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

Side by Side Diff: Source/core/inspector/InspectorCanvasAgent.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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 if (frame.value) { 134 if (frame.value) {
135 *result = true; 135 *result = true;
136 return; 136 return;
137 } 137 }
138 } 138 }
139 *result = false; 139 *result = false;
140 } 140 }
141 141
142 void InspectorCanvasAgent::captureFrame(ErrorString* errorString, const FrameId* frameId, TraceLogId* traceLogId) 142 void InspectorCanvasAgent::captureFrame(ErrorString* errorString, const FrameId* frameId, TraceLogId* traceLogId)
143 { 143 {
144 LocalFrame* frame = frameId ? m_pageAgent->assertFrame(errorString, *frameId ) : m_pageAgent->inspectedFrame(); 144 LocalFrame* frame = frameId ? m_pageAgent->assertFrame(errorString, *frameId ) : m_pageAgent->mainFrame();
145 if (!frame) 145 if (!frame)
146 return; 146 return;
147 InjectedScriptCanvasModule module = injectedScriptCanvasModule(errorString, ScriptState::forMainWorld(frame)); 147 InjectedScriptCanvasModule module = injectedScriptCanvasModule(errorString, ScriptState::forMainWorld(frame));
148 if (!module.isEmpty()) 148 if (!module.isEmpty())
149 module.captureFrame(errorString, traceLogId); 149 module.captureFrame(errorString, traceLogId);
150 } 150 }
151 151
152 void InspectorCanvasAgent::startCapturing(ErrorString* errorString, const FrameI d* frameId, TraceLogId* traceLogId) 152 void InspectorCanvasAgent::startCapturing(ErrorString* errorString, const FrameI d* frameId, TraceLogId* traceLogId)
153 { 153 {
154 LocalFrame* frame = frameId ? m_pageAgent->assertFrame(errorString, *frameId ) : m_pageAgent->inspectedFrame(); 154 LocalFrame* frame = frameId ? m_pageAgent->assertFrame(errorString, *frameId ) : m_pageAgent->mainFrame();
155 if (!frame) 155 if (!frame)
156 return; 156 return;
157 InjectedScriptCanvasModule module = injectedScriptCanvasModule(errorString, ScriptState::forMainWorld(frame)); 157 InjectedScriptCanvasModule module = injectedScriptCanvasModule(errorString, ScriptState::forMainWorld(frame));
158 if (!module.isEmpty()) 158 if (!module.isEmpty())
159 module.startCapturing(errorString, traceLogId); 159 module.startCapturing(errorString, traceLogId);
160 } 160 }
161 161
162 void InspectorCanvasAgent::stopCapturing(ErrorString* errorString, const TraceLo gId& traceLogId) 162 void InspectorCanvasAgent::stopCapturing(ErrorString* errorString, const TraceLo gId& traceLogId)
163 { 163 {
164 InjectedScriptCanvasModule module = injectedScriptCanvasModule(errorString, traceLogId); 164 InjectedScriptCanvasModule module = injectedScriptCanvasModule(errorString, traceLogId);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 *errorString = "Inspected frame has gone"; 261 *errorString = "Inspected frame has gone";
262 return InjectedScriptCanvasModule(); 262 return InjectedScriptCanvasModule();
263 } 263 }
264 return injectedScriptCanvasModule(errorString, injectedScript.scriptState()) ; 264 return injectedScriptCanvasModule(errorString, injectedScript.scriptState()) ;
265 } 265 }
266 266
267 void InspectorCanvasAgent::findFramesWithUninstrumentedCanvases() 267 void InspectorCanvasAgent::findFramesWithUninstrumentedCanvases()
268 { 268 {
269 class NodeVisitor final : public WrappedNodeVisitor { 269 class NodeVisitor final : public WrappedNodeVisitor {
270 public: 270 public:
271 NodeVisitor(LocalFrame* frame, FramesWithUninstrumentedCanvases& result) 271 NodeVisitor(Page* page, FramesWithUninstrumentedCanvases& result)
272 : m_frame(frame) 272 : m_page(page)
273 , m_framesWithUninstrumentedCanvases(result) 273 , m_framesWithUninstrumentedCanvases(result)
274 { 274 {
275 } 275 }
276 276
277 virtual void visitNode(Node* node) override 277 virtual void visitNode(Node* node) override
278 { 278 {
279 ASSERT(node); 279 ASSERT(node);
280 if (!isHTMLCanvasElement(*node) || !node->document().frame()) 280 if (!isHTMLCanvasElement(*node) || !node->document().frame())
281 return; 281 return;
282 282
283 LocalFrame* frame = node->document().frame(); 283 LocalFrame* frame = node->document().frame();
284 if (frame->localFrameRoot() != m_frame) 284 if (frame->page() != m_page)
285 return; 285 return;
286 286
287 if (toHTMLCanvasElement(node)->renderingContext()) 287 if (toHTMLCanvasElement(node)->renderingContext())
288 m_framesWithUninstrumentedCanvases.set(frame, true); 288 m_framesWithUninstrumentedCanvases.set(frame, true);
289 } 289 }
290 290
291 private: 291 private:
292 LocalFrame* m_frame; 292 Page* m_page;
293 FramesWithUninstrumentedCanvases& m_framesWithUninstrumentedCanvases; 293 FramesWithUninstrumentedCanvases& m_framesWithUninstrumentedCanvases;
294 } nodeVisitor(m_pageAgent->inspectedFrame(), m_framesWithUninstrumentedCanva ses); 294 } nodeVisitor(m_pageAgent->page(), m_framesWithUninstrumentedCanvases);
295 295
296 m_framesWithUninstrumentedCanvases.clear(); 296 m_framesWithUninstrumentedCanvases.clear();
297 ScriptProfiler::visitNodeWrappers(&nodeVisitor); 297 ScriptProfiler::visitNodeWrappers(&nodeVisitor);
298 298
299 if (m_frontend) { 299 if (m_frontend) {
300 for (const auto& frame : m_framesWithUninstrumentedCanvases) { 300 for (const auto& frame : m_framesWithUninstrumentedCanvases) {
301 String frameId = m_pageAgent->frameId(frame.key); 301 String frameId = m_pageAgent->frameId(frame.key);
302 if (!frameId.isEmpty()) 302 if (!frameId.isEmpty())
303 m_frontend->contextCreated(frameId); 303 m_frontend->contextCreated(frameId);
304 } 304 }
305 } 305 }
306 } 306 }
307 307
308 bool InspectorCanvasAgent::checkIsEnabled(ErrorString* errorString) const 308 bool InspectorCanvasAgent::checkIsEnabled(ErrorString* errorString) const
309 { 309 {
310 if (m_enabled) 310 if (m_enabled)
311 return true; 311 return true;
312 *errorString = "Canvas agent is not enabled"; 312 *errorString = "Canvas agent is not enabled";
313 return false; 313 return false;
314 } 314 }
315 315
316 void InspectorCanvasAgent::didCommitLoad(LocalFrame*, DocumentLoader* loader) 316 void InspectorCanvasAgent::didCommitLoad(LocalFrame*, DocumentLoader* loader)
317 { 317 {
318 if (!m_enabled) 318 if (!m_enabled)
319 return; 319 return;
320 Frame* frame = loader->frame(); 320 Frame* frame = loader->frame();
321 if (frame == m_pageAgent->inspectedFrame()) { 321 if (frame == m_pageAgent->mainFrame()) {
322 for (auto& frame : m_framesWithUninstrumentedCanvases) 322 for (auto& frame : m_framesWithUninstrumentedCanvases)
323 frame.value = false; 323 frame.value = false;
324 m_frontend->traceLogsRemoved(0, 0); 324 m_frontend->traceLogsRemoved(0, 0);
325 } else { 325 } else {
326 while (frame) { 326 while (frame) {
327 if (frame->isLocalFrame()) { 327 if (frame->isLocalFrame()) {
328 LocalFrame* localFrame = toLocalFrame(frame); 328 LocalFrame* localFrame = toLocalFrame(frame);
329 if (m_framesWithUninstrumentedCanvases.contains(localFrame)) 329 if (m_framesWithUninstrumentedCanvases.contains(localFrame))
330 m_framesWithUninstrumentedCanvases.set(localFrame, false); 330 m_framesWithUninstrumentedCanvases.set(localFrame, false);
331 if (m_pageAgent->hasIdForFrame(localFrame)) { 331 if (m_pageAgent->hasIdForFrame(localFrame)) {
(...skipping 19 matching lines...) Expand all
351 ErrorString error; 351 ErrorString error;
352 for (const auto& frame : m_framesWithUninstrumentedCanvases) { 352 for (const auto& frame : m_framesWithUninstrumentedCanvases) {
353 InjectedScriptCanvasModule module = injectedScriptCanvasModule(&error, S criptState::forMainWorld(frame.key)); 353 InjectedScriptCanvasModule module = injectedScriptCanvasModule(&error, S criptState::forMainWorld(frame.key));
354 if (!module.isEmpty()) 354 if (!module.isEmpty())
355 module.markFrameEnd(); 355 module.markFrameEnd();
356 } 356 }
357 } 357 }
358 358
359 } // namespace blink 359 } // namespace blink
360 360
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorApplicationCacheAgent.cpp ('k') | Source/core/inspector/InspectorController.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698