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

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

Issue 101323012: Revert of Stop recording CPU profiles when Profiler agent is disabled (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years 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 | « LayoutTests/inspector-protocol/cpu-profiler/record-cpu-profile.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 doEnable(); 150 doEnable();
151 } 151 }
152 152
153 void InspectorProfilerAgent::doEnable() 153 void InspectorProfilerAgent::doEnable()
154 { 154 {
155 m_instrumentingAgents->setInspectorProfilerAgent(this); 155 m_instrumentingAgents->setInspectorProfilerAgent(this);
156 } 156 }
157 157
158 void InspectorProfilerAgent::disable(ErrorString*) 158 void InspectorProfilerAgent::disable(ErrorString*)
159 { 159 {
160 for (Vector<ProfileDescriptor>::const_reverse_iterator it = m_startedProfile s.rbegin(); it != m_startedProfiles.rend(); ++it)
161 m_keepAliveProfile = ScriptProfiler::stop(it->m_id);
162 m_startedProfiles.clear();
163 stop(0, 0);
164
165 m_keepAliveProfile.clear(); 160 m_keepAliveProfile.clear();
166 m_instrumentingAgents->setInspectorProfilerAgent(0); 161 m_instrumentingAgents->setInspectorProfilerAgent(0);
167 m_state->setBoolean(ProfilerAgentState::profilerEnabled, false); 162 m_state->setBoolean(ProfilerAgentState::profilerEnabled, false);
168 } 163 }
169 164
170 bool InspectorProfilerAgent::enabled() 165 bool InspectorProfilerAgent::enabled()
171 { 166 {
172 return m_state->getBoolean(ProfilerAgentState::profilerEnabled); 167 return m_state->getBoolean(ProfilerAgentState::profilerEnabled);
173 } 168 }
174 169
175 void InspectorProfilerAgent::setSamplingInterval(ErrorString* error, int interva l) 170 void InspectorProfilerAgent::setSamplingInterval(ErrorString* error, int interva l)
176 { 171 {
177 if (m_recordingCPUProfile) { 172 if (m_recordingCPUProfile) {
178 *error = "Cannot change sampling interval when profiling."; 173 *error = "Cannot change sampling interval when profiling.";
179 return; 174 return;
180 } 175 }
181 m_state->setLong(ProfilerAgentState::samplingInterval, interval); 176 m_state->setLong(ProfilerAgentState::samplingInterval, interval);
182 ScriptProfiler::setSamplingInterval(interval); 177 ScriptProfiler::setSamplingInterval(interval);
183 } 178 }
184 179
185 void InspectorProfilerAgent::setFrontend(InspectorFrontend* frontend) 180 void InspectorProfilerAgent::setFrontend(InspectorFrontend* frontend)
186 { 181 {
187 m_frontend = frontend->profiler(); 182 m_frontend = frontend->profiler();
188 } 183 }
189 184
190 void InspectorProfilerAgent::clearFrontend() 185 void InspectorProfilerAgent::clearFrontend()
191 { 186 {
192 m_frontend = 0; 187 m_frontend = 0;
188 stop(0, 0);
189 m_injectedScriptManager->injectedScriptHost()->clearInspectedObjects();
193 ErrorString error; 190 ErrorString error;
194 disable(&error); 191 disable(&error);
195 m_injectedScriptManager->injectedScriptHost()->clearInspectedObjects();
196 } 192 }
197 193
198 void InspectorProfilerAgent::restore() 194 void InspectorProfilerAgent::restore()
199 { 195 {
200 if (m_state->getBoolean(ProfilerAgentState::profilerEnabled)) { 196 if (m_state->getBoolean(ProfilerAgentState::profilerEnabled)) {
201 doEnable(); 197 doEnable();
202 m_frontend->resetProfiles(); 198 m_frontend->resetProfiles();
203 } 199 }
204 if (long interval = m_state->getLong(ProfilerAgentState::samplingInterval, 0 )) 200 if (long interval = m_state->getLong(ProfilerAgentState::samplingInterval, 0 ))
205 ScriptProfiler::setSamplingInterval(interval); 201 ScriptProfiler::setSamplingInterval(interval);
206 if (m_state->getBoolean(ProfilerAgentState::userInitiatedProfiling)) 202 if (m_state->getBoolean(ProfilerAgentState::userInitiatedProfiling))
207 start(); 203 start();
208 } 204 }
209 205
210 void InspectorProfilerAgent::start(ErrorString* error) 206 void InspectorProfilerAgent::start(ErrorString* error)
211 { 207 {
212 if (m_recordingCPUProfile) 208 if (m_recordingCPUProfile)
213 return; 209 return;
214 if (!enabled()) { 210 if (!enabled()) {
215 *error = "Profiler is not enabled"; 211 ErrorString error;
216 return; 212 enable(&error);
217 } 213 }
218 m_recordingCPUProfile = true; 214 m_recordingCPUProfile = true;
219 if (m_overlay) 215 if (m_overlay)
220 m_overlay->startedRecordingProfile(); 216 m_overlay->startedRecordingProfile();
221 m_frontendInitiatedProfileId = String::number(m_nextProfileId++); 217 m_frontendInitiatedProfileId = String::number(m_nextProfileId++);
222 ScriptProfiler::start(m_frontendInitiatedProfileId); 218 ScriptProfiler::start(m_frontendInitiatedProfileId);
223 m_state->setBoolean(ProfilerAgentState::userInitiatedProfiling, true); 219 m_state->setBoolean(ProfilerAgentState::userInitiatedProfiling, true);
224 } 220 }
225 221
226 void InspectorProfilerAgent::stop(ErrorString* errorString, RefPtr<TypeBuilder:: Profiler::CPUProfile>& profile) 222 void InspectorProfilerAgent::stop(ErrorString* errorString, RefPtr<TypeBuilder:: Profiler::CPUProfile>& profile)
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 idleStarted(); 284 idleStarted();
289 } 285 }
290 286
291 void InspectorProfilerAgent::didLeaveNestedRunLoop() 287 void InspectorProfilerAgent::didLeaveNestedRunLoop()
292 { 288 {
293 idleFinished(); 289 idleFinished();
294 } 290 }
295 291
296 } // namespace WebCore 292 } // namespace WebCore
297 293
OLDNEW
« no previous file with comments | « LayoutTests/inspector-protocol/cpu-profiler/record-cpu-profile.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698