| 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/heap/GCTaskRunner.h" | 8 #include "platform/heap/GCTaskRunner.h" |
| 9 #include "public/platform/Platform.h" | 9 #include "public/platform/Platform.h" |
| 10 #include "public/platform/WebTaskRunner.h" | 10 #include "public/platform/WebTaskRunner.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 // | 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 WTF_MAKE_NONCOPYABLE(WebThreadSupportingGC); | 28 WTF_MAKE_NONCOPYABLE(WebThreadSupportingGC); |
| 29 public: | 29 public: |
| 30 static PassOwnPtr<WebThreadSupportingGC> create(const char* name); | 30 static PassOwnPtr<WebThreadSupportingGC> create(const char* name, bool isola
ted=false); |
| 31 static PassOwnPtr<WebThreadSupportingGC> createForThread(WebThread*); | 31 static PassOwnPtr<WebThreadSupportingGC> createForThread(WebThread*, bool is
olated=false); |
| 32 ~WebThreadSupportingGC(); | 32 ~WebThreadSupportingGC(); |
| 33 | 33 |
| 34 void postTask(const WebTraceLocation& location, WebTaskRunner::Task* task) | 34 void postTask(const WebTraceLocation& location, WebTaskRunner::Task* task) |
| 35 { | 35 { |
| 36 m_thread->taskRunner()->postTask(location, task); | 36 m_thread->taskRunner()->postTask(location, task); |
| 37 } | 37 } |
| 38 | 38 |
| 39 void postDelayedTask(const WebTraceLocation& location, WebTaskRunner::Task*
task, long long delayMs) | 39 void postDelayedTask(const WebTraceLocation& location, WebTaskRunner::Task*
task, long long delayMs) |
| 40 { | 40 { |
| 41 m_thread->taskRunner()->postDelayedTask(location, task, delayMs); | 41 m_thread->taskRunner()->postDelayedTask(location, task, delayMs); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 59 void initialize(); | 59 void initialize(); |
| 60 void shutdown(); | 60 void shutdown(); |
| 61 | 61 |
| 62 WebThread& platformThread() const | 62 WebThread& platformThread() const |
| 63 { | 63 { |
| 64 ASSERT(m_thread); | 64 ASSERT(m_thread); |
| 65 return *m_thread; | 65 return *m_thread; |
| 66 } | 66 } |
| 67 | 67 |
| 68 private: | 68 private: |
| 69 WebThreadSupportingGC(const char* name, WebThread*); | 69 WebThreadSupportingGC(const char* name, WebThread*, bool isolated=false); |
| 70 | 70 |
| 71 OwnPtr<GCTaskRunner> m_gcTaskRunner; | 71 OwnPtr<GCTaskRunner> m_gcTaskRunner; |
| 72 | 72 |
| 73 // m_thread is guaranteed to be non-null after this instance is constructed. | 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 | 74 // m_owningThread is non-null unless this instance is constructed for an |
| 75 // existing thread via createForThread(). | 75 // existing thread via createForThread(). |
| 76 WebThread* m_thread = nullptr; | 76 WebThread* m_thread = nullptr; |
| 77 OwnPtr<WebThread> m_owningThread; | 77 OwnPtr<WebThread> m_owningThread; |
| 78 bool m_isolated; |
| 78 }; | 79 }; |
| 79 | 80 |
| 80 } | 81 } |
| 81 | 82 |
| 82 #endif | 83 #endif |
| OLD | NEW |