| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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) | 86 PassOwnPtr<InspectorProfilerAgent> InspectorProfilerAgent::create(InjectedScript
Manager* injectedScriptManager, InspectorOverlay* overlay, InspectorAgentRegistr
y* registry) |
| 87 { | 87 { |
| 88 return adoptPtr(new InspectorProfilerAgent(injectedScriptManager, overlay)); | 88 return adoptPtr(new InspectorProfilerAgent(injectedScriptManager, overlay, r
egistry)); |
| 89 } | 89 } |
| 90 | 90 |
| 91 InspectorProfilerAgent::InspectorProfilerAgent(InjectedScriptManager* injectedSc
riptManager, InspectorOverlay* overlay) | 91 InspectorProfilerAgent::InspectorProfilerAgent(InjectedScriptManager* injectedSc
riptManager, InspectorOverlay* overlay, InspectorAgentRegistry* registry) |
| 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) |
| 99 { | 100 { |
| 100 } | 101 } |
| 101 | 102 |
| 102 InspectorProfilerAgent::~InspectorProfilerAgent() | 103 InspectorProfilerAgent::~InspectorProfilerAgent() |
| 103 { | 104 { |
| 104 } | 105 } |
| 105 | 106 |
| 106 void InspectorProfilerAgent::consoleProfile(const String& title, ScriptState* sc
riptState) | 107 void InspectorProfilerAgent::consoleProfile(const String& title, ScriptState* sc
riptState) |
| 107 { | 108 { |
| 108 ASSERT(m_frontend && enabled()); | 109 ASSERT(m_frontend && enabled()); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 if (m_recordingCPUProfile) | 211 if (m_recordingCPUProfile) |
| 211 return; | 212 return; |
| 212 if (!enabled()) { | 213 if (!enabled()) { |
| 213 *error = "Profiler is not enabled"; | 214 *error = "Profiler is not enabled"; |
| 214 return; | 215 return; |
| 215 } | 216 } |
| 216 m_recordingCPUProfile = true; | 217 m_recordingCPUProfile = true; |
| 217 if (m_overlay) | 218 if (m_overlay) |
| 218 m_overlay->startedRecordingProfile(); | 219 m_overlay->startedRecordingProfile(); |
| 219 m_frontendInitiatedProfileId = nextProfileId(); | 220 m_frontendInitiatedProfileId = nextProfileId(); |
| 221 m_registry->profilerStarted(); |
| 220 ScriptProfiler::start(m_frontendInitiatedProfileId); | 222 ScriptProfiler::start(m_frontendInitiatedProfileId); |
| 221 m_state->setBoolean(ProfilerAgentState::userInitiatedProfiling, true); | 223 m_state->setBoolean(ProfilerAgentState::userInitiatedProfiling, true); |
| 222 } | 224 } |
| 223 | 225 |
| 224 void InspectorProfilerAgent::stop(ErrorString* errorString, RefPtr<TypeBuilder::
Profiler::CPUProfile>& profile) | 226 void InspectorProfilerAgent::stop(ErrorString* errorString, RefPtr<TypeBuilder::
Profiler::CPUProfile>& profile) |
| 225 { | 227 { |
| 226 stop(errorString, &profile); | 228 stop(errorString, &profile); |
| 227 } | 229 } |
| 228 | 230 |
| 229 void InspectorProfilerAgent::stop(ErrorString* errorString, RefPtr<TypeBuilder::
Profiler::CPUProfile>* profile) | 231 void InspectorProfilerAgent::stop(ErrorString* errorString, RefPtr<TypeBuilder::
Profiler::CPUProfile>* profile) |
| 230 { | 232 { |
| 231 if (!m_recordingCPUProfile) { | 233 if (!m_recordingCPUProfile) { |
| 232 if (errorString) | 234 if (errorString) |
| 233 *errorString = "No recording profiles found"; | 235 *errorString = "No recording profiles found"; |
| 234 return; | 236 return; |
| 235 } | 237 } |
| 236 m_recordingCPUProfile = false; | 238 m_recordingCPUProfile = false; |
| 237 if (m_overlay) | 239 if (m_overlay) |
| 238 m_overlay->finishedRecordingProfile(); | 240 m_overlay->finishedRecordingProfile(); |
| 239 RefPtr<ScriptProfile> scriptProfile = ScriptProfiler::stop(m_frontendInitiat
edProfileId); | 241 RefPtr<ScriptProfile> scriptProfile = ScriptProfiler::stop(m_frontendInitiat
edProfileId); |
| 242 m_registry->profilerStopped(); |
| 240 m_frontendInitiatedProfileId = String(); | 243 m_frontendInitiatedProfileId = String(); |
| 241 if (scriptProfile && profile) | 244 if (scriptProfile && profile) |
| 242 *profile = createCPUProfile(*scriptProfile); | 245 *profile = createCPUProfile(*scriptProfile); |
| 243 else if (errorString) | 246 else if (errorString) |
| 244 *errorString = "Profile wasn't found"; | 247 *errorString = "Profile wasn't found"; |
| 245 m_state->setBoolean(ProfilerAgentState::userInitiatedProfiling, false); | 248 m_state->setBoolean(ProfilerAgentState::userInitiatedProfiling, false); |
| 246 } | 249 } |
| 247 | 250 |
| 248 String InspectorProfilerAgent::nextProfileId() | 251 String InspectorProfilerAgent::nextProfileId() |
| 249 { | 252 { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 idleStarted(); | 293 idleStarted(); |
| 291 } | 294 } |
| 292 | 295 |
| 293 void InspectorProfilerAgent::didLeaveNestedRunLoop() | 296 void InspectorProfilerAgent::didLeaveNestedRunLoop() |
| 294 { | 297 { |
| 295 idleFinished(); | 298 idleFinished(); |
| 296 } | 299 } |
| 297 | 300 |
| 298 } // namespace WebCore | 301 } // namespace WebCore |
| 299 | 302 |
| OLD | NEW |