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

Unified Diff: third_party/WebKit/Source/web/CompositorMutatorImpl.cpp

Issue 2204183002: Prepare CompositorWorker for per thread heap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/web/CompositorMutatorImpl.cpp
diff --git a/third_party/WebKit/Source/web/CompositorMutatorImpl.cpp b/third_party/WebKit/Source/web/CompositorMutatorImpl.cpp
index eddb7cb5972855c792cb2a2e48e854c5f32239ae..3a0ee6e698f421c997c28b702e8a5371f12d1f22 100644
--- a/third_party/WebKit/Source/web/CompositorMutatorImpl.cpp
+++ b/third_party/WebKit/Source/web/CompositorMutatorImpl.cpp
@@ -64,8 +64,9 @@ bool CompositorMutatorImpl::mutate(double monotonicTimeNow, CompositorMutableSta
// TODO(vollick): we should avoid executing the animation frame
// callbacks if none of the proxies in the global scope are affected by
// m_mutations.
- for (CompositorProxyClientImpl* client : m_proxyClients) {
- if (client->mutate(monotonicTimeNow, stateProvider))
+ for (auto& it : m_proxyClients) {
+ CrossThreadPersistent<CompositorProxyClientImpl> client = CrossThreadPersistent<CompositorProxyClientImpl>::protectWeak(it);
+ if (client && client->mutate(monotonicTimeNow, stateProvider))
needToReinvoke = true;
}
@@ -75,7 +76,21 @@ bool CompositorMutatorImpl::mutate(double monotonicTimeNow, CompositorMutableSta
void CompositorMutatorImpl::registerProxyClient(CompositorProxyClientImpl* client)
{
TRACE_EVENT0("compositor-worker", "CompositorMutatorImpl::registerClient");
- m_proxyClients.add(client);
+ CrossThreadWeakPersistent<CompositorProxyClientImpl>* insertPosition = nullptr;
+ for (auto& it : m_proxyClients) {
+ CrossThreadPersistent<CompositorProxyClientImpl> protect = CrossThreadPersistent<CompositorProxyClientImpl>::protectWeak(it);
+ if (!protect && !insertPosition) {
+ insertPosition = &it;
+#if !DCHECK_IS_ON()
+ break;
+#endif
+ }
+ DCHECK_NE(protect, client);
+ }
+ if (insertPosition)
+ *insertPosition = client;
+ else
+ m_proxyClients.append(client);
setNeedsMutate();
}

Powered by Google App Engine
This is Rietveld 408576698