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

Side by Side Diff: third_party/WebKit/Source/core/inspector/PageRuntimeAgent.cpp

Issue 1761663003: Revert of [DevTools] Postpone more agents instantiation until attached. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: manual Created 4 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "platform/v8_inspector/public/V8RuntimeAgent.h" 42 #include "platform/v8_inspector/public/V8RuntimeAgent.h"
43 #include "platform/weborigin/SecurityOrigin.h" 43 #include "platform/weborigin/SecurityOrigin.h"
44 44
45 using blink::protocol::Runtime::ExceptionDetails; 45 using blink::protocol::Runtime::ExceptionDetails;
46 46
47 namespace blink { 47 namespace blink {
48 48
49 PageRuntimeAgent::PageRuntimeAgent(Client* client, V8Debugger* debugger, Inspect edFrames* inspectedFrames) 49 PageRuntimeAgent::PageRuntimeAgent(Client* client, V8Debugger* debugger, Inspect edFrames* inspectedFrames)
50 : InspectorRuntimeAgent(debugger, client) 50 : InspectorRuntimeAgent(debugger, client)
51 , m_inspectedFrames(inspectedFrames) 51 , m_inspectedFrames(inspectedFrames)
52 , m_mainWorldContextCreated(false)
52 { 53 {
53 } 54 }
54 55
55 PageRuntimeAgent::~PageRuntimeAgent() 56 PageRuntimeAgent::~PageRuntimeAgent()
56 { 57 {
57 #if !ENABLE(OILPAN) 58 #if !ENABLE(OILPAN)
58 m_instrumentingAgents->setPageRuntimeAgent(0); 59 m_instrumentingAgents->setPageRuntimeAgent(0);
59 #endif 60 #endif
60 } 61 }
61 62
62 DEFINE_TRACE(PageRuntimeAgent) 63 DEFINE_TRACE(PageRuntimeAgent)
63 { 64 {
64 visitor->trace(m_inspectedFrames); 65 visitor->trace(m_inspectedFrames);
65 InspectorRuntimeAgent::trace(visitor); 66 InspectorRuntimeAgent::trace(visitor);
66 } 67 }
67 68
69 void PageRuntimeAgent::init()
70 {
71 InspectorRuntimeAgent::init();
72 m_instrumentingAgents->setPageRuntimeAgent(this);
73 }
74
68 void PageRuntimeAgent::enable(ErrorString* errorString) 75 void PageRuntimeAgent::enable(ErrorString* errorString)
69 { 76 {
70 if (m_enabled) 77 if (m_enabled)
71 return; 78 return;
72 79
73 InspectorRuntimeAgent::enable(errorString); 80 InspectorRuntimeAgent::enable(errorString);
74 m_instrumentingAgents->setPageRuntimeAgent(this);
75 } 81 }
76 82
77 void PageRuntimeAgent::disable(ErrorString* errorString) 83 void PageRuntimeAgent::disable(ErrorString* errorString)
78 { 84 {
79 if (!m_enabled) 85 if (!m_enabled)
80 return; 86 return;
81 m_instrumentingAgents->setPageRuntimeAgent(nullptr);
82 InspectorRuntimeAgent::disable(errorString); 87 InspectorRuntimeAgent::disable(errorString);
83 } 88 }
84 89
85 void PageRuntimeAgent::didClearDocumentOfWindowObject(LocalFrame* frame) 90 void PageRuntimeAgent::didClearDocumentOfWindowObject(LocalFrame* frame)
86 { 91 {
92 m_mainWorldContextCreated = true;
93
94 if (!m_enabled)
95 return;
87 ASSERT(frontend()); 96 ASSERT(frontend());
97
88 if (frame == m_inspectedFrames->root()) 98 if (frame == m_inspectedFrames->root())
89 m_v8RuntimeAgent->clearInspectedObjects(); 99 m_v8RuntimeAgent->clearInspectedObjects();
90 frame->script().initializeMainWorld(); 100 frame->script().initializeMainWorld();
91 } 101 }
92 102
93 void PageRuntimeAgent::didCreateScriptContext(LocalFrame* frame, ScriptState* sc riptState, SecurityOrigin* origin, int worldId) 103 void PageRuntimeAgent::didCreateScriptContext(LocalFrame* frame, ScriptState* sc riptState, SecurityOrigin* origin, int worldId)
94 { 104 {
105 if (!m_enabled)
106 return;
95 ASSERT(frontend()); 107 ASSERT(frontend());
96 bool isMainWorld = worldId == MainWorldId; 108 bool isMainWorld = worldId == MainWorldId;
97 String originString = origin ? origin->toRawString() : ""; 109 String originString = origin ? origin->toRawString() : "";
98 String frameId = IdentifiersFactory::frameId(frame); 110 String frameId = IdentifiersFactory::frameId(frame);
99 reportExecutionContext(scriptState, isMainWorld, originString, frameId); 111 reportExecutionContext(scriptState, isMainWorld, originString, frameId);
100 } 112 }
101 113
102 void PageRuntimeAgent::willReleaseScriptContext(LocalFrame* frame, ScriptState* scriptState) 114 void PageRuntimeAgent::willReleaseScriptContext(LocalFrame* frame, ScriptState* scriptState)
103 { 115 {
104 reportExecutionContextDestroyed(scriptState); 116 reportExecutionContextDestroyed(scriptState);
(...skipping 14 matching lines...) Expand all
119 void PageRuntimeAgent::unmuteConsole() 131 void PageRuntimeAgent::unmuteConsole()
120 { 132 {
121 FrameConsole::unmute(); 133 FrameConsole::unmute();
122 } 134 }
123 135
124 void PageRuntimeAgent::reportExecutionContexts() 136 void PageRuntimeAgent::reportExecutionContexts()
125 { 137 {
126 // Only report existing contexts if the page did commit load, otherwise we m ay 138 // Only report existing contexts if the page did commit load, otherwise we m ay
127 // unintentionally initialize contexts in the frames which may trigger some listeners 139 // unintentionally initialize contexts in the frames which may trigger some listeners
128 // that are expected to be triggered only after the load is committed, see h ttp://crbug.com/131623 140 // that are expected to be triggered only after the load is committed, see h ttp://crbug.com/131623
129 if (!m_client->didCommitLoadFired()) 141 if (!m_mainWorldContextCreated)
130 return; 142 return;
131 143
132 Vector<std::pair<ScriptState*, SecurityOrigin*>> isolatedContexts; 144 Vector<std::pair<ScriptState*, SecurityOrigin*>> isolatedContexts;
133 for (LocalFrame* frame : *m_inspectedFrames) { 145 for (LocalFrame* frame : *m_inspectedFrames) {
134 if (!frame->script().canExecuteScripts(NotAboutToExecuteScript)) 146 if (!frame->script().canExecuteScripts(NotAboutToExecuteScript))
135 continue; 147 continue;
136 String frameId = IdentifiersFactory::frameId(frame); 148 String frameId = IdentifiersFactory::frameId(frame);
137 149
138 // Ensure execution context is created. 150 // Ensure execution context is created.
139 // If initializeMainWorld returns true, then is registered by didCreateS criptContext 151 // If initializeMainWorld returns true, then is registered by didCreateS criptContext
(...skipping 14 matching lines...) Expand all
154 166
155 void PageRuntimeAgent::reportExecutionContext(ScriptState* scriptState, bool isP ageContext, const String& origin, const String& frameId) 167 void PageRuntimeAgent::reportExecutionContext(ScriptState* scriptState, bool isP ageContext, const String& origin, const String& frameId)
156 { 168 {
157 DOMWrapperWorld& world = scriptState->world(); 169 DOMWrapperWorld& world = scriptState->world();
158 String humanReadableName = world.isIsolatedWorld() ? world.isolatedWorldHuma nReadableName() : ""; 170 String humanReadableName = world.isIsolatedWorld() ? world.isolatedWorldHuma nReadableName() : "";
159 String type = isPageContext ? "" : "Extension"; 171 String type = isPageContext ? "" : "Extension";
160 InspectorRuntimeAgent::reportExecutionContextCreated(scriptState, type, orig in, humanReadableName, frameId); 172 InspectorRuntimeAgent::reportExecutionContextCreated(scriptState, type, orig in, humanReadableName, frameId);
161 } 173 }
162 174
163 } // namespace blink 175 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698