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

Side by Side Diff: Source/platform/WebThreadSupportingGC.h

Issue 1319363002: Makes WebThreadSupportingGC constructible for an existing thread (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef WebThreadSupportingGC_h 5 #ifndef WebThreadSupportingGC_h
6 #define WebThreadSupportingGC_h 6 #define WebThreadSupportingGC_h
7 7
8 #include "platform/heap/glue/MessageLoopInterruptor.h" 8 #include "platform/heap/glue/MessageLoopInterruptor.h"
9 #include "platform/heap/glue/PendingGCRunner.h" 9 #include "platform/heap/glue/PendingGCRunner.h"
10 #include "public/platform/Platform.h" 10 #include "public/platform/Platform.h"
11 #include "public/platform/WebThread.h" 11 #include "public/platform/WebThread.h"
12 #include "wtf/Noncopyable.h" 12 #include "wtf/Noncopyable.h"
13 #include "wtf/OwnPtr.h" 13 #include "wtf/OwnPtr.h"
14 #include "wtf/PassOwnPtr.h" 14 #include "wtf/PassOwnPtr.h"
15 15
16 namespace blink { 16 namespace blink {
17 17
18 // WebThreadSupportingGC wraps a WebThread and adds support for attaching 18 // WebThreadSupportingGC wraps a WebThread and adds support for attaching
19 // to and detaching from the Blink GC infrastructure. The initialize method 19 // to and detaching from the Blink GC infrastructure. The initialize method
20 // must be called during initialization on the WebThread and before the 20 // must be called during initialization on the WebThread and before the
21 // thread allocates any objects managed by the Blink GC. The shutdown 21 // thread allocates any objects managed by the Blink GC. The shutdown
22 // method must be called on the WebThread during shutdown when the thread 22 // method must be called on the WebThread during shutdown when the thread
23 // no longer needs to access objects managed by the Blink GC. 23 // no longer needs to access objects managed by the Blink GC.
24 //
25 // WebThreadSupportingGC usually internally creates and owns WebThread unless
26 // an existing WebThread is given via createForThread.
24 class PLATFORM_EXPORT WebThreadSupportingGC final { 27 class PLATFORM_EXPORT WebThreadSupportingGC final {
25 WTF_MAKE_NONCOPYABLE(WebThreadSupportingGC); 28 WTF_MAKE_NONCOPYABLE(WebThreadSupportingGC);
26 public: 29 public:
27 static PassOwnPtr<WebThreadSupportingGC> create(const char*); 30 static PassOwnPtr<WebThreadSupportingGC> create(const char* name);
31 static PassOwnPtr<WebThreadSupportingGC> createForThread(WebThread*);
28 ~WebThreadSupportingGC(); 32 ~WebThreadSupportingGC();
29 33
30 void postTask(const WebTraceLocation& location, WebThread::Task* task) 34 void postTask(const WebTraceLocation& location, WebThread::Task* task)
31 { 35 {
32 m_thread->postTask(location, task); 36 m_thread->postTask(location, task);
33 } 37 }
34 38
35 void postDelayedTask(const WebTraceLocation& location, WebThread::Task* task , long long delayMs) 39 void postDelayedTask(const WebTraceLocation& location, WebThread::Task* task , long long delayMs)
36 { 40 {
37 m_thread->postDelayedTask(location, task, delayMs); 41 m_thread->postDelayedTask(location, task, delayMs);
(...skipping 17 matching lines...) Expand all
55 void initialize(); 59 void initialize();
56 void shutdown(); 60 void shutdown();
57 61
58 WebThread& platformThread() const 62 WebThread& platformThread() const
59 { 63 {
60 ASSERT(m_thread); 64 ASSERT(m_thread);
61 return *m_thread; 65 return *m_thread;
62 } 66 }
63 67
64 private: 68 private:
65 explicit WebThreadSupportingGC(const char*); 69 WebThreadSupportingGC(const char* name, WebThread*);
66 70
67 OwnPtr<PendingGCRunner> m_pendingGCRunner; 71 OwnPtr<PendingGCRunner> m_pendingGCRunner;
68 OwnPtr<WebThread> m_thread; 72
73 // m_thread is guaranteed to be non-null after this instance is constructed.
74 // m_owningThread is non-null unless this instance is constructed for an
75 // existing thread via createForThread().
76 WebThread* m_thread = nullptr;
77 OwnPtr<WebThread> m_owningThread;
69 }; 78 };
70 79
71 } 80 }
72 81
73 #endif 82 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698