OLD | NEW |
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/WebTaskRunner.h" | 8 #include "platform/WebTaskRunner.h" |
9 #include "platform/heap/GCTaskRunner.h" | 9 #include "platform/heap/GCTaskRunner.h" |
10 #include "public/platform/Platform.h" | 10 #include "public/platform/Platform.h" |
(...skipping 11 matching lines...) Expand all Loading... |
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 // | 24 // |
25 // WebThreadSupportingGC usually internally creates and owns WebThread unless | 25 // WebThreadSupportingGC usually internally creates and owns WebThread unless |
26 // an existing WebThread is given via createForThread. | 26 // an existing WebThread is given via createForThread. |
27 class PLATFORM_EXPORT WebThreadSupportingGC final { | 27 class PLATFORM_EXPORT WebThreadSupportingGC final { |
28 USING_FAST_MALLOC(WebThreadSupportingGC); | 28 USING_FAST_MALLOC(WebThreadSupportingGC); |
29 WTF_MAKE_NONCOPYABLE(WebThreadSupportingGC); | 29 WTF_MAKE_NONCOPYABLE(WebThreadSupportingGC); |
30 | 30 |
31 public: | 31 public: |
32 static std::unique_ptr<WebThreadSupportingGC> create(const char* name, | 32 static std::unique_ptr<WebThreadSupportingGC> create(const char* name); |
33 BlinkGC::ThreadHeapMode); | 33 static std::unique_ptr<WebThreadSupportingGC> createForThread(WebThread*); |
34 static std::unique_ptr<WebThreadSupportingGC> createForThread( | |
35 WebThread*, | |
36 BlinkGC::ThreadHeapMode); | |
37 ~WebThreadSupportingGC(); | 34 ~WebThreadSupportingGC(); |
38 | 35 |
39 void postTask(const WebTraceLocation& location, | 36 void postTask(const WebTraceLocation& location, |
40 std::unique_ptr<WTF::Closure> task) { | 37 std::unique_ptr<WTF::Closure> task) { |
41 m_thread->getWebTaskRunner()->postTask(location, std::move(task)); | 38 m_thread->getWebTaskRunner()->postTask(location, std::move(task)); |
42 } | 39 } |
43 | 40 |
44 void postDelayedTask(const WebTraceLocation& location, | 41 void postDelayedTask(const WebTraceLocation& location, |
45 std::unique_ptr<WTF::Closure> task, | 42 std::unique_ptr<WTF::Closure> task, |
46 long long delayMs) { | 43 long long delayMs) { |
(...skipping 25 matching lines...) Expand all Loading... |
72 | 69 |
73 void initialize(); | 70 void initialize(); |
74 void shutdown(); | 71 void shutdown(); |
75 | 72 |
76 WebThread& platformThread() const { | 73 WebThread& platformThread() const { |
77 ASSERT(m_thread); | 74 ASSERT(m_thread); |
78 return *m_thread; | 75 return *m_thread; |
79 } | 76 } |
80 | 77 |
81 private: | 78 private: |
82 WebThreadSupportingGC(const char* name, WebThread*, BlinkGC::ThreadHeapMode); | 79 WebThreadSupportingGC(const char* name, WebThread*); |
83 | 80 |
84 std::unique_ptr<GCTaskRunner> m_gcTaskRunner; | 81 std::unique_ptr<GCTaskRunner> m_gcTaskRunner; |
85 | 82 |
86 // m_thread is guaranteed to be non-null after this instance is constructed. | 83 // m_thread is guaranteed to be non-null after this instance is constructed. |
87 // m_owningThread is non-null unless this instance is constructed for an | 84 // m_owningThread is non-null unless this instance is constructed for an |
88 // existing thread via createForThread(). | 85 // existing thread via createForThread(). |
89 WebThread* m_thread = nullptr; | 86 WebThread* m_thread = nullptr; |
90 std::unique_ptr<WebThread> m_owningThread; | 87 std::unique_ptr<WebThread> m_owningThread; |
91 const BlinkGC::ThreadHeapMode m_threadHeapMode; | |
92 }; | 88 }; |
93 | 89 |
94 } // namespace blink | 90 } // namespace blink |
95 | 91 |
96 #endif | 92 #endif |
OLD | NEW |