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: 29 29 100.0 %
Date: 2020-05-27 22:15:15 Branches: 1 2 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
536
                             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
1602
AsyncResource::~AsyncResource() {
26
532
  EmitAsyncDestroy(env_, async_context_);
27
538
}
28
29
2
MaybeLocal<Value> AsyncResource::MakeCallback(Local<Function> callback,
30
                                              int argc,
31
                                              Local<Value>* argv) {
32
2
  return node::MakeCallback(env_->isolate(), get_resource(),
33
                            callback, argc, argv,
34
4
                            async_context_);
35
}
36
37
2
MaybeLocal<Value> AsyncResource::MakeCallback(const char* method,
38
                                              int argc,
39
                                              Local<Value>* argv) {
40
2
  return node::MakeCallback(env_->isolate(), get_resource(),
41
                            method, argc, argv,
42
4
                            async_context_);
43
}
44
45
2
MaybeLocal<Value> AsyncResource::MakeCallback(Local<String> symbol,
46
                                              int argc,
47
                                              Local<Value>* argv) {
48
2
  return node::MakeCallback(env_->isolate(), get_resource(),
49
                            symbol, argc, argv,
50
4
                            async_context_);
51
}
52
53
14
Local<Object> AsyncResource::get_resource() {
54
28
  return resource_.Get(env_->isolate());
55
}
56
57
6
async_id AsyncResource::get_async_id() const {
58
6
  return async_context_.async_id;
59
}
60
61
6
async_id AsyncResource::get_trigger_async_id() const {
62
6
  return async_context_.trigger_async_id;
63
}
64
65
// TODO(addaleax): We shouldn’t need to use env_->isolate() if we’re just going
66
// to end up using the Isolate* to figure out the Environment* again.
67
639
AsyncResource::CallbackScope::CallbackScope(AsyncResource* res)
68
639
    : node::CallbackScope(res->env_->isolate(),
69
639
                          res->resource_.Get(res->env_->isolate()),
70
1278
                          res->async_context_) {}
71
72
}  // namespace node