| OLD | NEW |
| 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 doEnable(); | 153 doEnable(); |
| 154 } | 154 } |
| 155 | 155 |
| 156 void InspectorProfilerAgent::doEnable() | 156 void InspectorProfilerAgent::doEnable() |
| 157 { | 157 { |
| 158 m_instrumentingAgents->setInspectorProfilerAgent(this); | 158 m_instrumentingAgents->setInspectorProfilerAgent(this); |
| 159 } | 159 } |
| 160 | 160 |
| 161 void InspectorProfilerAgent::disable(ErrorString*) | 161 void InspectorProfilerAgent::disable(ErrorString*) |
| 162 { | 162 { |
| 163 for (Vector<ProfileDescriptor>::const_reverse_iterator it = m_startedProfile
s.rbegin(); it != m_startedProfiles.rend(); ++it) |
| 164 m_keepAliveProfile = ScriptProfiler::stop(it->m_id); |
| 165 m_startedProfiles.clear(); |
| 166 stop(0, 0); |
| 167 |
| 163 m_keepAliveProfile.clear(); | 168 m_keepAliveProfile.clear(); |
| 164 m_instrumentingAgents->setInspectorProfilerAgent(0); | 169 m_instrumentingAgents->setInspectorProfilerAgent(0); |
| 165 m_state->setBoolean(ProfilerAgentState::profilerEnabled, false); | 170 m_state->setBoolean(ProfilerAgentState::profilerEnabled, false); |
| 166 } | 171 } |
| 167 | 172 |
| 168 bool InspectorProfilerAgent::enabled() | 173 bool InspectorProfilerAgent::enabled() |
| 169 { | 174 { |
| 170 return m_state->getBoolean(ProfilerAgentState::profilerEnabled); | 175 return m_state->getBoolean(ProfilerAgentState::profilerEnabled); |
| 171 } | 176 } |
| 172 | 177 |
| 173 void InspectorProfilerAgent::setSamplingInterval(ErrorString* error, int interva
l) | 178 void InspectorProfilerAgent::setSamplingInterval(ErrorString* error, int interva
l) |
| 174 { | 179 { |
| 175 if (m_recordingCPUProfile) { | 180 if (m_recordingCPUProfile) { |
| 176 *error = "Cannot change sampling interval when profiling."; | 181 *error = "Cannot change sampling interval when profiling."; |
| 177 return; | 182 return; |
| 178 } | 183 } |
| 179 m_state->setLong(ProfilerAgentState::samplingInterval, interval); | 184 m_state->setLong(ProfilerAgentState::samplingInterval, interval); |
| 180 ScriptProfiler::setSamplingInterval(interval); | 185 ScriptProfiler::setSamplingInterval(interval); |
| 181 } | 186 } |
| 182 | 187 |
| 183 void InspectorProfilerAgent::setFrontend(InspectorFrontend* frontend) | 188 void InspectorProfilerAgent::setFrontend(InspectorFrontend* frontend) |
| 184 { | 189 { |
| 185 m_frontend = frontend->profiler(); | 190 m_frontend = frontend->profiler(); |
| 186 } | 191 } |
| 187 | 192 |
| 188 void InspectorProfilerAgent::clearFrontend() | 193 void InspectorProfilerAgent::clearFrontend() |
| 189 { | 194 { |
| 190 m_frontend = 0; | 195 m_frontend = 0; |
| 191 stop(0, 0); | |
| 192 m_injectedScriptManager->injectedScriptHost()->clearInspectedObjects(); | |
| 193 ErrorString error; | 196 ErrorString error; |
| 194 disable(&error); | 197 disable(&error); |
| 198 m_injectedScriptManager->injectedScriptHost()->clearInspectedObjects(); |
| 195 } | 199 } |
| 196 | 200 |
| 197 void InspectorProfilerAgent::restore() | 201 void InspectorProfilerAgent::restore() |
| 198 { | 202 { |
| 199 if (m_state->getBoolean(ProfilerAgentState::profilerEnabled)) { | 203 if (m_state->getBoolean(ProfilerAgentState::profilerEnabled)) { |
| 200 doEnable(); | 204 doEnable(); |
| 201 m_frontend->resetProfiles(); | 205 m_frontend->resetProfiles(); |
| 202 } | 206 } |
| 203 if (long interval = m_state->getLong(ProfilerAgentState::samplingInterval, 0
)) | 207 if (long interval = m_state->getLong(ProfilerAgentState::samplingInterval, 0
)) |
| 204 ScriptProfiler::setSamplingInterval(interval); | 208 ScriptProfiler::setSamplingInterval(interval); |
| 205 if (m_state->getBoolean(ProfilerAgentState::userInitiatedProfiling)) | 209 if (m_state->getBoolean(ProfilerAgentState::userInitiatedProfiling)) |
| 206 start(); | 210 start(); |
| 207 } | 211 } |
| 208 | 212 |
| 209 void InspectorProfilerAgent::start(ErrorString* error) | 213 void InspectorProfilerAgent::start(ErrorString* error) |
| 210 { | 214 { |
| 211 if (m_recordingCPUProfile) | 215 if (m_recordingCPUProfile) |
| 212 return; | 216 return; |
| 213 if (!enabled()) { | 217 if (!enabled()) { |
| 214 ErrorString error; | 218 *error = "Profiler is not enabled"; |
| 215 enable(&error); | 219 return; |
| 216 } | 220 } |
| 217 m_recordingCPUProfile = true; | 221 m_recordingCPUProfile = true; |
| 218 if (m_overlay) | 222 if (m_overlay) |
| 219 m_overlay->startedRecordingProfile(); | 223 m_overlay->startedRecordingProfile(); |
| 220 m_frontendInitiatedProfileId = String::number(m_nextProfileId++); | 224 m_frontendInitiatedProfileId = String::number(m_nextProfileId++); |
| 221 ScriptProfiler::start(m_frontendInitiatedProfileId); | 225 ScriptProfiler::start(m_frontendInitiatedProfileId); |
| 222 m_state->setBoolean(ProfilerAgentState::userInitiatedProfiling, true); | 226 m_state->setBoolean(ProfilerAgentState::userInitiatedProfiling, true); |
| 223 } | 227 } |
| 224 | 228 |
| 225 void InspectorProfilerAgent::stop(ErrorString* errorString, RefPtr<TypeBuilder::
Profiler::CPUProfile>& profile) | 229 void InspectorProfilerAgent::stop(ErrorString* errorString, RefPtr<TypeBuilder::
Profiler::CPUProfile>& profile) |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 idleStarted(); | 291 idleStarted(); |
| 288 } | 292 } |
| 289 | 293 |
| 290 void InspectorProfilerAgent::didLeaveNestedRunLoop() | 294 void InspectorProfilerAgent::didLeaveNestedRunLoop() |
| 291 { | 295 { |
| 292 idleFinished(); | 296 idleFinished(); |
| 293 } | 297 } |
| 294 | 298 |
| 295 } // namespace WebCore | 299 } // namespace WebCore |
| 296 | 300 |
| OLD | NEW |