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

Side by Side Diff: Source/core/inspector/InspectorProfilerAgent.cpp

Issue 327203002: Revert of DevTools: notify backend agents about profiler started/stopped events (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Google Inc. All rights reserved. 3 * Copyright (C) 2010 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 class InspectorProfilerAgent::ProfileDescriptor { 77 class InspectorProfilerAgent::ProfileDescriptor {
78 public: 78 public:
79 ProfileDescriptor(const String& id, const String& title) 79 ProfileDescriptor(const String& id, const String& title)
80 : m_id(id) 80 : m_id(id)
81 , m_title(title) { } 81 , m_title(title) { }
82 String m_id; 82 String m_id;
83 String m_title; 83 String m_title;
84 }; 84 };
85 85
86 PassOwnPtr<InspectorProfilerAgent> InspectorProfilerAgent::create(InjectedScript Manager* injectedScriptManager, InspectorOverlay* overlay, InspectorAgentRegistr y* registry) 86 PassOwnPtr<InspectorProfilerAgent> InspectorProfilerAgent::create(InjectedScript Manager* injectedScriptManager, InspectorOverlay* overlay)
87 { 87 {
88 return adoptPtr(new InspectorProfilerAgent(injectedScriptManager, overlay, r egistry)); 88 return adoptPtr(new InspectorProfilerAgent(injectedScriptManager, overlay));
89 } 89 }
90 90
91 InspectorProfilerAgent::InspectorProfilerAgent(InjectedScriptManager* injectedSc riptManager, InspectorOverlay* overlay, InspectorAgentRegistry* registry) 91 InspectorProfilerAgent::InspectorProfilerAgent(InjectedScriptManager* injectedSc riptManager, InspectorOverlay* overlay)
92 : InspectorBaseAgent<InspectorProfilerAgent>("Profiler") 92 : InspectorBaseAgent<InspectorProfilerAgent>("Profiler")
93 , m_injectedScriptManager(injectedScriptManager) 93 , m_injectedScriptManager(injectedScriptManager)
94 , m_frontend(0) 94 , m_frontend(0)
95 , m_recordingCPUProfile(false) 95 , m_recordingCPUProfile(false)
96 , m_profileNameIdleTimeMap(ScriptProfiler::currentProfileNameIdleTimeMap()) 96 , m_profileNameIdleTimeMap(ScriptProfiler::currentProfileNameIdleTimeMap())
97 , m_idleStartTime(0.0) 97 , m_idleStartTime(0.0)
98 , m_overlay(overlay) 98 , m_overlay(overlay)
99 , m_registry(registry)
100 { 99 {
101 } 100 }
102 101
103 InspectorProfilerAgent::~InspectorProfilerAgent() 102 InspectorProfilerAgent::~InspectorProfilerAgent()
104 { 103 {
105 } 104 }
106 105
107 void InspectorProfilerAgent::consoleProfile(const String& title, ScriptState* sc riptState) 106 void InspectorProfilerAgent::consoleProfile(const String& title, ScriptState* sc riptState)
108 { 107 {
109 ASSERT(m_frontend && enabled()); 108 ASSERT(m_frontend && enabled());
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 if (m_recordingCPUProfile) 210 if (m_recordingCPUProfile)
212 return; 211 return;
213 if (!enabled()) { 212 if (!enabled()) {
214 *error = "Profiler is not enabled"; 213 *error = "Profiler is not enabled";
215 return; 214 return;
216 } 215 }
217 m_recordingCPUProfile = true; 216 m_recordingCPUProfile = true;
218 if (m_overlay) 217 if (m_overlay)
219 m_overlay->startedRecordingProfile(); 218 m_overlay->startedRecordingProfile();
220 m_frontendInitiatedProfileId = nextProfileId(); 219 m_frontendInitiatedProfileId = nextProfileId();
221 m_registry->profilerStarted();
222 ScriptProfiler::start(m_frontendInitiatedProfileId); 220 ScriptProfiler::start(m_frontendInitiatedProfileId);
223 m_state->setBoolean(ProfilerAgentState::userInitiatedProfiling, true); 221 m_state->setBoolean(ProfilerAgentState::userInitiatedProfiling, true);
224 } 222 }
225 223
226 void InspectorProfilerAgent::stop(ErrorString* errorString, RefPtr<TypeBuilder:: Profiler::CPUProfile>& profile) 224 void InspectorProfilerAgent::stop(ErrorString* errorString, RefPtr<TypeBuilder:: Profiler::CPUProfile>& profile)
227 { 225 {
228 stop(errorString, &profile); 226 stop(errorString, &profile);
229 } 227 }
230 228
231 void InspectorProfilerAgent::stop(ErrorString* errorString, RefPtr<TypeBuilder:: Profiler::CPUProfile>* profile) 229 void InspectorProfilerAgent::stop(ErrorString* errorString, RefPtr<TypeBuilder:: Profiler::CPUProfile>* profile)
232 { 230 {
233 if (!m_recordingCPUProfile) { 231 if (!m_recordingCPUProfile) {
234 if (errorString) 232 if (errorString)
235 *errorString = "No recording profiles found"; 233 *errorString = "No recording profiles found";
236 return; 234 return;
237 } 235 }
238 m_recordingCPUProfile = false; 236 m_recordingCPUProfile = false;
239 if (m_overlay) 237 if (m_overlay)
240 m_overlay->finishedRecordingProfile(); 238 m_overlay->finishedRecordingProfile();
241 RefPtr<ScriptProfile> scriptProfile = ScriptProfiler::stop(m_frontendInitiat edProfileId); 239 RefPtr<ScriptProfile> scriptProfile = ScriptProfiler::stop(m_frontendInitiat edProfileId);
242 m_registry->profilerStopped();
243 m_frontendInitiatedProfileId = String(); 240 m_frontendInitiatedProfileId = String();
244 if (scriptProfile && profile) 241 if (scriptProfile && profile)
245 *profile = createCPUProfile(*scriptProfile); 242 *profile = createCPUProfile(*scriptProfile);
246 else if (errorString) 243 else if (errorString)
247 *errorString = "Profile wasn't found"; 244 *errorString = "Profile wasn't found";
248 m_state->setBoolean(ProfilerAgentState::userInitiatedProfiling, false); 245 m_state->setBoolean(ProfilerAgentState::userInitiatedProfiling, false);
249 } 246 }
250 247
251 String InspectorProfilerAgent::nextProfileId() 248 String InspectorProfilerAgent::nextProfileId()
252 { 249 {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 idleStarted(); 290 idleStarted();
294 } 291 }
295 292
296 void InspectorProfilerAgent::didLeaveNestedRunLoop() 293 void InspectorProfilerAgent::didLeaveNestedRunLoop()
297 { 294 {
298 idleFinished(); 295 idleFinished();
299 } 296 }
300 297
301 } // namespace WebCore 298 } // namespace WebCore
302 299
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorProfilerAgent.h ('k') | Source/core/inspector/InspectorTimelineAgent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698