OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "cctest.h" | 32 #include "cctest.h" |
33 | 33 |
34 const v8::CpuProfile* ProfilerExtension::last_profile = NULL; | 34 const v8::CpuProfile* ProfilerExtension::last_profile = NULL; |
35 const char* ProfilerExtension::kSource = | 35 const char* ProfilerExtension::kSource = |
36 "native function startProfiling();" | 36 "native function startProfiling();" |
37 "native function stopProfiling();"; | 37 "native function stopProfiling();"; |
38 | 38 |
39 v8::Handle<v8::FunctionTemplate> ProfilerExtension::GetNativeFunctionTemplate( | 39 v8::Handle<v8::FunctionTemplate> ProfilerExtension::GetNativeFunctionTemplate( |
40 v8::Isolate* isolate, v8::Handle<v8::String> name) { | 40 v8::Isolate* isolate, v8::Handle<v8::String> name) { |
41 if (name->Equals(v8::String::NewFromUtf8(isolate, "startProfiling"))) { | 41 if (name->Equals(v8::String::NewFromUtf8(isolate, "startProfiling"))) { |
42 return v8::FunctionTemplate::New(ProfilerExtension::StartProfiling); | 42 return v8::FunctionTemplate::New(isolate, |
| 43 ProfilerExtension::StartProfiling); |
43 } else if (name->Equals(v8::String::NewFromUtf8(isolate, "stopProfiling"))) { | 44 } else if (name->Equals(v8::String::NewFromUtf8(isolate, "stopProfiling"))) { |
44 return v8::FunctionTemplate::New(ProfilerExtension::StopProfiling); | 45 return v8::FunctionTemplate::New(isolate, |
| 46 ProfilerExtension::StopProfiling); |
45 } else { | 47 } else { |
46 CHECK(false); | 48 CHECK(false); |
47 return v8::Handle<v8::FunctionTemplate>(); | 49 return v8::Handle<v8::FunctionTemplate>(); |
48 } | 50 } |
49 } | 51 } |
50 | 52 |
51 | 53 |
52 void ProfilerExtension::StartProfiling( | 54 void ProfilerExtension::StartProfiling( |
53 const v8::FunctionCallbackInfo<v8::Value>& args) { | 55 const v8::FunctionCallbackInfo<v8::Value>& args) { |
54 last_profile = NULL; | 56 last_profile = NULL; |
55 v8::CpuProfiler* cpu_profiler = args.GetIsolate()->GetCpuProfiler(); | 57 v8::CpuProfiler* cpu_profiler = args.GetIsolate()->GetCpuProfiler(); |
56 cpu_profiler->StartCpuProfiling((args.Length() > 0) | 58 cpu_profiler->StartCpuProfiling((args.Length() > 0) |
57 ? args[0].As<v8::String>() | 59 ? args[0].As<v8::String>() |
58 : v8::String::Empty(args.GetIsolate())); | 60 : v8::String::Empty(args.GetIsolate())); |
59 } | 61 } |
60 | 62 |
61 | 63 |
62 void ProfilerExtension::StopProfiling( | 64 void ProfilerExtension::StopProfiling( |
63 const v8::FunctionCallbackInfo<v8::Value>& args) { | 65 const v8::FunctionCallbackInfo<v8::Value>& args) { |
64 v8::CpuProfiler* cpu_profiler = args.GetIsolate()->GetCpuProfiler(); | 66 v8::CpuProfiler* cpu_profiler = args.GetIsolate()->GetCpuProfiler(); |
65 last_profile = cpu_profiler->StopCpuProfiling((args.Length() > 0) | 67 last_profile = cpu_profiler->StopCpuProfiling((args.Length() > 0) |
66 ? args[0].As<v8::String>() | 68 ? args[0].As<v8::String>() |
67 : v8::String::Empty(args.GetIsolate())); | 69 : v8::String::Empty(args.GetIsolate())); |
68 } | 70 } |
69 | 71 |
70 | 72 |
71 static ProfilerExtension kProfilerExtension; | 73 static ProfilerExtension kProfilerExtension; |
72 v8::DeclareExtension kProfilerExtensionDeclaration(&kProfilerExtension); | 74 v8::DeclareExtension kProfilerExtensionDeclaration(&kProfilerExtension); |
OLD | NEW |