Chromium Code Reviews| 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 = ⁢ |
| +#if !DCHECK_IS_ON() |
| + break; |
| +#endif |
| + } |
| + DCHECK_NE(protect, client); |
| + } |
| + if (insertPosition) |
| + *insertPosition = client; |
| + else |
| + 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
|
| setNeedsMutate(); |
| } |