Chromium Code Reviews| Index: third_party/WebKit/Source/modules/websockets/WorkerWebSocketChannel.h |
| diff --git a/third_party/WebKit/Source/modules/websockets/WorkerWebSocketChannel.h b/third_party/WebKit/Source/modules/websockets/WorkerWebSocketChannel.h |
| index 2e9cf96b263a16a41766da9a44797008aa58374b..57ff375d7550e76450bd9421456befe17673cf88 100644 |
| --- a/third_party/WebKit/Source/modules/websockets/WorkerWebSocketChannel.h |
| +++ b/third_party/WebKit/Source/modules/websockets/WorkerWebSocketChannel.h |
| @@ -32,6 +32,7 @@ |
| #define WorkerWebSocketChannel_h |
| #include "bindings/core/v8/SourceLocation.h" |
| +#include "core/workers/WorkerThreadLifecycleObserver.h" |
| #include "modules/websockets/WebSocketChannel.h" |
| #include "modules/websockets/WebSocketChannelClient.h" |
| #include "platform/heap/Handle.h" |
| @@ -83,12 +84,13 @@ public: |
| DECLARE_VIRTUAL_TRACE(); |
| class Bridge; |
| - // Allocated in the worker thread, but used in the main thread. |
| - class Peer final : public GarbageCollectedFinalized<Peer>, public WebSocketChannelClient { |
| + // Allocated and used in the main thread, but destructed in the worker |
|
yhirano
2016/06/09 04:55:13
|Peer| is an on-heap class so it will be destructe
nhiroki
2016/06/09 07:37:07
Done.
|
| + // thread. |
| + class Peer final : public GarbageCollectedFinalized<Peer>, public WebSocketChannelClient, public WorkerThreadLifecycleObserver { |
| USING_GARBAGE_COLLECTED_MIXIN(Peer); |
| WTF_MAKE_NONCOPYABLE(Peer); |
| public: |
| - Peer(Bridge*, PassRefPtr<WorkerLoaderProxy>, WebSocketChannelSyncHelper*); |
| + Peer(Bridge*, PassRefPtr<WorkerLoaderProxy>, WebSocketChannelSyncHelper*, WorkerThreadContext*); |
| ~Peer() override; |
| // SourceLocation parameter may be shown when the connection fails. |
| @@ -113,6 +115,9 @@ public: |
| void didClose(ClosingHandshakeCompletionStatus, unsigned short code, const String& reason) override; |
| void didError() override; |
| + // WorkerThreadLifecycleObserver function. |
| + void contextDestroyed() override; |
| + |
| private: |
| Member<Bridge> m_bridge; |
|
yhirano
2016/06/09 04:55:13
If you use CrossThreadPersistent in Member, this s
nhiroki
2016/06/09 07:37:07
Done.
|
| RefPtr<WorkerLoaderProxy> m_loaderProxy; |
| @@ -136,6 +141,8 @@ public: |
| void fail(const String& reason, MessageLevel, PassOwnPtr<SourceLocation>); |
| void disconnect(); |
| + void createPeerOnMainThread(PassOwnPtr<SourceLocation>, WorkerThreadContext*, ExecutionContext*); |
| + |
| // Returns null when |disconnect| has already been called. |
| WebSocketChannelClient* client() { return m_client; } |
| @@ -149,7 +156,7 @@ public: |
| Member<WorkerGlobalScope> m_workerGlobalScope; |
| RefPtr<WorkerLoaderProxy> m_loaderProxy; |
| Member<WebSocketChannelSyncHelper> m_syncHelper; |
| - Member<Peer> m_peer; |
| + CrossThreadPersistent<Peer> m_peer; |
| }; |
| private: |