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

Side by Side Diff: content/renderer/shared_worker/websharedworker_proxy.h

Issue 2627123003: SharedWorker: Simplify connection sequence (Closed)
Patch Set: maybe fix win compile failures Created 3 years, 11 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 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 CONTENT_RENDERER_SHARED_WORKER_WEBSHAREDWORKER_PROXY_H_ 5 #ifndef CONTENT_RENDERER_SHARED_WORKER_WEBSHAREDWORKER_PROXY_H_
6 #define CONTENT_RENDERER_SHARED_WORKER_WEBSHAREDWORKER_PROXY_H_ 6 #define CONTENT_RENDERER_SHARED_WORKER_WEBSHAREDWORKER_PROXY_H_
7 7
8 #include <string>
9 #include <vector>
10
11 #include "base/compiler_specific.h"
12 #include "base/macros.h" 8 #include "base/macros.h"
13 #include "ipc/ipc_listener.h" 9 #include "ipc/ipc_listener.h"
14 #include "third_party/WebKit/public/web/WebSharedWorkerConnector.h" 10 #include "third_party/WebKit/public/web/WebSharedWorkerConnectListener.h"
11 #include "third_party/WebKit/public/web/WebSharedWorkerCreationErrors.h"
12
13 struct ViewHostMsg_CreateWorker_Params;
14
15 namespace blink {
16 class WebMessagePortChannel;
17 class WebSharedWorkerConnectListener;
18 }
15 19
16 namespace IPC { 20 namespace IPC {
17 class MessageRouter; 21 class MessageRouter;
18 } 22 }
19 23
20 namespace content { 24 namespace content {
21 25
22 // Implementation of the WebSharedWorker APIs. This object is intended to only 26 // Implementation of the WebSharedWorker APIs. This object is intended to only
23 // live long enough to allow the caller to send a "connect" event to the worker 27 // live long enough to allow the caller to send a "connect" event to the worker
24 // thread. Once the connect event has been sent, all future communication will 28 // thread. Once the connect event has been sent, all future communication will
25 // happen via the WebMessagePortChannel, and the WebSharedWorker instance will 29 // happen via the WebMessagePortChannel. This instance will self-destruct when a
26 // be freed. 30 // connection is established.
27 class WebSharedWorkerProxy : public blink::WebSharedWorkerConnector, 31 class WebSharedWorkerProxy : private IPC::Listener {
28 private IPC::Listener {
29 public: 32 public:
30 WebSharedWorkerProxy(IPC::MessageRouter* router, int route_id); 33 explicit WebSharedWorkerProxy(
34 std::unique_ptr<blink::WebSharedWorkerConnectListener> listener);
31 ~WebSharedWorkerProxy() override; 35 ~WebSharedWorkerProxy() override;
32 36
33 // Implementations of WebSharedWorkerConnector APIs 37 // This is expected to be called immediately after this proxy is constructed.
kinuko 2017/01/18 09:13:30 Can the work for connect be done in the ctor? The
nhiroki 2017/01/18 09:38:03 Done. (Generally I'd prefer only to do initializa
34 void connect(blink::WebMessagePortChannel* channel, 38 // |channel| should be passed with its ownership.
35 ConnectListener* listener) override; 39 void connect(ViewHostMsg_CreateWorker_Params params,
40 blink::WebMessagePortChannel* channel);
36 41
37 private: 42 private:
38 // IPC::Listener implementation. 43 // IPC::Listener implementation.
39 bool OnMessageReceived(const IPC::Message& message) override; 44 bool OnMessageReceived(const IPC::Message& message) override;
40 45
41 void OnWorkerCreated(); 46 void OnWorkerCreated();
42 void OnWorkerScriptLoadFailed(); 47 void OnWorkerScriptLoadFailed();
43 void OnWorkerConnected(); 48 void OnWorkerConnected();
44 49
45 // Routing id associated with this worker - used to receive messages from the 50 // Routing id associated with this worker - used to receive messages from the
46 // worker, and also to route messages to the worker (WorkerService contains 51 // worker, and also to route messages to the worker (WorkerService contains
47 // a map that maps between these renderer-side route IDs and worker-side 52 // a map that maps between these renderer-side route IDs and worker-side
48 // routing ids). 53 // routing ids).
49 const int route_id_; 54 int route_id_;
50 55
51 IPC::MessageRouter* const router_; 56 IPC::MessageRouter* const router_;
52 57
53 int message_port_id_; 58 int message_port_id_;
54 ConnectListener* connect_listener_; 59 std::unique_ptr<blink::WebSharedWorkerConnectListener> listener_;
55 60
56 DISALLOW_COPY_AND_ASSIGN(WebSharedWorkerProxy); 61 DISALLOW_COPY_AND_ASSIGN(WebSharedWorkerProxy);
57 }; 62 };
58 63
59 } // namespace content 64 } // namespace content
60 65
61 #endif // CONTENT_RENDERER_SHARED_WORKER_WEBSHAREDWORKER_PROXY_H_ 66 #endif // CONTENT_RENDERER_SHARED_WORKER_WEBSHAREDWORKER_PROXY_H_
OLDNEW
« no previous file with comments | « content/renderer/shared_worker/shared_worker_repository.cc ('k') | content/renderer/shared_worker/websharedworker_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698