Chromium Code Reviews| Index: test/cctest/profiler-extension.cc |
| diff --git a/test/cctest/profiler-extension.cc b/test/cctest/profiler-extension.cc |
| index a917932978c128e27b044da453facbcdf8b4f506..5e4917c83f0c2e397fbaba4fc2a614ba0535e616 100644 |
| --- a/test/cctest/profiler-extension.cc |
| +++ b/test/cctest/profiler-extension.cc |
| @@ -37,31 +37,33 @@ namespace internal { |
| v8::CpuProfile* ProfilerExtension::last_profile = NULL; |
| const char* ProfilerExtension::kSource = |
| "native function startProfiling();" |
| - "native function stopProfiling();"; |
| + "native function stopProfiling();" |
| + "native function collectSample();"; |
| + |
| +namespace { |
| +v8::Local<v8::String> v8_str(v8::Isolate* isolate, const char* string) { |
|
yurys
2016/02/05 17:33:04
Please use the one defined in v8/test/cctest/cctes
alph
2016/02/05 17:52:26
Done that, just forgot to upload. ;-)
|
| + return v8::String::NewFromUtf8(isolate, string, v8::NewStringType::kNormal) |
| + .ToLocalChecked(); |
| +} |
| +} // namespace |
| v8::Local<v8::FunctionTemplate> ProfilerExtension::GetNativeFunctionTemplate( |
| v8::Isolate* isolate, v8::Local<v8::String> name) { |
| v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
| - if (name->Equals(context, v8::String::NewFromUtf8(isolate, "startProfiling", |
| - v8::NewStringType::kNormal) |
| - .ToLocalChecked()) |
| - .FromJust()) { |
| + if (name->Equals(context, v8_str(isolate, "startProfiling")).FromJust()) { |
| return v8::FunctionTemplate::New(isolate, |
| ProfilerExtension::StartProfiling); |
| - } else if (name->Equals(context, |
| - v8::String::NewFromUtf8(isolate, "stopProfiling", |
| - v8::NewStringType::kNormal) |
| - .ToLocalChecked()) |
| - .FromJust()) { |
| - return v8::FunctionTemplate::New(isolate, |
| - ProfilerExtension::StopProfiling); |
| - } else { |
| - CHECK(false); |
| - return v8::Local<v8::FunctionTemplate>(); |
| } |
| + if (name->Equals(context, v8_str(isolate, "stopProfiling")).FromJust()) { |
| + return v8::FunctionTemplate::New(isolate, ProfilerExtension::StopProfiling); |
| + } |
| + if (name->Equals(context, v8_str(isolate, "collectSample")).FromJust()) { |
| + return v8::FunctionTemplate::New(isolate, ProfilerExtension::CollectSample); |
| + } |
| + CHECK(false); |
| + return v8::Local<v8::FunctionTemplate>(); |
| } |
| - |
| void ProfilerExtension::StartProfiling( |
| const v8::FunctionCallbackInfo<v8::Value>& args) { |
| last_profile = NULL; |
| @@ -71,7 +73,6 @@ void ProfilerExtension::StartProfiling( |
| : v8::String::Empty(args.GetIsolate())); |
| } |
| - |
| void ProfilerExtension::StopProfiling( |
| const v8::FunctionCallbackInfo<v8::Value>& args) { |
| v8::CpuProfiler* cpu_profiler = args.GetIsolate()->GetCpuProfiler(); |
| @@ -80,5 +81,10 @@ void ProfilerExtension::StopProfiling( |
| : v8::String::Empty(args.GetIsolate())); |
| } |
| +void ProfilerExtension::CollectSample( |
| + const v8::FunctionCallbackInfo<v8::Value>& args) { |
| + args.GetIsolate()->GetCpuProfiler()->CollectSample(); |
|
yurys
2016/02/05 17:33:04
The whole idea of the tests that now call this nat
alph
2016/02/05 17:52:26
The tests I'm unflaking are mostly checking the st
alph
2016/02/05 18:03:33
Ok, how about I drop the CheckChildrenNames which
yurys
2016/02/05 18:07:33
Well, the tests like JsNative1JsNative2JsSample ar
|
| +} |
| + |
| } // namespace internal |
| } // namespace v8 |