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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "web/CompositorMutatorImpl.h" 5 #include "web/CompositorMutatorImpl.h"
6 6
7 #include "core/animation/CustomCompositorAnimationManager.h" 7 #include "core/animation/CustomCompositorAnimationManager.h"
8 #include "core/dom/CompositorProxy.h" 8 #include "core/dom/CompositorProxy.h"
9 #include "platform/CrossThreadFunctional.h" 9 #include "platform/CrossThreadFunctional.h"
10 #include "platform/TraceEvent.h" 10 #include "platform/TraceEvent.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 return new CompositorMutatorImpl(); 57 return new CompositorMutatorImpl();
58 } 58 }
59 59
60 bool CompositorMutatorImpl::mutate(double monotonicTimeNow, CompositorMutableSta teProvider* stateProvider) 60 bool CompositorMutatorImpl::mutate(double monotonicTimeNow, CompositorMutableSta teProvider* stateProvider)
61 { 61 {
62 TRACE_EVENT0("compositor-worker", "CompositorMutatorImpl::mutate"); 62 TRACE_EVENT0("compositor-worker", "CompositorMutatorImpl::mutate");
63 bool needToReinvoke = false; 63 bool needToReinvoke = false;
64 // TODO(vollick): we should avoid executing the animation frame 64 // TODO(vollick): we should avoid executing the animation frame
65 // callbacks if none of the proxies in the global scope are affected by 65 // callbacks if none of the proxies in the global scope are affected by
66 // m_mutations. 66 // m_mutations.
67 for (CompositorProxyClientImpl* client : m_proxyClients) { 67 for (auto& it : m_proxyClients) {
68 if (client->mutate(monotonicTimeNow, stateProvider)) 68 CrossThreadPersistent<CompositorProxyClientImpl> client = CrossThreadPer sistent<CompositorProxyClientImpl>::protectWeak(it);
69 if (client && client->mutate(monotonicTimeNow, stateProvider))
69 needToReinvoke = true; 70 needToReinvoke = true;
70 } 71 }
71 72
72 return needToReinvoke; 73 return needToReinvoke;
73 } 74 }
74 75
75 void CompositorMutatorImpl::registerProxyClient(CompositorProxyClientImpl* clien t) 76 void CompositorMutatorImpl::registerProxyClient(CompositorProxyClientImpl* clien t)
76 { 77 {
77 TRACE_EVENT0("compositor-worker", "CompositorMutatorImpl::registerClient"); 78 TRACE_EVENT0("compositor-worker", "CompositorMutatorImpl::registerClient");
78 m_proxyClients.add(client); 79 CrossThreadWeakPersistent<CompositorProxyClientImpl>* insertPosition = nullp tr;
80 for (auto& it : m_proxyClients) {
81 CrossThreadPersistent<CompositorProxyClientImpl> protect = CrossThreadPe rsistent<CompositorProxyClientImpl>::protectWeak(it);
82 if (!protect && !insertPosition) {
83 insertPosition = &it;
84 #if !DCHECK_IS_ON()
85 break;
86 #endif
87 }
88 DCHECK_NE(protect, client);
89 }
90 if (insertPosition)
91 *insertPosition = client;
92 else
93 m_proxyClients.append(client);
haraken 2016/09/07 15:10:30 Hmm, this looks very complicated and I'm not sure
keishi 2016/09/12 09:00:48 I used WorkerGlobalScope::dispose for explicit rem
79 setNeedsMutate(); 94 setNeedsMutate();
80 } 95 }
81 96
82 void CompositorMutatorImpl::setNeedsMutate() 97 void CompositorMutatorImpl::setNeedsMutate()
83 { 98 {
84 TRACE_EVENT0("compositor-worker", "CompositorMutatorImpl::setNeedsMutate"); 99 TRACE_EVENT0("compositor-worker", "CompositorMutatorImpl::setNeedsMutate");
85 m_client->setNeedsMutate(); 100 m_client->setNeedsMutate();
86 } 101 }
87 102
88 } // namespace blink 103 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698