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

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

Issue 2627123003: SharedWorker: Simplify connection sequence (Closed)
Patch Set: remove unnecessary forward declaration 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 }
15 18
16 namespace IPC { 19 namespace IPC {
17 class MessageRouter; 20 class MessageRouter;
18 } 21 }
19 22
20 namespace content { 23 namespace content {
21 24
22 // Implementation of the WebSharedWorker APIs. This object is intended to only 25 // 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 26 // 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 27 // thread. Once the connect event has been sent, all future communication will
25 // happen via the WebMessagePortChannel, and the WebSharedWorker instance will 28 // happen via the WebMessagePortChannel. This instance will self-destruct when a
26 // be freed. 29 // connection is established.
27 class WebSharedWorkerProxy : public blink::WebSharedWorkerConnector, 30 class WebSharedWorkerProxy : private IPC::Listener {
28 private IPC::Listener {
29 public: 31 public:
30 WebSharedWorkerProxy(IPC::MessageRouter* router, int route_id); 32 // |channel| should be passed with its ownership.
33 WebSharedWorkerProxy(
34 std::unique_ptr<blink::WebSharedWorkerConnectListener> listener,
35 ViewHostMsg_CreateWorker_Params params,
36 blink::WebMessagePortChannel* channel);
31 ~WebSharedWorkerProxy() override; 37 ~WebSharedWorkerProxy() override;
32 38
33 // Implementations of WebSharedWorkerConnector APIs 39 private:
34 void connect(blink::WebMessagePortChannel* channel, 40 void connect(ViewHostMsg_CreateWorker_Params params,
35 ConnectListener* listener) override; 41 blink::WebMessagePortChannel* channel);
36 42
37 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