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

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, 4 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..a3b057e7ab37c7ce2546faa79b48a697773ce00d 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(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) {
haraken 2016/08/22 14:24:44 Would it make more sense to provide a helper class
keishi 2016/09/02 06:41:55 Strongifying all items at once is hard, and this p
+ CrossThreadPersistent<CompositorProxyClientImpl> protect(it);
haraken 2016/08/22 14:24:44 I'm just curious but how did you find that you nee
keishi 2016/09/02 06:41:55 I think the only safe way to use CrossThreadWeakPe
haraken 2016/09/02 09:39:17 Ah, the DCHECK looks clever! However, maybe would
keishi 2016/09/07 10:14:42 I was worried about this so I would love to do thi
+ 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