3333namespace v8 {
3434namespace internal {
3535
36- v8::CpuProfile* ProfilerExtension::last_profile = NULL ;
36+ v8::CpuProfiler* ProfilerExtension::profiler_ = nullptr ;
37+ v8::CpuProfile* ProfilerExtension::last_profile = nullptr ;
3738const char * ProfilerExtension::kSource =
3839 " native function startProfiling();"
3940 " native function stopProfiling();"
@@ -58,24 +59,22 @@ v8::Local<v8::FunctionTemplate> ProfilerExtension::GetNativeFunctionTemplate(
5859
5960void ProfilerExtension::StartProfiling (
6061 const v8::FunctionCallbackInfo<v8::Value>& args) {
61- last_profile = NULL ;
62- v8::CpuProfiler* cpu_profiler = args.GetIsolate ()->GetCpuProfiler ();
63- cpu_profiler->StartProfiling ((args.Length () > 0 )
64- ? args[0 ].As <v8::String>()
65- : v8::String::Empty (args.GetIsolate ()));
62+ last_profile = nullptr ;
63+ profiler_->StartProfiling (args.Length () > 0
64+ ? args[0 ].As <v8::String>()
65+ : v8::String::Empty (args.GetIsolate ()));
6666}
6767
6868void ProfilerExtension::StopProfiling (
6969 const v8::FunctionCallbackInfo<v8::Value>& args) {
70- v8::CpuProfiler* cpu_profiler = args.GetIsolate ()->GetCpuProfiler ();
71- last_profile = cpu_profiler->StopProfiling ((args.Length () > 0 )
72- ? args[0 ].As <v8::String>()
73- : v8::String::Empty (args.GetIsolate ()));
70+ last_profile = profiler_->StopProfiling (
71+ args.Length () > 0 ? args[0 ].As <v8::String>()
72+ : v8::String::Empty (args.GetIsolate ()));
7473}
7574
7675void ProfilerExtension::CollectSample (
7776 const v8::FunctionCallbackInfo<v8::Value>& args) {
78- args. GetIsolate ()-> GetCpuProfiler () ->CollectSample ();
77+ profiler_ ->CollectSample ();
7978}
8079
8180} // namespace internal
0 commit comments