OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 } | 262 } |
263 | 263 |
264 void InspectorTimelineAgent::setFrontend(InspectorFrontend* frontend) | 264 void InspectorTimelineAgent::setFrontend(InspectorFrontend* frontend) |
265 { | 265 { |
266 m_frontend = frontend->timeline(); | 266 m_frontend = frontend->timeline(); |
267 } | 267 } |
268 | 268 |
269 void InspectorTimelineAgent::clearFrontend() | 269 void InspectorTimelineAgent::clearFrontend() |
270 { | 270 { |
271 ErrorString error; | 271 ErrorString error; |
272 RefPtr<TypeBuilder::Array<TimelineEvent> > events; | 272 stop(&error); |
273 stop(&error, events); | |
274 disable(&error); | 273 disable(&error); |
275 m_frontend = 0; | 274 m_frontend = 0; |
276 } | 275 } |
277 | 276 |
278 void InspectorTimelineAgent::restore() | 277 void InspectorTimelineAgent::restore() |
279 { | 278 { |
280 if (m_state->getBoolean(TimelineAgentState::startedFromProtocol)) { | 279 if (m_state->getBoolean(TimelineAgentState::startedFromProtocol)) { |
281 if (m_state->getBoolean(TimelineAgentState::bufferEvents)) | 280 if (m_state->getBoolean(TimelineAgentState::bufferEvents)) |
282 m_bufferedEvents = TypeBuilder::Array<TimelineEvent>::create(); | 281 m_bufferedEvents = TypeBuilder::Array<TimelineEvent>::create(); |
283 | 282 |
284 setLiveEvents(m_state->getString(TimelineAgentState::liveEvents)); | 283 setLiveEvents(m_state->getString(TimelineAgentState::liveEvents)); |
285 innerStart(); | 284 innerStart(); |
286 } else if (isStarted()) { | 285 } else if (isStarted()) { |
287 // Timeline was started from console.timeline, it is not restored. | 286 // Timeline was started from console.timeline, it is not restored. |
288 // Tell front-end timline is no longer collecting. | 287 // Tell front-end timline is no longer collecting. |
289 m_state->setBoolean(TimelineAgentState::started, false); | 288 m_state->setBoolean(TimelineAgentState::started, false); |
290 bool fromConsole = true; | 289 bool fromConsole = true; |
291 m_frontend->stopped(&fromConsole); | 290 m_frontend->stopped(&fromConsole, nullptr); |
292 } | 291 } |
293 } | 292 } |
294 | 293 |
295 void InspectorTimelineAgent::enable(ErrorString*) | 294 void InspectorTimelineAgent::enable(ErrorString*) |
296 { | 295 { |
297 m_state->setBoolean(TimelineAgentState::enabled, true); | 296 m_state->setBoolean(TimelineAgentState::enabled, true); |
298 } | 297 } |
299 | 298 |
300 void InspectorTimelineAgent::disable(ErrorString*) | 299 void InspectorTimelineAgent::disable(ErrorString*) |
301 { | 300 { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 dispatcher->addListener(InstrumentationEvents::EmbedderCallback, TRACE_E
VENT_PHASE_BEGIN, this, &InspectorTimelineAgent::onEmbedderCallbackBegin, m_clie
nt); | 368 dispatcher->addListener(InstrumentationEvents::EmbedderCallback, TRACE_E
VENT_PHASE_BEGIN, this, &InspectorTimelineAgent::onEmbedderCallbackBegin, m_clie
nt); |
370 dispatcher->addListener(InstrumentationEvents::EmbedderCallback, TRACE_E
VENT_PHASE_END, this, &InspectorTimelineAgent::onEmbedderCallbackEnd, m_client); | 369 dispatcher->addListener(InstrumentationEvents::EmbedderCallback, TRACE_E
VENT_PHASE_END, this, &InspectorTimelineAgent::onEmbedderCallbackEnd, m_client); |
371 | 370 |
372 if (m_state->getBoolean(TimelineAgentState::includeGPUEvents)) { | 371 if (m_state->getBoolean(TimelineAgentState::includeGPUEvents)) { |
373 m_pendingGPURecord.clear(); | 372 m_pendingGPURecord.clear(); |
374 m_client->startGPUEventsRecording(); | 373 m_client->startGPUEventsRecording(); |
375 } | 374 } |
376 } | 375 } |
377 } | 376 } |
378 | 377 |
379 void InspectorTimelineAgent::stop(ErrorString* errorString, RefPtr<TypeBuilder::
Array<TimelineEvent> >& events) | 378 void InspectorTimelineAgent::stop(ErrorString* errorString) |
380 { | 379 { |
381 m_state->setBoolean(TimelineAgentState::startedFromProtocol, false); | 380 m_state->setBoolean(TimelineAgentState::startedFromProtocol, false); |
382 m_state->setBoolean(TimelineAgentState::bufferEvents, false); | 381 m_state->setBoolean(TimelineAgentState::bufferEvents, false); |
383 m_state->setString(TimelineAgentState::liveEvents, ""); | 382 m_state->setString(TimelineAgentState::liveEvents, ""); |
384 | 383 |
385 if (!isStarted()) { | 384 if (!isStarted()) { |
386 *errorString = "Timeline was not started"; | 385 *errorString = "Timeline was not started"; |
387 return; | 386 return; |
388 } | 387 } |
389 innerStop(false); | 388 innerStop(false); |
390 if (m_bufferedEvents) | |
391 events = m_bufferedEvents.release(); | |
392 m_liveEvents.clear(); | 389 m_liveEvents.clear(); |
393 } | 390 } |
394 | 391 |
395 void InspectorTimelineAgent::innerStop(bool fromConsole) | 392 void InspectorTimelineAgent::innerStop(bool fromConsole) |
396 { | 393 { |
397 m_state->setBoolean(TimelineAgentState::started, false); | 394 m_state->setBoolean(TimelineAgentState::started, false); |
398 | 395 |
399 if (m_client) { | 396 if (m_client) { |
400 TraceEventDispatcher::instance()->removeAllListeners(this, m_client); | 397 TraceEventDispatcher::instance()->removeAllListeners(this, m_client); |
401 if (m_state->getBoolean(TimelineAgentState::includeGPUEvents)) | 398 if (m_state->getBoolean(TimelineAgentState::includeGPUEvents)) |
(...skipping 10 matching lines...) Expand all Loading... |
412 m_imageBeingPainted = 0; | 409 m_imageBeingPainted = 0; |
413 m_paintSetupStart = 0; | 410 m_paintSetupStart = 0; |
414 m_mayEmitFirstPaint = false; | 411 m_mayEmitFirstPaint = false; |
415 | 412 |
416 for (size_t i = 0; i < m_consoleTimelines.size(); ++i) { | 413 for (size_t i = 0; i < m_consoleTimelines.size(); ++i) { |
417 String message = String::format("Timeline '%s' terminated.", m_consoleTi
melines[i].utf8().data()); | 414 String message = String::format("Timeline '%s' terminated.", m_consoleTi
melines[i].utf8().data()); |
418 mainFrame()->console().addMessage(JSMessageSource, DebugMessageLevel, me
ssage); | 415 mainFrame()->console().addMessage(JSMessageSource, DebugMessageLevel, me
ssage); |
419 } | 416 } |
420 m_consoleTimelines.clear(); | 417 m_consoleTimelines.clear(); |
421 | 418 |
422 m_frontend->stopped(&fromConsole); | 419 m_frontend->stopped(&fromConsole, m_bufferedEvents.release()); |
423 if (m_overlay) | 420 if (m_overlay) |
424 m_overlay->finishedRecordingProfile(); | 421 m_overlay->finishedRecordingProfile(); |
425 } | 422 } |
426 | 423 |
427 void InspectorTimelineAgent::didBeginFrame(int frameId) | 424 void InspectorTimelineAgent::didBeginFrame(int frameId) |
428 { | 425 { |
429 TraceEventDispatcher::instance()->processBackgroundEvents(); | 426 TraceEventDispatcher::instance()->processBackgroundEvents(); |
430 m_pendingFrameRecord = TimelineRecordFactory::createGenericRecord(timestamp(
), 0, TimelineRecordType::BeginFrame, TimelineRecordFactory::createFrameData(fra
meId)); | 427 m_pendingFrameRecord = TimelineRecordFactory::createGenericRecord(timestamp(
), 0, TimelineRecordType::BeginFrame, TimelineRecordFactory::createFrameData(fra
meId)); |
431 } | 428 } |
432 | 429 |
(...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1306 | 1303 |
1307 #ifndef NDEBUG | 1304 #ifndef NDEBUG |
1308 bool TimelineRecordStack::isOpenRecordOfType(const String& type) | 1305 bool TimelineRecordStack::isOpenRecordOfType(const String& type) |
1309 { | 1306 { |
1310 return !m_stack.isEmpty() && m_stack.last().type == type; | 1307 return !m_stack.isEmpty() && m_stack.last().type == type; |
1311 } | 1308 } |
1312 #endif | 1309 #endif |
1313 | 1310 |
1314 } // namespace WebCore | 1311 } // namespace WebCore |
1315 | 1312 |
OLD | NEW |