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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 std::unique_ptr<protocol::Debugger::Location> location = currentDebugLocatio
n(m_session->debugger()); | 178 std::unique_ptr<protocol::Debugger::Location> location = currentDebugLocatio
n(m_session->debugger()); |
179 m_frontend.consoleProfileFinished(id, std::move(location), std::move(profile
), resolvedTitle); | 179 m_frontend.consoleProfileFinished(id, std::move(location), std::move(profile
), resolvedTitle); |
180 } | 180 } |
181 | 181 |
182 void V8ProfilerAgentImpl::enable(ErrorString*) | 182 void V8ProfilerAgentImpl::enable(ErrorString*) |
183 { | 183 { |
184 if (m_enabled) | 184 if (m_enabled) |
185 return; | 185 return; |
186 m_enabled = true; | 186 m_enabled = true; |
187 m_state->setBoolean(ProfilerAgentState::profilerEnabled, true); | 187 m_state->setBoolean(ProfilerAgentState::profilerEnabled, true); |
188 m_session->changeInstrumentationCounter(+1); | |
189 } | 188 } |
190 | 189 |
191 void V8ProfilerAgentImpl::disable(ErrorString* errorString) | 190 void V8ProfilerAgentImpl::disable(ErrorString* errorString) |
192 { | 191 { |
193 if (!m_enabled) | 192 if (!m_enabled) |
194 return; | 193 return; |
195 m_session->changeInstrumentationCounter(-1); | |
196 for (size_t i = m_startedProfiles.size(); i > 0; --i) | 194 for (size_t i = m_startedProfiles.size(); i > 0; --i) |
197 stopProfiling(m_startedProfiles[i - 1].m_id, false); | 195 stopProfiling(m_startedProfiles[i - 1].m_id, false); |
198 m_startedProfiles.clear(); | 196 m_startedProfiles.clear(); |
199 stop(nullptr, nullptr); | 197 stop(nullptr, nullptr); |
200 m_enabled = false; | 198 m_enabled = false; |
201 m_state->setBoolean(ProfilerAgentState::profilerEnabled, false); | 199 m_state->setBoolean(ProfilerAgentState::profilerEnabled, false); |
202 } | 200 } |
203 | 201 |
204 void V8ProfilerAgentImpl::setSamplingInterval(ErrorString* error, int interval) | 202 void V8ProfilerAgentImpl::setSamplingInterval(ErrorString* error, int interval) |
205 { | 203 { |
206 if (m_recordingCPUProfile) { | 204 if (m_recordingCPUProfile) { |
207 *error = "Cannot change sampling interval when profiling."; | 205 *error = "Cannot change sampling interval when profiling."; |
208 return; | 206 return; |
209 } | 207 } |
210 m_state->setNumber(ProfilerAgentState::samplingInterval, interval); | 208 m_state->setNumber(ProfilerAgentState::samplingInterval, interval); |
211 m_isolate->GetCpuProfiler()->SetSamplingInterval(interval); | 209 m_isolate->GetCpuProfiler()->SetSamplingInterval(interval); |
212 } | 210 } |
213 | 211 |
214 void V8ProfilerAgentImpl::restore() | 212 void V8ProfilerAgentImpl::restore() |
215 { | 213 { |
216 DCHECK(!m_enabled); | 214 DCHECK(!m_enabled); |
217 if (!m_state->booleanProperty(ProfilerAgentState::profilerEnabled, false)) | 215 if (!m_state->booleanProperty(ProfilerAgentState::profilerEnabled, false)) |
218 return; | 216 return; |
219 m_enabled = true; | 217 m_enabled = true; |
220 m_session->changeInstrumentationCounter(+1); | |
221 int interval = 0; | 218 int interval = 0; |
222 m_state->getNumber(ProfilerAgentState::samplingInterval, &interval); | 219 m_state->getNumber(ProfilerAgentState::samplingInterval, &interval); |
223 if (interval) | 220 if (interval) |
224 m_isolate->GetCpuProfiler()->SetSamplingInterval(interval); | 221 m_isolate->GetCpuProfiler()->SetSamplingInterval(interval); |
225 if (m_state->booleanProperty(ProfilerAgentState::userInitiatedProfiling, fal
se)) { | 222 if (m_state->booleanProperty(ProfilerAgentState::userInitiatedProfiling, fal
se)) { |
226 ErrorString error; | 223 ErrorString error; |
227 start(&error); | 224 start(&error); |
228 } | 225 } |
229 } | 226 } |
230 | 227 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 profile->Delete(); | 282 profile->Delete(); |
286 return result; | 283 return result; |
287 } | 284 } |
288 | 285 |
289 bool V8ProfilerAgentImpl::isRecording() const | 286 bool V8ProfilerAgentImpl::isRecording() const |
290 { | 287 { |
291 return m_recordingCPUProfile || !m_startedProfiles.empty(); | 288 return m_recordingCPUProfile || !m_startedProfiles.empty(); |
292 } | 289 } |
293 | 290 |
294 } // namespace blink | 291 } // namespace blink |
OLD | NEW |