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

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

Issue 2600113003: (SUSPENDED) SharedWorker: Mojofy Renderer(Document)->Browser communication for SharedWorker
Patch Set: 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_WEBSHAREDWORKER_PROXY_H_ 5 #ifndef CONTENT_RENDERER_WEBSHAREDWORKER_PROXY_H_
6 #define CONTENT_RENDERER_WEBSHAREDWORKER_PROXY_H_ 6 #define CONTENT_RENDERER_WEBSHAREDWORKER_PROXY_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "content/common/shared_worker.mojom.h"
13 #include "ipc/ipc_listener.h" 14 #include "ipc/ipc_listener.h"
14 #include "third_party/WebKit/public/web/WebSharedWorkerConnector.h" 15 #include "third_party/WebKit/public/web/WebSharedWorkerConnector.h"
15 #include "url/gurl.h" 16 #include "url/gurl.h"
16 17
17 namespace IPC { 18 namespace IPC {
18 class MessageRouter; 19 class MessageRouter;
19 } 20 }
20 21
21 namespace content { 22 namespace content {
22 23
23 // Implementation of the WebSharedWorker APIs. This object is intended to only 24 // Implementation of the WebSharedWorker APIs. This object is intended to only
24 // live long enough to allow the caller to send a "connect" event to the worker 25 // live long enough to allow the caller to send a "connect" event to the worker
25 // thread. Once the connect event has been sent, all future communication will 26 // thread. Once the connect event has been sent, all future communication will
26 // happen via the WebMessagePortChannel, and the WebSharedWorker instance will 27 // happen via the WebMessagePortChannel, and the WebSharedWorker instance will
27 // be freed. 28 // be freed.
28 class WebSharedWorkerProxy : public blink::WebSharedWorkerConnector, 29 class WebSharedWorkerProxy : public blink::WebSharedWorkerConnector,
29 private IPC::Listener { 30 private IPC::Listener {
30 public: 31 public:
31 // If the worker not loaded yet, route_id == MSG_ROUTING_NONE 32 // If the worker not loaded yet, route_id == MSG_ROUTING_NONE
kinuko 2017/01/05 08:13:14 (Would be nice to rebase)
nhiroki 2017/01/10 08:44:06 Done.
32 WebSharedWorkerProxy(IPC::MessageRouter* router, int route_id); 33 explicit WebSharedWorkerProxy(int route_id);
33 ~WebSharedWorkerProxy() override; 34 ~WebSharedWorkerProxy() override;
34 35
35 // Implementations of WebSharedWorkerConnector APIs 36 // Implementations of WebSharedWorkerConnector APIs
36 void connect(blink::WebMessagePortChannel* channel, 37 void connect(blink::WebMessagePortChannel* channel,
37 ConnectListener* listener) override; 38 ConnectListener* listener) override;
38 39
39 private: 40 private:
40 // IPC::Listener implementation. 41 // IPC::Listener implementation.
41 bool OnMessageReceived(const IPC::Message& message) override; 42 bool OnMessageReceived(const IPC::Message& message) override;
42 43
43 // Disconnects the worker (stops listening for incoming messages). 44 // Disconnects the worker (stops listening for incoming messages).
44 void Disconnect(); 45 void Disconnect();
45 46
46 // Sends a message to the worker thread (forwarded via the RenderViewHost). 47 // Sends a message to the worker thread (forwarded via the RenderViewHost).
47 // If WorkerStarted() has not yet been called, message is queued. 48 // If WorkerStarted() has not yet been called, message is queued.
48 bool Send(std::unique_ptr<IPC::Message> message); 49 bool Send(int message_port_id);
shimazu 2017/01/05 02:24:03 How about renaming to TryToSendConnectToWorker to
nhiroki 2017/01/10 08:44:06 This function was removed by other cleanup CLs.
49 50
50 // Sends any messages currently in the queue. 51 // Sends any messages currently in the queue.
51 void SendQueuedMessages(); 52 void SendQueuedMessages();
52 53
53 void OnWorkerCreated(); 54 void OnWorkerCreated();
54 void OnWorkerScriptLoadFailed(); 55 void OnWorkerScriptLoadFailed();
55 void OnWorkerConnected(); 56 void OnWorkerConnected();
56 57
57 // Routing id associated with this worker - used to receive messages from the 58 // Routing id associated with this worker - used to receive messages from the
58 // worker, and also to route messages to the worker (WorkerService contains 59 // worker, and also to route messages to the worker (WorkerService contains
59 // a map that maps between these renderer-side route IDs and worker-side 60 // a map that maps between these renderer-side route IDs and worker-side
60 // routing ids). 61 // routing ids).
61 int route_id_; 62 int route_id_;
62 63
63 IPC::MessageRouter* const router_; 64 IPC::MessageRouter* const router_;
64 65
65 // Stores messages that were sent before the StartWorkerContext message. 66 // Stores messages that were sent before the StartWorkerContext message.
66 std::vector<std::unique_ptr<IPC::Message>> queued_messages_; 67 std::vector<int> queued_messages_;
shimazu 2017/01/05 02:24:03 I prefer |queued_connect_request_| or something to
nhiroki 2017/01/10 08:44:06 Queuing mechanism was removed by other cleanup CLs
68
69 mojom::SharedWorkerMessageFilterAssociatedPtr message_filter_;
67 70
68 ConnectListener* connect_listener_; 71 ConnectListener* connect_listener_;
69 bool created_; 72 bool created_;
70 73
71 DISALLOW_COPY_AND_ASSIGN(WebSharedWorkerProxy); 74 DISALLOW_COPY_AND_ASSIGN(WebSharedWorkerProxy);
72 }; 75 };
73 76
74 } // namespace content 77 } // namespace content
75 78
76 #endif // CONTENT_RENDERER_WEBSHAREDWORKER_PROXY_H_ 79 #endif // CONTENT_RENDERER_WEBSHAREDWORKER_PROXY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698