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

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

Issue 1085033003: Introduce InspectorIdentifiers<> and use it to assign/lookup LocalFrame and DocumentLoader (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: win build error fixed Created 5 years, 8 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/InspectorStyleSheet.cpp ('k') | Source/core/loader/DocumentLoader.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 21 matching lines...) Expand all
32 #include "core/inspector/PageRuntimeAgent.h" 32 #include "core/inspector/PageRuntimeAgent.h"
33 33
34 #include "bindings/core/v8/DOMWrapperWorld.h" 34 #include "bindings/core/v8/DOMWrapperWorld.h"
35 #include "bindings/core/v8/PageScriptDebugServer.h" 35 #include "bindings/core/v8/PageScriptDebugServer.h"
36 #include "bindings/core/v8/ScriptController.h" 36 #include "bindings/core/v8/ScriptController.h"
37 #include "bindings/core/v8/ScriptState.h" 37 #include "bindings/core/v8/ScriptState.h"
38 #include "core/frame/FrameConsole.h" 38 #include "core/frame/FrameConsole.h"
39 #include "core/frame/LocalFrame.h" 39 #include "core/frame/LocalFrame.h"
40 #include "core/inspector/InjectedScript.h" 40 #include "core/inspector/InjectedScript.h"
41 #include "core/inspector/InjectedScriptManager.h" 41 #include "core/inspector/InjectedScriptManager.h"
42 #include "core/inspector/InspectorIdentifiers.h"
42 #include "core/inspector/InspectorPageAgent.h" 43 #include "core/inspector/InspectorPageAgent.h"
43 #include "core/inspector/InstrumentingAgents.h" 44 #include "core/inspector/InstrumentingAgents.h"
44 #include "core/page/Page.h" 45 #include "core/page/Page.h"
45 #include "platform/weborigin/SecurityOrigin.h" 46 #include "platform/weborigin/SecurityOrigin.h"
46 47
47 namespace blink { 48 namespace blink {
48 49
49 static int s_nextDebuggerId = 1; 50 static int s_nextDebuggerId = 1;
50 51
51 PageRuntimeAgent::PageRuntimeAgent(InjectedScriptManager* injectedScriptManager, Client* client, ScriptDebugServer* scriptDebugServer, InspectorPageAgent* pageA gent) 52 PageRuntimeAgent::PageRuntimeAgent(InjectedScriptManager* injectedScriptManager, Client* client, ScriptDebugServer* scriptDebugServer, InspectorPageAgent* pageA gent)
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 bool isMainWorld = worldId == MainWorldId; 105 bool isMainWorld = worldId == MainWorldId;
105 106
106 // Name the context for debugging. 107 // Name the context for debugging.
107 String type = isMainWorld ? "page" : "injected"; 108 String type = isMainWorld ? "page" : "injected";
108 PageScriptDebugServer::setContextDebugData(scriptState->context(), type, m_d ebuggerId); 109 PageScriptDebugServer::setContextDebugData(scriptState->context(), type, m_d ebuggerId);
109 110
110 if (!m_enabled) 111 if (!m_enabled)
111 return; 112 return;
112 ASSERT(frontend()); 113 ASSERT(frontend());
113 String originString = origin ? origin->toRawString() : ""; 114 String originString = origin ? origin->toRawString() : "";
114 String frameId = m_pageAgent->frameId(frame); 115 String frameId = InspectorIdentifiers<LocalFrame>::identifier(frame);
115 addExecutionContextToFrontend(scriptState, isMainWorld, originString, frameI d); 116 addExecutionContextToFrontend(scriptState, isMainWorld, originString, frameI d);
116 } 117 }
117 118
118 void PageRuntimeAgent::willReleaseScriptContext(LocalFrame* frame, ScriptState* scriptState) 119 void PageRuntimeAgent::willReleaseScriptContext(LocalFrame* frame, ScriptState* scriptState)
119 { 120 {
120 injectedScriptManager()->discardInjectedScriptFor(scriptState); 121 injectedScriptManager()->discardInjectedScriptFor(scriptState);
121 ScriptStateToId::iterator it = m_scriptStateToId.find(scriptState); 122 ScriptStateToId::iterator it = m_scriptStateToId.find(scriptState);
122 if (it == m_scriptStateToId.end()) 123 if (it == m_scriptStateToId.end())
123 return; 124 return;
124 int id = it->value; 125 int id = it->value;
(...skipping 28 matching lines...) Expand all
153 154
154 void PageRuntimeAgent::reportExecutionContextCreation() 155 void PageRuntimeAgent::reportExecutionContextCreation()
155 { 156 {
156 Vector<std::pair<ScriptState*, SecurityOrigin*> > isolatedContexts; 157 Vector<std::pair<ScriptState*, SecurityOrigin*> > isolatedContexts;
157 for (Frame* frame = m_pageAgent->inspectedFrame(); frame; frame = frame->tre e().traverseNext(m_pageAgent->inspectedFrame())) { 158 for (Frame* frame = m_pageAgent->inspectedFrame(); frame; frame = frame->tre e().traverseNext(m_pageAgent->inspectedFrame())) {
158 if (!frame->isLocalFrame()) 159 if (!frame->isLocalFrame())
159 continue; 160 continue;
160 LocalFrame* localFrame = toLocalFrame(frame); 161 LocalFrame* localFrame = toLocalFrame(frame);
161 if (!localFrame->script().canExecuteScripts(NotAboutToExecuteScript)) 162 if (!localFrame->script().canExecuteScripts(NotAboutToExecuteScript))
162 continue; 163 continue;
163 String frameId = m_pageAgent->frameId(localFrame); 164 String frameId = InspectorIdentifiers<LocalFrame>::identifier(localFrame );
164 165
165 // Ensure execution context is created. 166 // Ensure execution context is created.
166 // If initializeMainWorld returns true, then is registered by didCreateS criptContext 167 // If initializeMainWorld returns true, then is registered by didCreateS criptContext
167 if (!localFrame->script().initializeMainWorld()) 168 if (!localFrame->script().initializeMainWorld())
168 addExecutionContextToFrontend(ScriptState::forMainWorld(localFrame), true, "", frameId); 169 addExecutionContextToFrontend(ScriptState::forMainWorld(localFrame), true, "", frameId);
169 localFrame->script().collectIsolatedContexts(isolatedContexts); 170 localFrame->script().collectIsolatedContexts(isolatedContexts);
170 if (isolatedContexts.isEmpty()) 171 if (isolatedContexts.isEmpty())
171 continue; 172 continue;
172 for (const auto& pair : isolatedContexts) { 173 for (const auto& pair : isolatedContexts) {
173 String originString = pair.second ? pair.second->toRawString() : ""; 174 String originString = pair.second ? pair.second->toRawString() : "";
174 addExecutionContextToFrontend(pair.first, false, originString, frame Id); 175 addExecutionContextToFrontend(pair.first, false, originString, frame Id);
175 } 176 }
176 isolatedContexts.clear(); 177 isolatedContexts.clear();
177 } 178 }
178 } 179 }
179 180
180 } // namespace blink 181 } // namespace blink
181 182
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorStyleSheet.cpp ('k') | Source/core/loader/DocumentLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698