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

Side by Side Diff: third_party/WebKit/Source/core/dom/FrameRequestCallbackCollection.cpp

Issue 2553343002: Avoid WTF::Vector::at() and operator[] in core/dom. (Closed)
Patch Set: Created 4 years 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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/dom/FrameRequestCallbackCollection.h" 5 #include "core/dom/FrameRequestCallbackCollection.h"
6 6
7 #include "core/dom/FrameRequestCallback.h" 7 #include "core/dom/FrameRequestCallback.h"
8 #include "core/frame/PerformanceMonitor.h" 8 #include "core/frame/PerformanceMonitor.h"
9 #include "core/inspector/InspectorInstrumentation.h" 9 #include "core/inspector/InspectorInstrumentation.h"
10 #include "core/inspector/InspectorTraceEvents.h" 10 #include "core/inspector/InspectorTraceEvents.h"
(...skipping 28 matching lines...) Expand all
39 InspectorInstrumentation::asyncTaskCanceled(m_context, m_callbacks[i]); 39 InspectorInstrumentation::asyncTaskCanceled(m_context, m_callbacks[i]);
40 InspectorInstrumentation::NativeBreakpoint nativeBreakpoint( 40 InspectorInstrumentation::NativeBreakpoint nativeBreakpoint(
41 m_context, "cancelAnimationFrame", true); 41 m_context, "cancelAnimationFrame", true);
42 m_callbacks.remove(i); 42 m_callbacks.remove(i);
43 TRACE_EVENT_INSTANT1("devtools.timeline", "CancelAnimationFrame", 43 TRACE_EVENT_INSTANT1("devtools.timeline", "CancelAnimationFrame",
44 TRACE_EVENT_SCOPE_THREAD, "data", 44 TRACE_EVENT_SCOPE_THREAD, "data",
45 InspectorAnimationFrameEvent::data(m_context, id)); 45 InspectorAnimationFrameEvent::data(m_context, id));
46 return; 46 return;
47 } 47 }
48 } 48 }
49 for (size_t i = 0; i < m_callbacksToInvoke.size(); ++i) { 49 for (const auto& callback : m_callbacksToInvoke) {
50 if (m_callbacksToInvoke[i]->m_id == id) { 50 if (callback->m_id == id) {
51 InspectorInstrumentation::asyncTaskCanceled(m_context, 51 InspectorInstrumentation::asyncTaskCanceled(m_context, callback);
52 m_callbacksToInvoke[i]);
53 InspectorInstrumentation::NativeBreakpoint nativeBreakpoint( 52 InspectorInstrumentation::NativeBreakpoint nativeBreakpoint(
54 m_context, "cancelAnimationFrame", true); 53 m_context, "cancelAnimationFrame", true);
55 TRACE_EVENT_INSTANT1("devtools.timeline", "CancelAnimationFrame", 54 TRACE_EVENT_INSTANT1("devtools.timeline", "CancelAnimationFrame",
56 TRACE_EVENT_SCOPE_THREAD, "data", 55 TRACE_EVENT_SCOPE_THREAD, "data",
57 InspectorAnimationFrameEvent::data(m_context, id)); 56 InspectorAnimationFrameEvent::data(m_context, id));
58 m_callbacksToInvoke[i]->m_cancelled = true; 57 callback->m_cancelled = true;
59 // will be removed at the end of executeCallbacks() 58 // will be removed at the end of executeCallbacks()
60 return; 59 return;
61 } 60 }
62 } 61 }
63 } 62 }
64 63
65 void FrameRequestCallbackCollection::executeCallbacks( 64 void FrameRequestCallbackCollection::executeCallbacks(
66 double highResNowMs, 65 double highResNowMs,
67 double highResNowMsLegacy) { 66 double highResNowMsLegacy) {
68 // First, generate a list of callbacks to consider. Callbacks registered from 67 // First, generate a list of callbacks to consider. Callbacks registered from
69 // this point on are considered only for the "next" frame, not this one. 68 // this point on are considered only for the "next" frame, not this one.
70 DCHECK(m_callbacksToInvoke.isEmpty()); 69 DCHECK(m_callbacksToInvoke.isEmpty());
71 m_callbacksToInvoke.swap(m_callbacks); 70 m_callbacksToInvoke.swap(m_callbacks);
72 71
73 for (size_t i = 0; i < m_callbacksToInvoke.size(); ++i) { 72 for (const auto& callback : m_callbacksToInvoke) {
74 FrameRequestCallback* callback = m_callbacksToInvoke[i].get();
75 if (!callback->m_cancelled) { 73 if (!callback->m_cancelled) {
76 TRACE_EVENT1( 74 TRACE_EVENT1(
77 "devtools.timeline", "FireAnimationFrame", "data", 75 "devtools.timeline", "FireAnimationFrame", "data",
78 InspectorAnimationFrameEvent::data(m_context, callback->m_id)); 76 InspectorAnimationFrameEvent::data(m_context, callback->m_id));
79 InspectorInstrumentation::NativeBreakpoint nativeBreakpoint( 77 InspectorInstrumentation::NativeBreakpoint nativeBreakpoint(
80 m_context, "animationFrameFired", false); 78 m_context, "animationFrameFired", false);
81 InspectorInstrumentation::AsyncTask asyncTask(m_context, callback); 79 InspectorInstrumentation::AsyncTask asyncTask(m_context, callback);
82 PerformanceMonitor::HandlerCall handlerCall( 80 PerformanceMonitor::HandlerCall handlerCall(
83 m_context, "requestAnimationFrame", true); 81 m_context, "requestAnimationFrame", true);
84 if (callback->m_useLegacyTimeBase) 82 if (callback->m_useLegacyTimeBase)
85 callback->handleEvent(highResNowMsLegacy); 83 callback->handleEvent(highResNowMsLegacy);
86 else 84 else
87 callback->handleEvent(highResNowMs); 85 callback->handleEvent(highResNowMs);
88 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), 86 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"),
89 "UpdateCounters", TRACE_EVENT_SCOPE_THREAD, "data", 87 "UpdateCounters", TRACE_EVENT_SCOPE_THREAD, "data",
90 InspectorUpdateCountersEvent::data()); 88 InspectorUpdateCountersEvent::data());
91 } 89 }
92 } 90 }
93 91
94 m_callbacksToInvoke.clear(); 92 m_callbacksToInvoke.clear();
95 } 93 }
96 94
97 DEFINE_TRACE(FrameRequestCallbackCollection) { 95 DEFINE_TRACE(FrameRequestCallbackCollection) {
98 visitor->trace(m_callbacks); 96 visitor->trace(m_callbacks);
99 visitor->trace(m_callbacksToInvoke); 97 visitor->trace(m_callbacksToInvoke);
100 visitor->trace(m_context); 98 visitor->trace(m_context);
101 } 99 }
102 100
103 } // namespace blink 101 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/DOMTokenList.cpp ('k') | third_party/WebKit/Source/core/dom/MutationObserver.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698