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

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

Issue 474683003: Not for review - Rebase of crrev.com/62833003 Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: . Created 6 years, 1 month 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
« no previous file with comments | « Source/platform/WebThreadRawPtr.h ('k') | Source/platform/WebThreadSupportingGC.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "WebThreadOwnPtr.h"
15 16
16 namespace blink { 17 namespace blink {
17 18
18 // WebThreadSupportingGC wraps a WebThread and adds support for attaching 19 // WebThreadSupportingGC wraps a WebThread and adds support for attaching
19 // to and detaching from the Blink GC infrastructure. The attachGC method 20 // to and detaching from the Blink GC infrastructure. The attachGC method
20 // must be called during initialization on the WebThread and before the 21 // must be called during initialization on the WebThread and before the
21 // thread allocates any objects managed by the Blink GC. The detach GC 22 // thread allocates any objects managed by the Blink GC. The detach GC
22 // method must be called on the WebThread during shutdown when the thread 23 // method must be called on the WebThread during shutdown when the thread
23 // no longer needs to access objects managed by the Blink GC. 24 // no longer needs to access objects managed by the Blink GC.
24 class PLATFORM_EXPORT WebThreadSupportingGC final { 25 class PLATFORM_EXPORT WebThreadSupportingGC {
25 WTF_MAKE_NONCOPYABLE(WebThreadSupportingGC); 26 WTF_MAKE_NONCOPYABLE(WebThreadSupportingGC);
26 public: 27 public:
27 static PassOwnPtr<WebThreadSupportingGC> create(const char*); 28 static PassOwnPtr<WebThreadSupportingGC> create(const char*);
28 ~WebThreadSupportingGC(); 29 virtual ~WebThreadSupportingGC();
29 30
30 void postTask(WebThread::Task* task) 31 void postTask(WebThread::Task* task)
31 { 32 {
32 m_thread->postTask(task); 33 (*m_thread)->postTask(task);
33 } 34 }
34 35
35 void postDelayedTask(WebThread::Task* task, long long delayMs) 36 void postDelayedTask(WebThread::Task* task, long long delayMs)
36 { 37 {
37 m_thread->postDelayedTask(task, delayMs); 38 (*m_thread)->postDelayedTask(task, delayMs);
38 } 39 }
39 40
40 bool isCurrentThread() const 41 bool isCurrentThread() const
41 { 42 {
42 return m_thread->isCurrentThread(); 43 return (*m_thread)->isCurrentThread();
43 } 44 }
44 45
45 void addTaskObserver(WebThread::TaskObserver* observer) 46 void addTaskObserver(WebThread::TaskObserver* observer)
46 { 47 {
47 m_thread->addTaskObserver(observer); 48 (*m_thread)->addTaskObserver(observer);
48 } 49 }
49 50
50 void removeTaskObserver(WebThread::TaskObserver* observer) 51 void removeTaskObserver(WebThread::TaskObserver* observer)
51 { 52 {
52 m_thread->removeTaskObserver(observer); 53 (*m_thread)->removeTaskObserver(observer);
53 } 54 }
54 55
55 void enterRunLoop() 56 void enterRunLoop()
56 { 57 {
57 m_thread->enterRunLoop(); 58 (*m_thread)->enterRunLoop();
58 } 59 }
59 60
60 void exitRunLoop() 61 void exitRunLoop()
61 { 62 {
62 m_thread->exitRunLoop(); 63 (*m_thread)->exitRunLoop();
63 } 64 }
64 65
65 void attachGC(); 66 virtual void attachGC();
66 void detachGC(); 67 virtual void detachGC();
67 68
68 WebThread& platformThread() const 69 WebThread& platformThread() const
69 { 70 {
70 ASSERT(m_thread); 71 // ASSERT(*(m_thread));
71 return *m_thread; 72 return *(*m_thread);
72 } 73 }
73 74
74 private: 75 private:
75 explicit WebThreadSupportingGC(const char*); 76 explicit WebThreadSupportingGC(const char*);
76 77
77 OwnPtr<PendingGCRunner> m_pendingGCRunner; 78 OwnPtr<PendingGCRunner> m_pendingGCRunner;
78 OwnPtr<MessageLoopInterruptor> m_messageLoopInterruptor; 79 OwnPtr<MessageLoopInterruptor> m_messageLoopInterruptor;
79 80
81 protected:
82 WebThreadSupportingGC() {}
80 // FIXME: This has to be last because of crbug.com/401397. 83 // FIXME: This has to be last because of crbug.com/401397.
81 // A WorkerThread might get deleted before it had a chance to properly 84 // A WorkerThread might get deleted before it had a chance to properly
82 // shut down. By deleting the WebThread first, we can guarantee that 85 // shut down. By deleting the WebThread first, we can guarantee that
83 // no pending tasks on the thread might want to access any of the other 86 // no pending tasks on the thread might want to access any of the other
84 // members during the WorkerThread's destruction. 87 // members during the WorkerThread's destruction.
85 OwnPtr<WebThread> m_thread; 88 WebThreadPtr *m_thread;
86 }; 89 };
87 90
88 } 91 }
89 92
90 #endif 93 #endif
OLDNEW
« no previous file with comments | « Source/platform/WebThreadRawPtr.h ('k') | Source/platform/WebThreadSupportingGC.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698