GCC Code Coverage Report
Directory: ../ Exec Total Coverage
File: /home/iojs/build/workspace/node-test-commit-linux-coverage-daily/nodes/benchmark/out/../src/timers.cc Lines: 31 31 100.0 %
Date: 2019-02-23 22:23:05 Branches: 2 4 50.0 %

Line Branch Exec Source
1
#include "env-inl.h"
2
#include "util.h"
3
#include "v8.h"
4
5
#include <stdint.h>
6
7
namespace node {
8
namespace {
9
10
using v8::Array;
11
using v8::Context;
12
using v8::Function;
13
using v8::FunctionCallbackInfo;
14
using v8::Integer;
15
using v8::Local;
16
using v8::Object;
17
using v8::Value;
18
19
4396
void SetupTimers(const FunctionCallbackInfo<Value>& args) {
20
8792
  CHECK(args[0]->IsFunction());
21
8792
  CHECK(args[1]->IsFunction());
22
4396
  auto env = Environment::GetCurrent(args);
23
24
8792
  env->set_immediate_callback_function(args[0].As<Function>());
25
8792
  env->set_timers_callback_function(args[1].As<Function>());
26
4396
}
27
28
332354
void GetLibuvNow(const FunctionCallbackInfo<Value>& args) {
29
332354
  Environment* env = Environment::GetCurrent(args);
30
997062
  args.GetReturnValue().Set(env->GetNow());
31
332354
}
32
33
2033
void ScheduleTimer(const FunctionCallbackInfo<Value>& args) {
34
2033
  auto env = Environment::GetCurrent(args);
35
8132
  env->ScheduleTimer(args[0]->IntegerValue(env->context()).FromJust());
36
2033
}
37
38
1269
void ToggleTimerRef(const FunctionCallbackInfo<Value>& args) {
39
2538
  Environment::GetCurrent(args)->ToggleTimerRef(args[0]->IsTrue());
40
1269
}
41
42
25774
void ToggleImmediateRef(const FunctionCallbackInfo<Value>& args) {
43
51548
  Environment::GetCurrent(args)->ToggleImmediateRef(args[0]->IsTrue());
44
25774
}
45
46
4396
void Initialize(Local<Object> target,
47
                       Local<Value> unused,
48
                       Local<Context> context,
49
                       void* priv) {
50
4396
  Environment* env = Environment::GetCurrent(context);
51
52
4396
  env->SetMethod(target, "getLibuvNow", GetLibuvNow);
53
4396
  env->SetMethod(target, "setupTimers", SetupTimers);
54
4396
  env->SetMethod(target, "scheduleTimer", ScheduleTimer);
55
4396
  env->SetMethod(target, "toggleTimerRef", ToggleTimerRef);
56
4396
  env->SetMethod(target, "toggleImmediateRef", ToggleImmediateRef);
57
58
  target->Set(env->context(),
59
              FIXED_ONE_BYTE_STRING(env->isolate(), "immediateInfo"),
60
21980
              env->immediate_info()->fields().GetJSArray()).FromJust();
61
4396
}
62
63
64
}  // anonymous namespace
65
}  // namespace node
66
67
4288
NODE_MODULE_CONTEXT_AWARE_INTERNAL(timers, node::Initialize)