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

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, 8 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/ThreadingPrimitives.h"
13 #include <v8.h>
14
15 namespace blink {
16
17 class WebThread;
18 class WebThreadSupportingGC;
19
20 class CORE_EXPORT WorkerBackingThread final {
kinuko 2016/04/04 16:18:16 Could we have a nice class-level comment for this?
yhirano 2016/04/06 01:51:40 I wrote something, though I'm not sure if it's nic
21 public:
22 static PassOwnPtr<WorkerBackingThread> create(const char* name) { return ado ptPtr(new WorkerBackingThread(name, false)); }
23 static PassOwnPtr<WorkerBackingThread> create(WebThread* thread) { return ad optPtr(new WorkerBackingThread(thread, false)); }
24
25 // These are needed to suppress leak reports. See
26 // https://crbug.com/590802 and https://crbug.com/v8/1428.
27 static PassOwnPtr<WorkerBackingThread> createForTest(const char* name) { ret urn adoptPtr(new WorkerBackingThread(name, true)); }
28 static PassOwnPtr<WorkerBackingThread> createForTest(WebThread* thread) { re turn adoptPtr(new WorkerBackingThread(thread, true)); }
29
30 ~WorkerBackingThread();
31
32 // attach() and detach() atacches and detatches Oilpan and V8 to / from
kinuko 2016/04/04 16:18:16 nit: atacches -> attaches detatches -> detaches
yhirano 2016/04/06 01:51:40 Done.
33 // the caller worker script, respectively. attach() and detach() increments
34 // and decrements m_workerScriptCount. attach() initializes Oilpan and V8
35 // when m_workerScriptCount is 0. detach() terminates Oilpan and V8 when
36 // m_workerScriptCount is 1. A worker script must not call any function
37 // after calling detach().
38 void attach();
39 void detach();
40 unsigned workerScriptCount()
kinuko 2016/04/04 16:18:16 nit: put one empty line after detach() before work
yhirano 2016/04/06 01:51:40 Done.
41 {
42 MutexLocker locker(m_mutex);
43 return m_workerScriptCount;
44 }
45
46 WebThreadSupportingGC& backingThread()
47 {
48 ASSERT(m_backingThread);
49 return *m_backingThread;
50 }
51
52 v8::Isolate* isolate() { return m_isolate; }
53
54 private:
55 WorkerBackingThread(const char* name, bool shouldCallGCOnShutdown);
56 WorkerBackingThread(WebThread*, bool shouldCallGCOnSHutdown);
57 void initialize();
58 void shutdown();
59
60 Mutex m_mutex;
61 OwnPtr<WebThreadSupportingGC> m_backingThread;
62 v8::Isolate* m_isolate = nullptr;
63 unsigned m_workerScriptCount = 0;
nhiroki 2016/04/05 10:04:33 It'd be nice to have a comment about what |m_mutex
yhirano 2016/04/06 01:51:40 Done.
64 bool m_isOwningThread;
65 bool m_shouldCallGCOnShutdown;
66 };
67
68 } // namespace blink
69
70 #endif // WorkerBackingThread_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698