| 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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 return; | 223 return; |
| 224 if (!enabled()) { | 224 if (!enabled()) { |
| 225 ErrorString error; | 225 ErrorString error; |
| 226 enable(&error); | 226 enable(&error); |
| 227 } | 227 } |
| 228 m_recordingCPUProfile = true; | 228 m_recordingCPUProfile = true; |
| 229 if (m_overlay) | 229 if (m_overlay) |
| 230 m_overlay->startedRecordingProfile(); | 230 m_overlay->startedRecordingProfile(); |
| 231 String title = getCurrentUserInitiatedProfileName(true); | 231 String title = getCurrentUserInitiatedProfileName(true); |
| 232 ScriptProfiler::start(title); | 232 ScriptProfiler::start(title); |
| 233 toggleRecordButton(true); | |
| 234 m_state->setBoolean(ProfilerAgentState::userInitiatedProfiling, true); | 233 m_state->setBoolean(ProfilerAgentState::userInitiatedProfiling, true); |
| 235 } | 234 } |
| 236 | 235 |
| 237 void InspectorProfilerAgent::stop(ErrorString* errorString, RefPtr<TypeBuilder::
Profiler::ProfileHeader>& header) | 236 void InspectorProfilerAgent::stop(ErrorString* errorString, RefPtr<TypeBuilder::
Profiler::ProfileHeader>& header) |
| 238 { | 237 { |
| 239 header = stop(errorString); | 238 header = stop(errorString); |
| 240 } | 239 } |
| 241 | 240 |
| 242 PassRefPtr<TypeBuilder::Profiler::ProfileHeader> InspectorProfilerAgent::stop(Er
rorString* errorString) | 241 PassRefPtr<TypeBuilder::Profiler::ProfileHeader> InspectorProfilerAgent::stop(Er
rorString* errorString) |
| 243 { | 242 { |
| 244 if (!m_recordingCPUProfile) { | 243 if (!m_recordingCPUProfile) { |
| 245 if (errorString) | 244 if (errorString) |
| 246 *errorString = "No recording profiles found"; | 245 *errorString = "No recording profiles found"; |
| 247 return 0; | 246 return 0; |
| 248 } | 247 } |
| 249 m_recordingCPUProfile = false; | 248 m_recordingCPUProfile = false; |
| 250 if (m_overlay) | 249 if (m_overlay) |
| 251 m_overlay->finishedRecordingProfile(); | 250 m_overlay->finishedRecordingProfile(); |
| 252 String title = getCurrentUserInitiatedProfileName(); | 251 String title = getCurrentUserInitiatedProfileName(); |
| 253 RefPtr<ScriptProfile> profile = ScriptProfiler::stop(title); | 252 RefPtr<ScriptProfile> profile = ScriptProfiler::stop(title); |
| 254 RefPtr<TypeBuilder::Profiler::ProfileHeader> profileHeader; | 253 RefPtr<TypeBuilder::Profiler::ProfileHeader> profileHeader; |
| 255 if (profile) { | 254 if (profile) { |
| 256 addProfile(profile, 0, String()); | 255 addProfile(profile, 0, String()); |
| 257 profileHeader = createProfileHeader(*profile); | 256 profileHeader = createProfileHeader(*profile); |
| 258 } else if (errorString) | 257 } else if (errorString) |
| 259 *errorString = "Profile wasn't found"; | 258 *errorString = "Profile wasn't found"; |
| 260 toggleRecordButton(false); | |
| 261 m_state->setBoolean(ProfilerAgentState::userInitiatedProfiling, false); | 259 m_state->setBoolean(ProfilerAgentState::userInitiatedProfiling, false); |
| 262 return profileHeader; | 260 return profileHeader; |
| 263 } | 261 } |
| 264 | 262 |
| 265 void InspectorProfilerAgent::toggleRecordButton(bool isProfiling) | |
| 266 { | |
| 267 if (m_frontend) | |
| 268 m_frontend->setRecordingProfile(isProfiling); | |
| 269 } | |
| 270 | |
| 271 void InspectorProfilerAgent::idleFinished() | 263 void InspectorProfilerAgent::idleFinished() |
| 272 { | 264 { |
| 273 if (!m_profileNameIdleTimeMap || !m_profileNameIdleTimeMap->size()) | 265 if (!m_profileNameIdleTimeMap || !m_profileNameIdleTimeMap->size()) |
| 274 return; | 266 return; |
| 275 ScriptProfiler::setIdle(false); | 267 ScriptProfiler::setIdle(false); |
| 276 if (!m_idleStartTime) | 268 if (!m_idleStartTime) |
| 277 return; | 269 return; |
| 278 | 270 |
| 279 double idleTime = WTF::monotonicallyIncreasingTime() - m_idleStartTime; | 271 double idleTime = WTF::monotonicallyIncreasingTime() - m_idleStartTime; |
| 280 m_idleStartTime = 0.0; | 272 m_idleStartTime = 0.0; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 306 idleStarted(); | 298 idleStarted(); |
| 307 } | 299 } |
| 308 | 300 |
| 309 void InspectorProfilerAgent::didLeaveNestedRunLoop() | 301 void InspectorProfilerAgent::didLeaveNestedRunLoop() |
| 310 { | 302 { |
| 311 idleFinished(); | 303 idleFinished(); |
| 312 } | 304 } |
| 313 | 305 |
| 314 } // namespace WebCore | 306 } // namespace WebCore |
| 315 | 307 |
| OLD | NEW |