| 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/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 class PLATFORM_EXPORT GCSupportForWebThread final { |
| 19 public: |
| 20 static PassOwnPtr<GCSupportForWebThread> create(WebThread&); |
| 21 ~GCSupportForWebThread(); |
| 22 |
| 23 private: |
| 24 explicit GCSupportForWebThread(WebThread&); |
| 25 WebThread& m_thread; |
| 26 OwnPtr<PendingGCRunner> m_pendingGCRunner; |
| 27 }; |
| 28 |
| 18 // WebThreadSupportingGC wraps a WebThread and adds support for attaching | 29 // WebThreadSupportingGC wraps a WebThread and adds support for attaching |
| 19 // to and detaching from the Blink GC infrastructure. The initialize method | 30 // to and detaching from the Blink GC infrastructure. The initialize method |
| 20 // must be called during initialization on the WebThread and before the | 31 // must be called during initialization on the WebThread and before the |
| 21 // thread allocates any objects managed by the Blink GC. The shutdown | 32 // thread allocates any objects managed by the Blink GC. The shutdown |
| 22 // method must be called on the WebThread during shutdown when the thread | 33 // method must be called on the WebThread during shutdown when the thread |
| 23 // no longer needs to access objects managed by the Blink GC. | 34 // no longer needs to access objects managed by the Blink GC. |
| 24 class PLATFORM_EXPORT WebThreadSupportingGC final { | 35 class PLATFORM_EXPORT WebThreadSupportingGC final { |
| 25 WTF_MAKE_NONCOPYABLE(WebThreadSupportingGC); | 36 WTF_MAKE_NONCOPYABLE(WebThreadSupportingGC); |
| 26 public: | 37 public: |
| 27 static PassOwnPtr<WebThreadSupportingGC> create(const char*); | 38 static PassOwnPtr<WebThreadSupportingGC> create(const char*); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 57 | 68 |
| 58 WebThread& platformThread() const | 69 WebThread& platformThread() const |
| 59 { | 70 { |
| 60 ASSERT(m_thread); | 71 ASSERT(m_thread); |
| 61 return *m_thread; | 72 return *m_thread; |
| 62 } | 73 } |
| 63 | 74 |
| 64 private: | 75 private: |
| 65 explicit WebThreadSupportingGC(const char*); | 76 explicit WebThreadSupportingGC(const char*); |
| 66 | 77 |
| 67 OwnPtr<PendingGCRunner> m_pendingGCRunner; | 78 OwnPtr<GCSupportForWebThread> m_gcSupport; |
| 68 | 79 |
| 69 // FIXME: This has to be last because of crbug.com/401397. | 80 // FIXME: This has to be last because of crbug.com/401397. |
| 70 // A WorkerThread might get deleted before it had a chance to properly | 81 // A WorkerThread might get deleted before it had a chance to properly |
| 71 // shut down. By deleting the WebThread first, we can guarantee that | 82 // shut down. By deleting the WebThread first, we can guarantee that |
| 72 // no pending tasks on the thread might want to access any of the other | 83 // no pending tasks on the thread might want to access any of the other |
| 73 // members during the WorkerThread's destruction. | 84 // members during the WorkerThread's destruction. |
| 74 OwnPtr<WebThread> m_thread; | 85 OwnPtr<WebThread> m_thread; |
| 75 }; | 86 }; |
| 76 | 87 |
| 77 } | 88 } |
| 78 | 89 |
| 79 #endif | 90 #endif |
| OLD | NEW |