OLD | NEW |
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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 { | 123 { |
124 InjectedScriptCanvasModule module = injectedScriptCanvasModule(errorString,
traceLogId); | 124 InjectedScriptCanvasModule module = injectedScriptCanvasModule(errorString,
traceLogId); |
125 if (!module.isEmpty()) | 125 if (!module.isEmpty()) |
126 module.dropTraceLog(errorString, traceLogId); | 126 module.dropTraceLog(errorString, traceLogId); |
127 } | 127 } |
128 | 128 |
129 void InspectorCanvasAgent::hasUninstrumentedCanvases(ErrorString* errorString, b
ool* result) | 129 void InspectorCanvasAgent::hasUninstrumentedCanvases(ErrorString* errorString, b
ool* result) |
130 { | 130 { |
131 if (!checkIsEnabled(errorString)) | 131 if (!checkIsEnabled(errorString)) |
132 return; | 132 return; |
133 for (FramesWithUninstrumentedCanvases::const_iterator it = m_framesWithUnins
trumentedCanvases.begin(); it != m_framesWithUninstrumentedCanvases.end(); ++it)
{ | 133 for (const auto& frame : m_framesWithUninstrumentedCanvases) { |
134 if (it->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->mainFrame(); | 144 LocalFrame* frame = frameId ? m_pageAgent->assertFrame(errorString, *frameId
) : m_pageAgent->mainFrame(); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 | 290 |
291 private: | 291 private: |
292 Page* m_page; | 292 Page* m_page; |
293 FramesWithUninstrumentedCanvases& m_framesWithUninstrumentedCanvases; | 293 FramesWithUninstrumentedCanvases& m_framesWithUninstrumentedCanvases; |
294 } nodeVisitor(m_pageAgent->page(), m_framesWithUninstrumentedCanvases); | 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 (FramesWithUninstrumentedCanvases::const_iterator it = m_framesWithU
ninstrumentedCanvases.begin(); it != m_framesWithUninstrumentedCanvases.end(); +
+it) { | 300 for (const auto& frame : m_framesWithUninstrumentedCanvases) { |
301 String frameId = m_pageAgent->frameId(it->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->mainFrame()) { | 321 if (frame == m_pageAgent->mainFrame()) { |
322 for (FramesWithUninstrumentedCanvases::iterator it = m_framesWithUninstr
umentedCanvases.begin(); it != m_framesWithUninstrumentedCanvases.end(); ++it) | 322 for (auto& frame : m_framesWithUninstrumentedCanvases) |
323 it->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)) { |
332 String frameId = m_pageAgent->frameId(localFrame); | 332 String frameId = m_pageAgent->frameId(localFrame); |
333 m_frontend->traceLogsRemoved(&frameId, 0); | 333 m_frontend->traceLogsRemoved(&frameId, 0); |
334 } | 334 } |
335 } | 335 } |
336 frame = frame->tree().traverseNext(); | 336 frame = frame->tree().traverseNext(); |
337 } | 337 } |
338 } | 338 } |
339 } | 339 } |
340 | 340 |
341 void InspectorCanvasAgent::frameDetachedFromParent(LocalFrame* frame) | 341 void InspectorCanvasAgent::frameDetachedFromParent(LocalFrame* frame) |
342 { | 342 { |
343 if (m_enabled) | 343 if (m_enabled) |
344 m_framesWithUninstrumentedCanvases.remove(frame); | 344 m_framesWithUninstrumentedCanvases.remove(frame); |
345 } | 345 } |
346 | 346 |
347 void InspectorCanvasAgent::didBeginFrame() | 347 void InspectorCanvasAgent::didBeginFrame() |
348 { | 348 { |
349 if (!m_enabled) | 349 if (!m_enabled) |
350 return; | 350 return; |
351 ErrorString error; | 351 ErrorString error; |
352 for (FramesWithUninstrumentedCanvases::const_iterator it = m_framesWithUnins
trumentedCanvases.begin(); it != m_framesWithUninstrumentedCanvases.end(); ++it)
{ | 352 for (const auto& frame : m_framesWithUninstrumentedCanvases) { |
353 InjectedScriptCanvasModule module = injectedScriptCanvasModule(&error, S
criptState::forMainWorld(it->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 |
OLD | NEW |