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