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

Side by Side Diff: Source/core/inspector/PageRuntimeAgent.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
« no previous file with comments | « Source/core/inspector/PageRuntimeAgent.h ('k') | Source/core/page/Chrome.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 30 matching lines...) Expand all
41 #include "core/inspector/InspectorClient.h" 41 #include "core/inspector/InspectorClient.h"
42 #include "core/inspector/InspectorPageAgent.h" 42 #include "core/inspector/InspectorPageAgent.h"
43 #include "core/inspector/InstrumentingAgents.h" 43 #include "core/inspector/InstrumentingAgents.h"
44 #include "core/page/Page.h" 44 #include "core/page/Page.h"
45 #include "platform/weborigin/SecurityOrigin.h" 45 #include "platform/weborigin/SecurityOrigin.h"
46 46
47 namespace blink { 47 namespace blink {
48 48
49 static int s_nextDebuggerId = 1; 49 static int s_nextDebuggerId = 1;
50 50
51 PageRuntimeAgent::PageRuntimeAgent(InjectedScriptManager* injectedScriptManager, InspectorClient* client, ScriptDebugServer* scriptDebugServer, InspectorPageAge nt* pageAgent) 51 PageRuntimeAgent::PageRuntimeAgent(InjectedScriptManager* injectedScriptManager, InspectorClient* client, ScriptDebugServer* scriptDebugServer, Page* page, Insp ectorPageAgent* pageAgent)
52 : InspectorRuntimeAgent(injectedScriptManager, scriptDebugServer) 52 : InspectorRuntimeAgent(injectedScriptManager, scriptDebugServer)
53 , m_client(client) 53 , m_client(client)
54 , m_inspectedPage(page)
54 , m_pageAgent(pageAgent) 55 , m_pageAgent(pageAgent)
55 , m_mainWorldContextCreated(false) 56 , m_mainWorldContextCreated(false)
56 , m_debuggerId(s_nextDebuggerId++) 57 , m_debuggerId(s_nextDebuggerId++)
57 { 58 {
58 } 59 }
59 60
60 PageRuntimeAgent::~PageRuntimeAgent() 61 PageRuntimeAgent::~PageRuntimeAgent()
61 { 62 {
62 #if !ENABLE(OILPAN) 63 #if !ENABLE(OILPAN)
63 m_instrumentingAgents->setPageRuntimeAgent(0); 64 m_instrumentingAgents->setPageRuntimeAgent(0);
64 #endif 65 #endif
65 } 66 }
66 67
67 void PageRuntimeAgent::trace(Visitor* visitor) 68 void PageRuntimeAgent::trace(Visitor* visitor)
68 { 69 {
70 visitor->trace(m_inspectedPage);
69 visitor->trace(m_pageAgent); 71 visitor->trace(m_pageAgent);
70 InspectorRuntimeAgent::trace(visitor); 72 InspectorRuntimeAgent::trace(visitor);
71 } 73 }
72 74
73 void PageRuntimeAgent::init() 75 void PageRuntimeAgent::init()
74 { 76 {
75 m_instrumentingAgents->setPageRuntimeAgent(this); 77 m_instrumentingAgents->setPageRuntimeAgent(this);
76 } 78 }
77 79
78 void PageRuntimeAgent::enable(ErrorString* errorString) 80 void PageRuntimeAgent::enable(ErrorString* errorString)
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 if (it == m_scriptStateToId.end()) 130 if (it == m_scriptStateToId.end())
129 return; 131 return;
130 int id = it->value; 132 int id = it->value;
131 m_scriptStateToId.remove(scriptState); 133 m_scriptStateToId.remove(scriptState);
132 m_frontend->executionContextDestroyed(id); 134 m_frontend->executionContextDestroyed(id);
133 } 135 }
134 136
135 InjectedScript PageRuntimeAgent::injectedScriptForEval(ErrorString* errorString, const int* executionContextId) 137 InjectedScript PageRuntimeAgent::injectedScriptForEval(ErrorString* errorString, const int* executionContextId)
136 { 138 {
137 if (!executionContextId) { 139 if (!executionContextId) {
138 ScriptState* scriptState = ScriptState::forMainWorld(m_pageAgent->inspec tedFrame()); 140 ScriptState* scriptState = ScriptState::forMainWorld(m_inspectedPage->de precatedLocalMainFrame());
139 InjectedScript result = injectedScriptManager()->injectedScriptFor(scrip tState); 141 InjectedScript result = injectedScriptManager()->injectedScriptFor(scrip tState);
140 if (result.isEmpty()) 142 if (result.isEmpty())
141 *errorString = "Internal error: main world execution context not fou nd."; 143 *errorString = "Internal error: main world execution context not fou nd.";
142 return result; 144 return result;
143 } 145 }
144 InjectedScript injectedScript = injectedScriptManager()->injectedScriptForId (*executionContextId); 146 InjectedScript injectedScript = injectedScriptManager()->injectedScriptForId (*executionContextId);
145 if (injectedScript.isEmpty()) 147 if (injectedScript.isEmpty())
146 *errorString = "Execution context with given id not found."; 148 *errorString = "Execution context with given id not found.";
147 return injectedScript; 149 return injectedScript;
148 } 150 }
149 151
150 void PageRuntimeAgent::muteConsole() 152 void PageRuntimeAgent::muteConsole()
151 { 153 {
152 FrameConsole::mute(); 154 FrameConsole::mute();
153 } 155 }
154 156
155 void PageRuntimeAgent::unmuteConsole() 157 void PageRuntimeAgent::unmuteConsole()
156 { 158 {
157 FrameConsole::unmute(); 159 FrameConsole::unmute();
158 } 160 }
159 161
160 void PageRuntimeAgent::reportExecutionContextCreation() 162 void PageRuntimeAgent::reportExecutionContextCreation()
161 { 163 {
162 Vector<std::pair<ScriptState*, SecurityOrigin*> > isolatedContexts; 164 Vector<std::pair<ScriptState*, SecurityOrigin*> > isolatedContexts;
163 for (Frame* frame = m_pageAgent->inspectedFrame(); frame; frame = frame->tre e().traverseNext(m_pageAgent->inspectedFrame())) { 165 for (Frame* frame = m_inspectedPage->mainFrame(); frame; frame = frame->tree ().traverseNext()) {
164 if (!frame->isLocalFrame()) 166 if (!frame->isLocalFrame())
165 continue; 167 continue;
166 LocalFrame* localFrame = toLocalFrame(frame); 168 LocalFrame* localFrame = toLocalFrame(frame);
167 if (!localFrame->script().canExecuteScripts(NotAboutToExecuteScript)) 169 if (!localFrame->script().canExecuteScripts(NotAboutToExecuteScript))
168 continue; 170 continue;
169 String frameId = m_pageAgent->frameId(localFrame); 171 String frameId = m_pageAgent->frameId(localFrame);
170 172
171 // Ensure execution context is created. 173 // Ensure execution context is created.
172 // If initializeMainWorld returns true, then is registered by didCreateS criptContext 174 // If initializeMainWorld returns true, then is registered by didCreateS criptContext
173 if (!localFrame->script().initializeMainWorld()) 175 if (!localFrame->script().initializeMainWorld())
174 addExecutionContextToFrontend(ScriptState::forMainWorld(localFrame), true, "", frameId); 176 addExecutionContextToFrontend(ScriptState::forMainWorld(localFrame), true, "", frameId);
175 localFrame->script().collectIsolatedContexts(isolatedContexts); 177 localFrame->script().collectIsolatedContexts(isolatedContexts);
176 if (isolatedContexts.isEmpty()) 178 if (isolatedContexts.isEmpty())
177 continue; 179 continue;
178 for (const auto& pair : isolatedContexts) { 180 for (const auto& pair : isolatedContexts) {
179 String originString = pair.second ? pair.second->toRawString() : ""; 181 String originString = pair.second ? pair.second->toRawString() : "";
180 addExecutionContextToFrontend(pair.first, false, originString, frame Id); 182 addExecutionContextToFrontend(pair.first, false, originString, frame Id);
181 } 183 }
182 isolatedContexts.clear(); 184 isolatedContexts.clear();
183 } 185 }
184 } 186 }
185 187
186 } // namespace blink 188 } // namespace blink
187 189
OLDNEW
« no previous file with comments | « Source/core/inspector/PageRuntimeAgent.h ('k') | Source/core/page/Chrome.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698