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

Side by Side Diff: third_party/WebKit/Source/modules/compositorworker/AbstractAnimationWorkletThread.cpp

Issue 2214263007: [worklets] Split apart CompositorWorkerThread for sharing with AnimationWorkletThread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rename abstract class. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 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 "modules/compositorworker/CompositorWorkerThread.h" 5 #include "modules/compositorworker/AbstractAnimationWorkletThread.h"
6 6
7 #include "bindings/core/v8/V8GCController.h"
8 #include "bindings/core/v8/V8Initializer.h"
9 #include "core/workers/InProcessWorkerObjectProxy.h"
10 #include "core/workers/WorkerBackingThread.h" 7 #include "core/workers/WorkerBackingThread.h"
11 #include "core/workers/WorkerThreadStartupData.h"
12 #include "modules/compositorworker/CompositorWorkerGlobalScope.h"
13 #include "platform/CrossThreadFunctional.h" 8 #include "platform/CrossThreadFunctional.h"
14 #include "platform/TraceEvent.h"
15 #include "platform/WaitableEvent.h" 9 #include "platform/WaitableEvent.h"
16 #include "platform/WebThreadSupportingGC.h" 10 #include "platform/WebThreadSupportingGC.h"
17 #include "public/platform/Platform.h" 11 #include "public/platform/Platform.h"
18 #include "wtf/Assertions.h" 12 #include "wtf/Assertions.h"
19 #include "wtf/PtrUtil.h" 13 #include "wtf/PtrUtil.h"
20 #include <memory> 14 #include <memory>
21 15
22 namespace blink { 16 namespace blink {
23 17
24 namespace { 18 namespace {
25 19
26 // This is a singleton class holding the compositor worker thread in this 20 // This is a singleton class holding the animation worklet thread in this
27 // renderer process. BackingThreadHolder::m_thread is cleared by 21 // renderer process. BackingThreadHolder::m_thread is cleared by
28 // ModulesInitializer::shutdown. 22 // ModulesInitializer::shutdown.
29 // See WorkerThread::terminateAndWaitForAllWorkers for the process shutdown 23 // See WorkerThread::terminateAndWaitForAllWorkers for the process shutdown
30 // case. 24 // case.
31 class BackingThreadHolder { 25 class BackingThreadHolder {
32 public: 26 public:
33 static BackingThreadHolder& instance() 27 static BackingThreadHolder& instance()
34 { 28 {
35 MutexLocker locker(holderInstanceMutex()); 29 MutexLocker locker(holderInstanceMutex());
36 return *s_instance; 30 return *s_instance;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 std::unique_ptr<WorkerBackingThread> m_thread; 94 std::unique_ptr<WorkerBackingThread> m_thread;
101 bool m_initialized = false; 95 bool m_initialized = false;
102 96
103 static BackingThreadHolder* s_instance; 97 static BackingThreadHolder* s_instance;
104 }; 98 };
105 99
106 BackingThreadHolder* BackingThreadHolder::s_instance = nullptr; 100 BackingThreadHolder* BackingThreadHolder::s_instance = nullptr;
107 101
108 } // namespace 102 } // namespace
109 103
110 std::unique_ptr<CompositorWorkerThread> CompositorWorkerThread::create(PassRefPt r<WorkerLoaderProxy> workerLoaderProxy, InProcessWorkerObjectProxy& workerObject Proxy, double timeOrigin) 104 AbstractAnimationWorkletThread::AbstractAnimationWorkletThread(PassRefPtr<Worker LoaderProxy> workerLoaderProxy, WorkerReportingProxy& workerReportingProxy)
111 { 105 : WorkerThread(workerLoaderProxy, workerReportingProxy)
112 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), "CompositorWork erThread::create");
113 ASSERT(isMainThread());
114 return wrapUnique(new CompositorWorkerThread(workerLoaderProxy, workerObject Proxy, timeOrigin));
115 }
116
117 CompositorWorkerThread::CompositorWorkerThread(PassRefPtr<WorkerLoaderProxy> wor kerLoaderProxy, InProcessWorkerObjectProxy& workerObjectProxy, double timeOrigin )
118 : WorkerThread(workerLoaderProxy, workerObjectProxy)
119 , m_workerObjectProxy(workerObjectProxy)
120 , m_timeOrigin(timeOrigin)
121 { 106 {
122 } 107 }
123 108
124 CompositorWorkerThread::~CompositorWorkerThread() 109 AbstractAnimationWorkletThread::~AbstractAnimationWorkletThread()
125 { 110 {
126 } 111 }
127 112
128 WorkerBackingThread& CompositorWorkerThread::workerBackingThread() 113 WorkerBackingThread& AbstractAnimationWorkletThread::workerBackingThread()
129 { 114 {
130 return *BackingThreadHolder::instance().thread(); 115 return *BackingThreadHolder::instance().thread();
131 } 116 }
132 117
133 WorkerOrWorkletGlobalScope* CompositorWorkerThread::createWorkerGlobalScope(std: :unique_ptr<WorkerThreadStartupData> startupData) 118 void AbstractAnimationWorkletThread::ensureSharedBackingThread()
134 {
135 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), "CompositorWork erThread::createWorkerGlobalScope");
136 return CompositorWorkerGlobalScope::create(this, std::move(startupData), m_t imeOrigin);
137 }
138
139 void CompositorWorkerThread::ensureSharedBackingThread()
140 { 119 {
141 DCHECK(isMainThread()); 120 DCHECK(isMainThread());
142 BackingThreadHolder::ensureInstance(); 121 BackingThreadHolder::ensureInstance();
143 } 122 }
144 123
145 void CompositorWorkerThread::clearSharedBackingThread() 124 void AbstractAnimationWorkletThread::clearSharedBackingThread()
146 { 125 {
147 DCHECK(isMainThread()); 126 DCHECK(isMainThread());
148 BackingThreadHolder::clear(); 127 BackingThreadHolder::clear();
149 } 128 }
150 129
151 void CompositorWorkerThread::createSharedBackingThreadForTest() 130 void AbstractAnimationWorkletThread::createSharedBackingThreadForTest()
152 { 131 {
153 BackingThreadHolder::createForTest(); 132 BackingThreadHolder::createForTest();
154 } 133 }
155 134
156 } // namespace blink 135 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698