GCC Code Coverage Report
Directory: ../ Exec Total Coverage
File: /home/iojs/build/workspace/node-test-commit-linux-coverage-daily/nodes/benchmark/out/../src/api/async_resource.cc Lines: 24 24 100.0 %
Date: 2019-10-05 22:32:21 Branches: 2 4 50.0 %

Line Branch Exec Source
1
#include "node.h"
2
#include "env-inl.h"
3
4
namespace node {
5
6
using v8::Function;
7
using v8::Isolate;
8
using v8::Local;
9
using v8::MaybeLocal;
10
using v8::Object;
11
using v8::String;
12
using v8::Value;
13
14
536
AsyncResource::AsyncResource(Isolate* isolate,
15
                             Local<Object> resource,
16
                             const char* name,
17
                             async_id trigger_async_id)
18
536
    : env_(Environment::GetCurrent(isolate)),
19
1072
      resource_(isolate, resource) {
20
536
  CHECK_NOT_NULL(env_);
21
  async_context_ = EmitAsyncInit(isolate, resource, name,
22
536
                                 trigger_async_id);
23
536
}
24
25
1070
AsyncResource::~AsyncResource() {
26
532
  EmitAsyncDestroy(env_, async_context_);
27
532
  resource_.Reset();
28
538
}
29
30
2
MaybeLocal<Value> AsyncResource::MakeCallback(Local<Function> callback,
31
                                              int argc,
32
                                              Local<Value>* argv) {
33
  return node::MakeCallback(env_->isolate(), get_resource(),
34
                            callback, argc, argv,
35
2
                            async_context_);
36
}
37
38
2
MaybeLocal<Value> AsyncResource::MakeCallback(const char* method,
39
                                              int argc,
40
                                              Local<Value>* argv) {
41
  return node::MakeCallback(env_->isolate(), get_resource(),
42
                            method, argc, argv,
43
2
                            async_context_);
44
}
45
46
2
MaybeLocal<Value> AsyncResource::MakeCallback(Local<String> symbol,
47
                                              int argc,
48
                                              Local<Value>* argv) {
49
  return node::MakeCallback(env_->isolate(), get_resource(),
50
                            symbol, argc, argv,
51
2
                            async_context_);
52
}
53
54
14
Local<Object> AsyncResource::get_resource() {
55
28
  return resource_.Get(env_->isolate());
56
}
57
58
6
async_id AsyncResource::get_async_id() const {
59
6
  return async_context_.async_id;
60
}
61
62
6
async_id AsyncResource::get_trigger_async_id() const {
63
6
  return async_context_.trigger_async_id;
64
}
65
66
// TODO(addaleax): We shouldn’t need to use env_->isolate() if we’re just going
67
// to end up using the Isolate* to figure out the Environment* again.
68
639
AsyncResource::CallbackScope::CallbackScope(AsyncResource* res)
69
    : node::CallbackScope(res->env_->isolate(),
70
                          res->resource_.Get(res->env_->isolate()),
71
1278
                          res->async_context_) {}
72
73
}  // namespace node