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

Unified Diff: third_party/WebKit/Source/modules/websockets/WorkerWebSocketChannel.h

Issue 2025783002: Worker: Introduce an observation mechanism for WorkerThread termination (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@delayed_task
Patch Set: Stop tracing CrossThread(Weak)Persistents Created 4 years, 6 months 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 side-by-side diff with in-line comments
Download patch
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..1e2f3b5e7e6a494cb9e25d86a2386069ced5e2b0 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,16 +84,16 @@ 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.
+ 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.
- void initialize(PassOwnPtr<SourceLocation>, ExecutionContext*);
+ bool initialize(PassOwnPtr<SourceLocation>, ExecutionContext*);
void connect(const KURL&, const String& protocol);
void sendTextAsCharVector(PassOwnPtr<Vector<char>>);
@@ -113,8 +114,11 @@ public:
void didClose(ClosingHandshakeCompletionStatus, unsigned short code, const String& reason) override;
void didError() override;
+ // WorkerThreadLifecycleObserver function.
+ void contextDestroyed() override;
+
private:
- Member<Bridge> m_bridge;
+ CrossThreadWeakPersistent<Bridge> m_bridge;
haraken 2016/06/10 00:45:36 This changes the lifetime semantics. Before, it wa
yhirano 2016/06/10 01:54:05 It's intended. Previously Bridge and Peer referenc
RefPtr<WorkerLoaderProxy> m_loaderProxy;
Member<WebSocketChannel> m_mainWebSocketChannel;
Member<WebSocketChannelSyncHelper> m_syncHelper;
@@ -136,6 +140,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 +155,7 @@ public:
Member<WorkerGlobalScope> m_workerGlobalScope;
RefPtr<WorkerLoaderProxy> m_loaderProxy;
Member<WebSocketChannelSyncHelper> m_syncHelper;
- Member<Peer> m_peer;
+ CrossThreadPersistent<Peer> m_peer;
};
private:

Powered by Google App Engine
This is Rietveld 408576698