| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/v8_inspector/V8ProfilerAgentImpl.h" | 5 #include "platform/v8_inspector/V8ProfilerAgentImpl.h" |
| 6 | 6 |
| 7 #include "platform/v8_inspector/Atomics.h" | 7 #include "platform/v8_inspector/Atomics.h" |
| 8 #include "platform/v8_inspector/V8DebuggerImpl.h" | 8 #include "platform/v8_inspector/V8DebuggerImpl.h" |
| 9 #include "platform/v8_inspector/V8InspectorSessionImpl.h" | 9 #include "platform/v8_inspector/V8InspectorSessionImpl.h" |
| 10 #include "platform/v8_inspector/V8StackTraceImpl.h" | 10 #include "platform/v8_inspector/V8StackTraceImpl.h" |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 if (m_recordingCPUProfile) | 252 if (m_recordingCPUProfile) |
| 253 return; | 253 return; |
| 254 if (!m_enabled) { | 254 if (!m_enabled) { |
| 255 *error = "Profiler is not enabled"; | 255 *error = "Profiler is not enabled"; |
| 256 return; | 256 return; |
| 257 } | 257 } |
| 258 m_recordingCPUProfile = true; | 258 m_recordingCPUProfile = true; |
| 259 m_frontendInitiatedProfileId = nextProfileId(); | 259 m_frontendInitiatedProfileId = nextProfileId(); |
| 260 startProfiling(m_frontendInitiatedProfileId); | 260 startProfiling(m_frontendInitiatedProfileId); |
| 261 m_state->setBoolean(ProfilerAgentState::userInitiatedProfiling, true); | 261 m_state->setBoolean(ProfilerAgentState::userInitiatedProfiling, true); |
| 262 m_session->client()->profilingStarted(); | |
| 263 } | 262 } |
| 264 | 263 |
| 265 void V8ProfilerAgentImpl::stop(ErrorString* errorString, std::unique_ptr<protoco
l::Profiler::CPUProfile>* profile) | 264 void V8ProfilerAgentImpl::stop(ErrorString* errorString, std::unique_ptr<protoco
l::Profiler::CPUProfile>* profile) |
| 266 { | 265 { |
| 267 if (!m_recordingCPUProfile) { | 266 if (!m_recordingCPUProfile) { |
| 268 if (errorString) | 267 if (errorString) |
| 269 *errorString = "No recording profiles found"; | 268 *errorString = "No recording profiles found"; |
| 270 return; | 269 return; |
| 271 } | 270 } |
| 272 m_recordingCPUProfile = false; | 271 m_recordingCPUProfile = false; |
| 273 std::unique_ptr<protocol::Profiler::CPUProfile> cpuProfile = stopProfiling(m
_frontendInitiatedProfileId, !!profile); | 272 std::unique_ptr<protocol::Profiler::CPUProfile> cpuProfile = stopProfiling(m
_frontendInitiatedProfileId, !!profile); |
| 274 if (profile) { | 273 if (profile) { |
| 275 *profile = std::move(cpuProfile); | 274 *profile = std::move(cpuProfile); |
| 276 if (!profile->get() && errorString) | 275 if (!profile->get() && errorString) |
| 277 *errorString = "Profile is not found"; | 276 *errorString = "Profile is not found"; |
| 278 } | 277 } |
| 279 m_frontendInitiatedProfileId = String16(); | 278 m_frontendInitiatedProfileId = String16(); |
| 280 m_state->setBoolean(ProfilerAgentState::userInitiatedProfiling, false); | 279 m_state->setBoolean(ProfilerAgentState::userInitiatedProfiling, false); |
| 281 m_session->client()->profilingStopped(); | |
| 282 } | 280 } |
| 283 | 281 |
| 284 String16 V8ProfilerAgentImpl::nextProfileId() | 282 String16 V8ProfilerAgentImpl::nextProfileId() |
| 285 { | 283 { |
| 286 return String16::fromInteger(atomicIncrement(&s_lastProfileId)); | 284 return String16::fromInteger(atomicIncrement(&s_lastProfileId)); |
| 287 } | 285 } |
| 288 | 286 |
| 289 void V8ProfilerAgentImpl::startProfiling(const String16& title) | 287 void V8ProfilerAgentImpl::startProfiling(const String16& title) |
| 290 { | 288 { |
| 291 v8::HandleScope handleScope(m_isolate); | 289 v8::HandleScope handleScope(m_isolate); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 313 v8::CpuProfiler* V8ProfilerAgentImpl::profiler() | 311 v8::CpuProfiler* V8ProfilerAgentImpl::profiler() |
| 314 { | 312 { |
| 315 #if ENSURE_V8_VERSION(5, 4) | 313 #if ENSURE_V8_VERSION(5, 4) |
| 316 return m_profiler; | 314 return m_profiler; |
| 317 #else | 315 #else |
| 318 return m_isolate->GetCpuProfiler(); | 316 return m_isolate->GetCpuProfiler(); |
| 319 #endif | 317 #endif |
| 320 } | 318 } |
| 321 | 319 |
| 322 } // namespace blink | 320 } // namespace blink |
| OLD | NEW |