Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(893)

Side by Side Diff: Source/core/inspector/InspectorTimelineAgent.cpp

Issue 892693006: Revert of DevTools: use per-LocalFrame instrumenting agents instead of per-Page ones. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 { 349 {
350 m_state->setBoolean(TimelineAgentState::enabled, false); 350 m_state->setBoolean(TimelineAgentState::enabled, false);
351 } 351 }
352 352
353 void InspectorTimelineAgent::start(ErrorString* errorString, const int* maxCallS tackDepth, const bool* bufferEvents, const String* liveEvents, const bool* inclu deCounters, const bool* includeGPUEvents) 353 void InspectorTimelineAgent::start(ErrorString* errorString, const int* maxCallS tackDepth, const bool* bufferEvents, const String* liveEvents, const bool* inclu deCounters, const bool* includeGPUEvents)
354 { 354 {
355 if (!m_frontend) 355 if (!m_frontend)
356 return; 356 return;
357 m_state->setBoolean(TimelineAgentState::startedFromProtocol, true); 357 m_state->setBoolean(TimelineAgentState::startedFromProtocol, true);
358 358
359 if (LocalFrame* frame = inspectedFrame()) { 359 if (LocalFrame* frame = mainFrame()) {
360 if (UseCounter* useCounter = UseCounter::getFrom(frame->document())) 360 if (UseCounter* useCounter = UseCounter::getFrom(frame->document()))
361 useCounter->count(UseCounter::TimelineStart); 361 useCounter->count(UseCounter::TimelineStart);
362 } 362 }
363 363
364 if (isStarted()) { 364 if (isStarted()) {
365 *errorString = "Timeline is already started"; 365 *errorString = "Timeline is already started";
366 return; 366 return;
367 } 367 }
368 368
369 if (maxCallStackDepth && *maxCallStackDepth >= 0) 369 if (maxCallStackDepth && *maxCallStackDepth >= 0)
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 m_threadStates.clear(); 457 m_threadStates.clear();
458 m_gpuTask.clear(); 458 m_gpuTask.clear();
459 m_layerToNodeMap.clear(); 459 m_layerToNodeMap.clear();
460 m_pixelRefToImageInfo.clear(); 460 m_pixelRefToImageInfo.clear();
461 m_imageBeingPainted = 0; 461 m_imageBeingPainted = 0;
462 m_paintSetupStart = 0; 462 m_paintSetupStart = 0;
463 m_mayEmitFirstPaint = false; 463 m_mayEmitFirstPaint = false;
464 464
465 for (size_t i = 0; i < m_consoleTimelines.size(); ++i) { 465 for (size_t i = 0; i < m_consoleTimelines.size(); ++i) {
466 String message = String::format("Timeline '%s' terminated.", m_consoleTi melines[i].utf8().data()); 466 String message = String::format("Timeline '%s' terminated.", m_consoleTi melines[i].utf8().data());
467 inspectedFrame()->console().addMessage(ConsoleMessage::create(JSMessageS ource, DebugMessageLevel, message)); 467 mainFrame()->console().addMessage(ConsoleMessage::create(JSMessageSource , DebugMessageLevel, message));
468 } 468 }
469 m_consoleTimelines.clear(); 469 m_consoleTimelines.clear();
470 470
471 m_frontend->stopped(&fromConsole, m_bufferedEvents.release()); 471 m_frontend->stopped(&fromConsole, m_bufferedEvents.release());
472 if (m_overlay) 472 if (m_overlay)
473 m_overlay->finishedRecordingProfile(); 473 m_overlay->finishedRecordingProfile();
474 } 474 }
475 475
476 void InspectorTimelineAgent::didBeginFrame(int frameId) 476 void InspectorTimelineAgent::didBeginFrame(int frameId)
477 { 477 {
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 823
824 void InspectorTimelineAgent::consoleTimeline(ExecutionContext* context, const St ring& title, ScriptState* scriptState) 824 void InspectorTimelineAgent::consoleTimeline(ExecutionContext* context, const St ring& title, ScriptState* scriptState)
825 { 825 {
826 if (!m_state->getBoolean(TimelineAgentState::enabled)) 826 if (!m_state->getBoolean(TimelineAgentState::enabled))
827 return; 827 return;
828 828
829 String message = String::format("Timeline '%s' started.", title.utf8().data( )); 829 String message = String::format("Timeline '%s' started.", title.utf8().data( ));
830 830
831 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(J SMessageSource, DebugMessageLevel, message); 831 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(J SMessageSource, DebugMessageLevel, message);
832 consoleMessage->setScriptState(scriptState); 832 consoleMessage->setScriptState(scriptState);
833 inspectedFrame()->console().addMessage(consoleMessage.release()); 833 mainFrame()->console().addMessage(consoleMessage.release());
834 m_consoleTimelines.append(title); 834 m_consoleTimelines.append(title);
835 if (!isStarted()) { 835 if (!isStarted()) {
836 m_state->setBoolean(TimelineAgentState::bufferEvents, true); 836 m_state->setBoolean(TimelineAgentState::bufferEvents, true);
837 m_bufferedEvents = TypeBuilder::Array<TimelineEvent>::create(); 837 m_bufferedEvents = TypeBuilder::Array<TimelineEvent>::create();
838 838
839 innerStart(); 839 innerStart();
840 bool fromConsole = true; 840 bool fromConsole = true;
841 m_frontend->started(&fromConsole); 841 m_frontend->started(&fromConsole);
842 } 842 }
843 appendRecord(TimelineRecordFactory::createTimeStampData(message), TimelineRe cordType::TimeStamp, true, frameForExecutionContext(context)); 843 appendRecord(TimelineRecordFactory::createTimeStampData(message), TimelineRe cordType::TimeStamp, true, frameForExecutionContext(context));
844 } 844 }
845 845
846 void InspectorTimelineAgent::consoleTimelineEnd(ExecutionContext* context, const String& title, ScriptState* scriptState) 846 void InspectorTimelineAgent::consoleTimelineEnd(ExecutionContext* context, const String& title, ScriptState* scriptState)
847 { 847 {
848 if (!m_state->getBoolean(TimelineAgentState::enabled)) 848 if (!m_state->getBoolean(TimelineAgentState::enabled))
849 return; 849 return;
850 850
851 size_t index = m_consoleTimelines.find(title); 851 size_t index = m_consoleTimelines.find(title);
852 if (index == kNotFound) { 852 if (index == kNotFound) {
853 String message = String::format("Timeline '%s' was not started.", title. utf8().data()); 853 String message = String::format("Timeline '%s' was not started.", title. utf8().data());
854 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::crea te(JSMessageSource, DebugMessageLevel, message); 854 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::crea te(JSMessageSource, DebugMessageLevel, message);
855 consoleMessage->setScriptState(scriptState); 855 consoleMessage->setScriptState(scriptState);
856 inspectedFrame()->console().addMessage(consoleMessage.release()); 856 mainFrame()->console().addMessage(consoleMessage.release());
857 return; 857 return;
858 } 858 }
859 859
860 String message = String::format("Timeline '%s' finished.", title.utf8().data ()); 860 String message = String::format("Timeline '%s' finished.", title.utf8().data ());
861 appendRecord(TimelineRecordFactory::createTimeStampData(message), TimelineRe cordType::TimeStamp, true, frameForExecutionContext(context)); 861 appendRecord(TimelineRecordFactory::createTimeStampData(message), TimelineRe cordType::TimeStamp, true, frameForExecutionContext(context));
862 m_consoleTimelines.remove(index); 862 m_consoleTimelines.remove(index);
863 if (!m_consoleTimelines.size() && isStarted() && !m_state->getBoolean(Timeli neAgentState::startedFromProtocol)) { 863 if (!m_consoleTimelines.size() && isStarted() && !m_state->getBoolean(Timeli neAgentState::startedFromProtocol)) {
864 unwindRecordStack(); 864 unwindRecordStack();
865 innerStop(true); 865 innerStop(true);
866 } 866 }
867 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(J SMessageSource, DebugMessageLevel, message); 867 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(J SMessageSource, DebugMessageLevel, message);
868 consoleMessage->setScriptState(scriptState); 868 consoleMessage->setScriptState(scriptState);
869 inspectedFrame()->console().addMessage(consoleMessage.release()); 869 mainFrame()->console().addMessage(consoleMessage.release());
870 } 870 }
871 871
872 void InspectorTimelineAgent::domContentLoadedEventFired(LocalFrame* frame) 872 void InspectorTimelineAgent::domContentLoadedEventFired(LocalFrame* frame)
873 { 873 {
874 bool isMainFrame = frame && m_pageAgent && (frame == m_pageAgent->inspectedF rame()); 874 bool isMainFrame = frame && m_pageAgent && (frame == m_pageAgent->mainFrame( ));
875 appendRecord(TimelineRecordFactory::createMarkData(isMainFrame), TimelineRec ordType::MarkDOMContent, false, frame); 875 appendRecord(TimelineRecordFactory::createMarkData(isMainFrame), TimelineRec ordType::MarkDOMContent, false, frame);
876 if (isMainFrame) 876 if (isMainFrame)
877 m_mayEmitFirstPaint = true; 877 m_mayEmitFirstPaint = true;
878 } 878 }
879 879
880 void InspectorTimelineAgent::loadEventFired(LocalFrame* frame) 880 void InspectorTimelineAgent::loadEventFired(LocalFrame* frame)
881 { 881 {
882 bool isMainFrame = frame && m_pageAgent && (frame == m_pageAgent->inspectedF rame()); 882 bool isMainFrame = frame && m_pageAgent && (frame == m_pageAgent->mainFrame( ));
883 appendRecord(TimelineRecordFactory::createMarkData(isMainFrame), TimelineRec ordType::MarkLoad, false, frame); 883 appendRecord(TimelineRecordFactory::createMarkData(isMainFrame), TimelineRec ordType::MarkLoad, false, frame);
884 } 884 }
885 885
886 void InspectorTimelineAgent::didCommitLoad() 886 void InspectorTimelineAgent::didCommitLoad()
887 { 887 {
888 clearRecordStack(); 888 clearRecordStack();
889 } 889 }
890 890
891 void InspectorTimelineAgent::didRequestAnimationFrame(Document* document, int ca llbackId) 891 void InspectorTimelineAgent::didRequestAnimationFrame(Document* document, int ca llbackId)
892 { 892 {
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
1277 long long InspectorTimelineAgent::nodeId(RenderObject* renderer) 1277 long long InspectorTimelineAgent::nodeId(RenderObject* renderer)
1278 { 1278 {
1279 return InspectorNodeIds::idForNode(renderer->generatingNode()); 1279 return InspectorNodeIds::idForNode(renderer->generatingNode());
1280 } 1280 }
1281 1281
1282 double InspectorTimelineAgent::timestamp() 1282 double InspectorTimelineAgent::timestamp()
1283 { 1283 {
1284 return WTF::monotonicallyIncreasingTime() * msPerSecond; 1284 return WTF::monotonicallyIncreasingTime() * msPerSecond;
1285 } 1285 }
1286 1286
1287 LocalFrame* InspectorTimelineAgent::inspectedFrame() const 1287 LocalFrame* InspectorTimelineAgent::mainFrame() const
1288 { 1288 {
1289 if (!m_pageAgent) 1289 if (!m_pageAgent)
1290 return nullptr; 1290 return nullptr;
1291 return m_pageAgent->inspectedFrame(); 1291 return m_pageAgent->mainFrame();
1292 } 1292 }
1293 1293
1294 PassRefPtr<TimelineEvent> InspectorTimelineAgent::createRecordForEvent(const Tra ceEventDispatcher::TraceEvent& event, const String& type, PassRefPtr<JSONObject> data) 1294 PassRefPtr<TimelineEvent> InspectorTimelineAgent::createRecordForEvent(const Tra ceEventDispatcher::TraceEvent& event, const String& type, PassRefPtr<JSONObject> data)
1295 { 1295 {
1296 double timeestamp = event.timestamp() * msPerSecond; 1296 double timeestamp = event.timestamp() * msPerSecond;
1297 return TimelineRecordFactory::createBackgroundRecord(timeestamp, String::num ber(event.threadIdentifier()), type, data); 1297 return TimelineRecordFactory::createBackgroundRecord(timeestamp, String::num ber(event.threadIdentifier()), type, data);
1298 } 1298 }
1299 1299
1300 void InspectorTimelineAgent::setLiveEvents(const String& liveEvents) 1300 void InspectorTimelineAgent::setLiveEvents(const String& liveEvents)
1301 { 1301 {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1349 { 1349 {
1350 visitor->trace(m_timelineAgent); 1350 visitor->trace(m_timelineAgent);
1351 } 1351 }
1352 1352
1353 void TimelineThreadState::trace(Visitor* visitor) 1353 void TimelineThreadState::trace(Visitor* visitor)
1354 { 1354 {
1355 visitor->trace(recordStack); 1355 visitor->trace(recordStack);
1356 } 1356 }
1357 1357
1358 } // namespace blink 1358 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorTimelineAgent.h ('k') | Source/core/inspector/InspectorTraceEvents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698