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

Side by Side Diff: third_party/WebKit/Source/core/workers/WorkerBackingThread.h

Issue 1733353004: Introduce WorkerBackingThread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef WorkerBackingThread_h
6 #define WorkerBackingThread_h
7
8 #include "core/CoreExport.h"
9 #include "wtf/Forward.h"
10 #include "wtf/OwnPtr.h"
11 #include "wtf/PassOwnPtr.h"
12 #include "wtf/PassRefPtr.h"
13 #include "wtf/ThreadSafeRefCounted.h"
14 #include "wtf/ThreadingPrimitives.h"
15 #include <v8.h>
16
17 namespace blink {
18
19 class WaitableEvent;
20 class WebThread;
21 class WebThreadSupportingGC;
22
23 class CORE_EXPORT WorkerBackingThread final : public ThreadSafeRefCounted<Worker BackingThread> {
24 public:
25 static PassRefPtr<WorkerBackingThread> create(const char* name) { return ado ptRef(new WorkerBackingThread(name)); }
26 static PassRefPtr<WorkerBackingThread> create(WebThread* thread) { return ad optRef(new WorkerBackingThread(thread)); }
27
28 ~WorkerBackingThread();
29
30 void attach();
31 void detach();
32 unsigned workerScriptCount()
33 {
34 MutexLocker locker(m_mutex);
35 return m_workerScriptCount;
36 }
37
38 WebThreadSupportingGC& backingThread()
39 {
40 ASSERT(m_backingThread);
41 return *m_backingThread;
42 }
43
44 v8::Isolate* isolate() const { return m_isolate; }
45
46 void setInitializationEventForTest();
47 WaitableEvent* initializationEventForTest() { return m_initializationEventFo rTest.get(); }
kinuko 2016/02/29 09:32:53 Hmm could we not have these?
yhirano 2016/02/29 23:47:32 Done.
48
49 private:
50 explicit WorkerBackingThread(const char* name);
51 explicit WorkerBackingThread(WebThread*);
52 void initialize();
53 void shutdown();
54
55 Mutex m_mutex;
56 OwnPtr<WebThreadSupportingGC> m_backingThread;
57 OwnPtr<WaitableEvent> m_initializationEventForTest;
58 v8::Isolate* m_isolate = nullptr;
59 unsigned m_workerScriptCount = 0;
60 bool m_isOwningThread;
61 };
62
63 } // namespace blink
64
65 #endif // WorkerBackingThread_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698