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

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

Issue 2840473002: Worker: Remove WorkerLoaderProxy for clean-up (Closed)
Patch Set: wip Created 3 years, 7 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #include "platform/wtf/text/WTFString.h" 46 #include "platform/wtf/text/WTFString.h"
47 #include "public/platform/WebTraceLocation.h" 47 #include "public/platform/WebTraceLocation.h"
48 48
49 namespace blink { 49 namespace blink {
50 50
51 class BlobDataHandle; 51 class BlobDataHandle;
52 class KURL; 52 class KURL;
53 class ThreadableLoadingContext; 53 class ThreadableLoadingContext;
54 class WebSocketChannelSyncHelper; 54 class WebSocketChannelSyncHelper;
55 class WorkerGlobalScope; 55 class WorkerGlobalScope;
56 class WorkerLoaderProxy;
57 56
58 class WorkerWebSocketChannel final : public WebSocketChannel { 57 class WorkerWebSocketChannel final : public WebSocketChannel {
59 WTF_MAKE_NONCOPYABLE(WorkerWebSocketChannel); 58 WTF_MAKE_NONCOPYABLE(WorkerWebSocketChannel);
60 59
61 public: 60 public:
62 static WebSocketChannel* Create(WorkerGlobalScope& worker_global_scope, 61 static WebSocketChannel* Create(WorkerGlobalScope& worker_global_scope,
63 WebSocketChannelClient* client, 62 WebSocketChannelClient* client,
64 std::unique_ptr<SourceLocation> location) { 63 std::unique_ptr<SourceLocation> location) {
65 return new WorkerWebSocketChannel(worker_global_scope, client, 64 return new WorkerWebSocketChannel(worker_global_scope, client,
66 std::move(location)); 65 std::move(location));
(...skipping 24 matching lines...) Expand all
91 class Bridge; 90 class Bridge;
92 // Allocated and used in the main thread. 91 // Allocated and used in the main thread.
93 class Peer final : public GarbageCollectedFinalized<Peer>, 92 class Peer final : public GarbageCollectedFinalized<Peer>,
94 public WebSocketChannelClient, 93 public WebSocketChannelClient,
95 public WorkerThreadLifecycleObserver { 94 public WorkerThreadLifecycleObserver {
96 USING_GARBAGE_COLLECTED_MIXIN(Peer); 95 USING_GARBAGE_COLLECTED_MIXIN(Peer);
97 WTF_MAKE_NONCOPYABLE(Peer); 96 WTF_MAKE_NONCOPYABLE(Peer);
98 97
99 public: 98 public:
100 Peer(Bridge*, 99 Peer(Bridge*,
101 PassRefPtr<WorkerLoaderProxy>,
102 RefPtr<WebTaskRunner>, 100 RefPtr<WebTaskRunner>,
103 WorkerThreadLifecycleContext*); 101 WorkerThreadLifecycleContext*);
104 ~Peer() override; 102 ~Peer() override;
105 103
106 // SourceLocation parameter may be shown when the connection fails. 104 // SourceLocation parameter may be shown when the connection fails.
107 bool Initialize(std::unique_ptr<SourceLocation>, ThreadableLoadingContext*); 105 bool Initialize(std::unique_ptr<SourceLocation>, ThreadableLoadingContext*);
108 106
109 bool Connect(const KURL&, const String& protocol); 107 bool Connect(const KURL&, const String& protocol);
110 void SendTextAsCharVector(std::unique_ptr<Vector<char>>); 108 void SendTextAsCharVector(std::unique_ptr<Vector<char>>);
111 void SendBinaryAsCharVector(std::unique_ptr<Vector<char>>); 109 void SendBinaryAsCharVector(std::unique_ptr<Vector<char>>);
(...skipping 18 matching lines...) Expand all
130 void DidClose(ClosingHandshakeCompletionStatus, 128 void DidClose(ClosingHandshakeCompletionStatus,
131 unsigned short code, 129 unsigned short code,
132 const String& reason) override; 130 const String& reason) override;
133 void DidError() override; 131 void DidError() override;
134 132
135 // WorkerThreadLifecycleObserver function. 133 // WorkerThreadLifecycleObserver function.
136 void ContextDestroyed(WorkerThreadLifecycleContext*) override; 134 void ContextDestroyed(WorkerThreadLifecycleContext*) override;
137 135
138 private: 136 private:
139 CrossThreadWeakPersistent<Bridge> bridge_; 137 CrossThreadWeakPersistent<Bridge> bridge_;
140 RefPtr<WorkerLoaderProxy> loader_proxy_;
141 RefPtr<WebTaskRunner> worker_networking_task_runner_; 138 RefPtr<WebTaskRunner> worker_networking_task_runner_;
142 Member<WebSocketChannel> main_web_socket_channel_; 139 Member<WebSocketChannel> main_web_socket_channel_;
143 }; 140 };
144 141
145 // Bridge for Peer. Running on the worker thread. 142 // Bridge for Peer. Running on the worker thread.
146 class Bridge final : public GarbageCollectedFinalized<Bridge> { 143 class Bridge final : public GarbageCollectedFinalized<Bridge> {
147 WTF_MAKE_NONCOPYABLE(Bridge); 144 WTF_MAKE_NONCOPYABLE(Bridge);
148 145
149 public: 146 public:
150 Bridge(WebSocketChannelClient*, WorkerGlobalScope&); 147 Bridge(WebSocketChannelClient*, WorkerGlobalScope&);
151 ~Bridge(); 148 ~Bridge();
152 149
153 // SourceLocation parameter may be shown when the connection fails. 150 // SourceLocation parameter may be shown when the connection fails.
154 bool Connect(std::unique_ptr<SourceLocation>, 151 bool Connect(std::unique_ptr<SourceLocation>,
155 const KURL&, 152 const KURL&,
156 const String& protocol); 153 const String& protocol);
157 154
158 void Send(const CString& message); 155 void Send(const CString& message);
159 void Send(const DOMArrayBuffer&, 156 void Send(const DOMArrayBuffer&,
160 unsigned byte_offset, 157 unsigned byte_offset,
161 unsigned byte_length); 158 unsigned byte_length);
162 void Send(PassRefPtr<BlobDataHandle>); 159 void Send(PassRefPtr<BlobDataHandle>);
163 void Close(int code, const String& reason); 160 void Close(int code, const String& reason);
164 void Fail(const String& reason, 161 void Fail(const String& reason,
165 MessageLevel, 162 MessageLevel,
166 std::unique_ptr<SourceLocation>); 163 std::unique_ptr<SourceLocation>);
167 void Disconnect(); 164 void Disconnect();
168 165
169 void ConnectOnMainThread(std::unique_ptr<SourceLocation>, 166 void ConnectOnMainThread(std::unique_ptr<SourceLocation>,
170 RefPtr<WorkerLoaderProxy>, 167 ThreadableLoadingContext*,
171 RefPtr<WebTaskRunner>, 168 RefPtr<WebTaskRunner>,
172 WorkerThreadLifecycleContext*, 169 WorkerThreadLifecycleContext*,
173 const KURL&, 170 const KURL&,
174 const String& protocol, 171 const String& protocol,
175 WebSocketChannelSyncHelper*); 172 WebSocketChannelSyncHelper*);
176 173
177 // Returns null when |disconnect| has already been called. 174 // Returns null when |disconnect| has already been called.
178 WebSocketChannelClient* Client() { return client_; } 175 WebSocketChannelClient* Client() { return client_; }
179 176
180 DECLARE_TRACE(); 177 DECLARE_TRACE();
181 // Promptly clear connection to peer + loader proxy. 178 // Promptly clear connection to peer + loader proxy.
182 EAGERLY_FINALIZE(); 179 EAGERLY_FINALIZE();
183 180
184 private: 181 private:
185 Member<WebSocketChannelClient> client_; 182 Member<WebSocketChannelClient> client_;
186 Member<WorkerGlobalScope> worker_global_scope_; 183 Member<WorkerGlobalScope> worker_global_scope_;
187 RefPtr<WorkerLoaderProxy> loader_proxy_; 184 CrossThreadPersistent<ThreadableLoadingContext> loading_context_;
haraken 2017/04/25 16:53:43 Add a comment and mention that this is set on the
nhiroki 2017/05/29 04:20:24 Removed this field because it was unused.
188 CrossThreadPersistent<ParentFrameTaskRunners> parent_frame_task_runners_; 185 CrossThreadPersistent<ParentFrameTaskRunners> parent_frame_task_runners_;
189 CrossThreadPersistent<Peer> peer_; 186 CrossThreadPersistent<Peer> peer_;
190 }; 187 };
191 188
192 private: 189 private:
193 WorkerWebSocketChannel(WorkerGlobalScope&, 190 WorkerWebSocketChannel(WorkerGlobalScope&,
194 WebSocketChannelClient*, 191 WebSocketChannelClient*,
195 std::unique_ptr<SourceLocation>); 192 std::unique_ptr<SourceLocation>);
196 193
197 Member<Bridge> bridge_; 194 Member<Bridge> bridge_;
198 std::unique_ptr<SourceLocation> location_at_connection_; 195 std::unique_ptr<SourceLocation> location_at_connection_;
199 }; 196 };
200 197
201 } // namespace blink 198 } // namespace blink
202 199
203 #endif // WorkerWebSocketChannel_h 200 #endif // WorkerWebSocketChannel_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698