GCC Code Coverage Report
Directory: ../ Exec Total Coverage
File: /home/iojs/build/workspace/node-test-commit-linux-coverage-daily/nodes/benchmark/out/../src/async_wrap-inl.h Lines: 21 22 95.5 %
Date: 2020-02-27 22:14:15 Branches: 3 4 75.0 %

Line Branch Exec Source
1
// Copyright Joyent, Inc. and other Node contributors.
2
//
3
// Permission is hereby granted, free of charge, to any person obtaining a
4
// copy of this software and associated documentation files (the
5
// "Software"), to deal in the Software without restriction, including
6
// without limitation the rights to use, copy, modify, merge, publish,
7
// distribute, sublicense, and/or sell copies of the Software, and to permit
8
// persons to whom the Software is furnished to do so, subject to the
9
// following conditions:
10
//
11
// The above copyright notice and this permission notice shall be included
12
// in all copies or substantial portions of the Software.
13
//
14
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20
// USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22
#ifndef SRC_ASYNC_WRAP_INL_H_
23
#define SRC_ASYNC_WRAP_INL_H_
24
25
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
26
27
#include "async_wrap.h"
28
#include "base_object-inl.h"
29
#include "node_internals.h"
30
31
namespace node {
32
33
3008050
inline AsyncWrap::ProviderType AsyncWrap::provider_type() const {
34
3008050
  return provider_type_;
35
}
36
37
5190
inline AsyncWrap::ProviderType AsyncWrap::set_provider_type(
38
    AsyncWrap::ProviderType provider) {
39
5190
  provider_type_ = provider;
40
5190
  return provider_type_;
41
}
42
43
1141206
inline double AsyncWrap::get_async_id() const {
44
1141206
  return async_id_;
45
}
46
47
48
595267
inline double AsyncWrap::get_trigger_async_id() const {
49
595267
  return trigger_async_id_;
50
}
51
52
53
87972
inline v8::MaybeLocal<v8::Value> AsyncWrap::MakeCallback(
54
    const v8::Local<v8::String> symbol,
55
    int argc,
56
    v8::Local<v8::Value>* argv) {
57
87972
  return MakeCallback(symbol.As<v8::Name>(), argc, argv);
58
}
59
60
61
43501
inline v8::MaybeLocal<v8::Value> AsyncWrap::MakeCallback(
62
    const v8::Local<v8::Symbol> symbol,
63
    int argc,
64
    v8::Local<v8::Value>* argv) {
65
43501
  return MakeCallback(symbol.As<v8::Name>(), argc, argv);
66
}
67
68
69
131474
inline v8::MaybeLocal<v8::Value> AsyncWrap::MakeCallback(
70
    const v8::Local<v8::Name> symbol,
71
    int argc,
72
    v8::Local<v8::Value>* argv) {
73
  v8::Local<v8::Value> cb_v;
74
394422
  if (!object()->Get(env()->context(), symbol).ToLocal(&cb_v))
75
    return v8::MaybeLocal<v8::Value>();
76
131473
  if (!cb_v->IsFunction()) {
77
    // TODO(addaleax): We should throw an error here to fulfill the
78
    // `MaybeLocal<>` API contract.
79
1
    return v8::MaybeLocal<v8::Value>();
80
  }
81
131475
  return MakeCallback(cb_v.As<v8::Function>(), argc, argv);
82
}
83
84
85
// Defined here to avoid a circular dependency with env-inl.h.
86
448983
inline AsyncHooks::DefaultTriggerAsyncIdScope ::DefaultTriggerAsyncIdScope(
87
448983
    AsyncWrap* async_wrap)
88
    : DefaultTriggerAsyncIdScope(async_wrap->env(),
89
448983
                                 async_wrap->get_async_id()) {}
90
91
}  // namespace node
92
93
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
94
95
#endif  // SRC_ASYNC_WRAP_INL_H_