Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Side by Side Diff: test/cctest/test-profile-generator.cc

Issue 17336003: remove all old style callbacks - patch 3 (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-log-stack-tracer.cc ('k') | test/cctest/test-thread-termination.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 786 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 } 797 }
798 798
799 799
800 // --- P r o f i l e r E x t e n s i o n --- 800 // --- P r o f i l e r E x t e n s i o n ---
801 801
802 class ProfilerExtension : public v8::Extension { 802 class ProfilerExtension : public v8::Extension {
803 public: 803 public:
804 ProfilerExtension() : v8::Extension("v8/profiler", kSource) { } 804 ProfilerExtension() : v8::Extension("v8/profiler", kSource) { }
805 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( 805 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
806 v8::Handle<v8::String> name); 806 v8::Handle<v8::String> name);
807 static v8::Handle<v8::Value> StartProfiling(const v8::Arguments& args); 807 static void StartProfiling(const v8::FunctionCallbackInfo<v8::Value>& args);
808 static v8::Handle<v8::Value> StopProfiling(const v8::Arguments& args); 808 static void StopProfiling(const v8::FunctionCallbackInfo<v8::Value>& args);
809 private: 809 private:
810 static const char* kSource; 810 static const char* kSource;
811 }; 811 };
812 812
813 813
814 const char* ProfilerExtension::kSource = 814 const char* ProfilerExtension::kSource =
815 "native function startProfiling();" 815 "native function startProfiling();"
816 "native function stopProfiling();"; 816 "native function stopProfiling();";
817 817
818 v8::Handle<v8::FunctionTemplate> ProfilerExtension::GetNativeFunction( 818 v8::Handle<v8::FunctionTemplate> ProfilerExtension::GetNativeFunction(
819 v8::Handle<v8::String> name) { 819 v8::Handle<v8::String> name) {
820 if (name->Equals(v8::String::New("startProfiling"))) { 820 if (name->Equals(v8::String::New("startProfiling"))) {
821 return v8::FunctionTemplate::New(ProfilerExtension::StartProfiling); 821 return v8::FunctionTemplate::New(ProfilerExtension::StartProfiling);
822 } else if (name->Equals(v8::String::New("stopProfiling"))) { 822 } else if (name->Equals(v8::String::New("stopProfiling"))) {
823 return v8::FunctionTemplate::New(ProfilerExtension::StopProfiling); 823 return v8::FunctionTemplate::New(ProfilerExtension::StopProfiling);
824 } else { 824 } else {
825 CHECK(false); 825 CHECK(false);
826 return v8::Handle<v8::FunctionTemplate>(); 826 return v8::Handle<v8::FunctionTemplate>();
827 } 827 }
828 } 828 }
829 829
830 830
831 v8::Handle<v8::Value> ProfilerExtension::StartProfiling( 831 void ProfilerExtension::StartProfiling(
832 const v8::Arguments& args) { 832 const v8::FunctionCallbackInfo<v8::Value>& args) {
833 v8::CpuProfiler* cpu_profiler = args.GetIsolate()->GetCpuProfiler(); 833 v8::CpuProfiler* cpu_profiler = args.GetIsolate()->GetCpuProfiler();
834 if (args.Length() > 0) 834 if (args.Length() > 0)
835 cpu_profiler->StartCpuProfiling(args[0].As<v8::String>()); 835 cpu_profiler->StartCpuProfiling(args[0].As<v8::String>());
836 else 836 else
837 cpu_profiler->StartCpuProfiling(v8::String::New("")); 837 cpu_profiler->StartCpuProfiling(v8::String::New(""));
838 return v8::Undefined();
839 } 838 }
840 839
841 840
842 v8::Handle<v8::Value> ProfilerExtension::StopProfiling( 841 void ProfilerExtension::StopProfiling(
843 const v8::Arguments& args) { 842 const v8::FunctionCallbackInfo<v8::Value>& args) {
844 v8::CpuProfiler* cpu_profiler = args.GetIsolate()->GetCpuProfiler(); 843 v8::CpuProfiler* cpu_profiler = args.GetIsolate()->GetCpuProfiler();
845 if (args.Length() > 0) 844 if (args.Length() > 0)
846 cpu_profiler->StopCpuProfiling(args[0].As<v8::String>()); 845 cpu_profiler->StopCpuProfiling(args[0].As<v8::String>());
847 else 846 else
848 cpu_profiler->StopCpuProfiling(v8::String::New("")); 847 cpu_profiler->StopCpuProfiling(v8::String::New(""));
849 return v8::Undefined();
850 } 848 }
851 849
852 850
853 static ProfilerExtension kProfilerExtension; 851 static ProfilerExtension kProfilerExtension;
854 v8::DeclareExtension kProfilerExtensionDeclaration(&kProfilerExtension); 852 v8::DeclareExtension kProfilerExtensionDeclaration(&kProfilerExtension);
855 853
856 static const ProfileNode* PickChild(const ProfileNode* parent, 854 static const ProfileNode* PickChild(const ProfileNode* parent,
857 const char* name) { 855 const char* name) {
858 for (int i = 0; i < parent->children()->length(); ++i) { 856 for (int i = 0; i < parent->children()->length(); ++i) {
859 const ProfileNode* child = parent->children()->at(i); 857 const ProfileNode* child = parent->children()->at(i);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 i::OS::SNPrintF(title, "%d", i); 921 i::OS::SNPrintF(title, "%d", i);
924 // UID must be > 0. 922 // UID must be > 0.
925 CHECK(collection.StartProfiling(title.start(), i + 1, false)); 923 CHECK(collection.StartProfiling(title.start(), i + 1, false));
926 titles[i] = title.start(); 924 titles[i] = title.start();
927 } 925 }
928 CHECK(!collection.StartProfiling( 926 CHECK(!collection.StartProfiling(
929 "maximum", CpuProfilesCollection::kMaxSimultaneousProfiles + 1, false)); 927 "maximum", CpuProfilesCollection::kMaxSimultaneousProfiles + 1, false));
930 for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i) 928 for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i)
931 i::DeleteArray(titles[i]); 929 i::DeleteArray(titles[i]);
932 } 930 }
OLDNEW
« no previous file with comments | « test/cctest/test-log-stack-tracer.cc ('k') | test/cctest/test-thread-termination.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698