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

Side by Side Diff: Source/modules/websockets/WorkerWebSocketChannel.h

Issue 887463003: Turn WorkerLoaderProxy into a threadsafe, ref-counted object. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Clarify WorkerLoaderProxyProvider's obligations on shutdown Created 5 years, 10 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 virtual void disconnect() override; // Will suppress didClose(). 76 virtual void disconnect() override; // Will suppress didClose().
77 77
78 virtual void trace(Visitor*) override; 78 virtual void trace(Visitor*) override;
79 79
80 class Bridge; 80 class Bridge;
81 // Allocated in the worker thread, but used in the main thread. 81 // Allocated in the worker thread, but used in the main thread.
82 class Peer final : public GarbageCollectedFinalized<Peer>, public WebSocketC hannelClient { 82 class Peer final : public GarbageCollectedFinalized<Peer>, public WebSocketC hannelClient {
83 USING_GARBAGE_COLLECTED_MIXIN(Peer); 83 USING_GARBAGE_COLLECTED_MIXIN(Peer);
84 WTF_MAKE_NONCOPYABLE(Peer); 84 WTF_MAKE_NONCOPYABLE(Peer);
85 public: 85 public:
86 Peer(Bridge*, WorkerLoaderProxy&, WebSocketChannelSyncHelper*); 86 Peer(Bridge*, PassRefPtr<WorkerLoaderProxy>, WebSocketChannelSyncHelper* );
87 virtual ~Peer(); 87 virtual ~Peer();
88 88
89 // sourceURLAtConnection and lineNumberAtConnection parameters may 89 // sourceURLAtConnection and lineNumberAtConnection parameters may
90 // be shown when the connection fails. 90 // be shown when the connection fails.
91 static void initialize(ExecutionContext* executionContext, Peer* peer, c onst String& sourceURLAtConnection, unsigned lineNumberAtConnection) 91 static void initialize(ExecutionContext* executionContext, Peer* peer, c onst String& sourceURLAtConnection, unsigned lineNumberAtConnection)
92 { 92 {
93 peer->initializeInternal(executionContext, sourceURLAtConnection, li neNumberAtConnection); 93 peer->initializeInternal(executionContext, sourceURLAtConnection, li neNumberAtConnection);
94 } 94 }
95 95
96 void connect(const KURL&, const String& protocol); 96 void connect(const KURL&, const String& protocol);
(...skipping 12 matching lines...) Expand all
109 virtual void didReceiveBinaryMessage(PassOwnPtr<Vector<char>>) override; 109 virtual void didReceiveBinaryMessage(PassOwnPtr<Vector<char>>) override;
110 virtual void didConsumeBufferedAmount(uint64_t) override; 110 virtual void didConsumeBufferedAmount(uint64_t) override;
111 virtual void didStartClosingHandshake() override; 111 virtual void didStartClosingHandshake() override;
112 virtual void didClose(ClosingHandshakeCompletionStatus, unsigned short c ode, const String& reason) override; 112 virtual void didClose(ClosingHandshakeCompletionStatus, unsigned short c ode, const String& reason) override;
113 virtual void didError() override; 113 virtual void didError() override;
114 114
115 private: 115 private:
116 void initializeInternal(ExecutionContext*, const String& sourceURLAtConn ection, unsigned lineNumberAtConnection); 116 void initializeInternal(ExecutionContext*, const String& sourceURLAtConn ection, unsigned lineNumberAtConnection);
117 117
118 Member<Bridge> m_bridge; 118 Member<Bridge> m_bridge;
119 WorkerLoaderProxy& m_loaderProxy; 119 RefPtr<WorkerLoaderProxy> m_loaderProxy;
120 Member<WebSocketChannel> m_mainWebSocketChannel; 120 Member<WebSocketChannel> m_mainWebSocketChannel;
121 Member<WebSocketChannelSyncHelper> m_syncHelper; 121 Member<WebSocketChannelSyncHelper> m_syncHelper;
122 }; 122 };
123 123
124 // Bridge for Peer. Running on the worker thread. 124 // Bridge for Peer. Running on the worker thread.
125 class Bridge final : public GarbageCollectedFinalized<Bridge> { 125 class Bridge final : public GarbageCollectedFinalized<Bridge> {
126 WTF_MAKE_NONCOPYABLE(Bridge); 126 WTF_MAKE_NONCOPYABLE(Bridge);
127 public: 127 public:
128 Bridge(WebSocketChannelClient*, WorkerGlobalScope&); 128 Bridge(WebSocketChannelClient*, WorkerGlobalScope&);
129 ~Bridge(); 129 ~Bridge();
(...skipping 12 matching lines...) Expand all
142 WebSocketChannelClient* client() { return m_client; } 142 WebSocketChannelClient* client() { return m_client; }
143 143
144 void trace(Visitor*); 144 void trace(Visitor*);
145 145
146 private: 146 private:
147 // Returns false if shutdown event is received before method completion. 147 // Returns false if shutdown event is received before method completion.
148 bool waitForMethodCompletion(PassOwnPtr<ExecutionContextTask>); 148 bool waitForMethodCompletion(PassOwnPtr<ExecutionContextTask>);
149 149
150 Member<WebSocketChannelClient> m_client; 150 Member<WebSocketChannelClient> m_client;
151 RefPtrWillBeMember<WorkerGlobalScope> m_workerGlobalScope; 151 RefPtrWillBeMember<WorkerGlobalScope> m_workerGlobalScope;
152 WorkerLoaderProxy& m_loaderProxy; 152 RefPtr<WorkerLoaderProxy> m_loaderProxy;
153 Member<WebSocketChannelSyncHelper> m_syncHelper; 153 Member<WebSocketChannelSyncHelper> m_syncHelper;
154 Member<Peer> m_peer; 154 Member<Peer> m_peer;
155 }; 155 };
156 156
157 private: 157 private:
158 WorkerWebSocketChannel(WorkerGlobalScope&, WebSocketChannelClient*, const St ring& sourceURL, unsigned lineNumber); 158 WorkerWebSocketChannel(WorkerGlobalScope&, WebSocketChannelClient*, const St ring& sourceURL, unsigned lineNumber);
159 159
160 Member<Bridge> m_bridge; 160 Member<Bridge> m_bridge;
161 String m_sourceURLAtConnection; 161 String m_sourceURLAtConnection;
162 unsigned m_lineNumberAtConnection; 162 unsigned m_lineNumberAtConnection;
163 }; 163 };
164 164
165 } // namespace blink 165 } // namespace blink
166 166
167 #endif // WorkerWebSocketChannel_h 167 #endif // WorkerWebSocketChannel_h
OLDNEW
« no previous file with comments | « Source/modules/serviceworkers/ServiceWorkerThread.cpp ('k') | Source/modules/websockets/WorkerWebSocketChannel.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698