Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <vector> | |
| 9 | |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 9 #include "ipc/ipc_listener.h" | 11 #include "ipc/ipc_listener.h" |
| 10 #include "third_party/WebKit/public/web/WebSharedWorkerConnectListener.h" | 12 #include "third_party/WebKit/public/web/WebSharedWorkerConnectListener.h" |
| 11 #include "third_party/WebKit/public/web/WebSharedWorkerCreationErrors.h" | 13 #include "third_party/WebKit/public/web/WebSharedWorkerCreationErrors.h" |
| 12 | 14 |
| 13 struct ViewHostMsg_CreateWorker_Params; | 15 struct ViewHostMsg_CreateWorker_Params; |
| 14 | 16 |
| 15 namespace blink { | 17 namespace blink { |
| 16 class WebMessagePortChannel; | 18 class WebMessagePortChannel; |
| 17 } | 19 } |
| 18 | 20 |
| 19 namespace IPC { | 21 namespace IPC { |
| 20 class MessageRouter; | 22 class MessageRouter; |
| 21 } | 23 } |
| 22 | 24 |
| 23 namespace content { | 25 namespace content { |
| 24 | 26 |
| 25 // Implementation of the WebSharedWorker APIs. This object is intended to only | 27 // Implementation of the WebSharedWorker APIs. This object is intended to only |
| 26 // live long enough to allow the caller to send a "connect" event to the worker | 28 // live long enough to allow the caller to send a "connect" event to the worker |
| 27 // thread. Once the connect event has been sent, all future communication will | 29 // thread. Once the connect event has been sent, all future communication will |
| 28 // happen via the WebMessagePortChannel. This instance will self-destruct when a | 30 // happen via the WebMessagePortChannel. This instance will self-destruct when a |
| 29 // connection is established. | 31 // connection is established. |
|
kinuko
2017/01/24 13:56:31
The comment needs to be updated.
nhiroki
2017/01/25 10:16:11
Done.
| |
| 30 class WebSharedWorkerProxy : private IPC::Listener { | 32 class WebSharedWorkerProxy : private IPC::Listener { |
| 31 public: | 33 public: |
| 32 // |channel| should be passed with its ownership. | 34 // |channel| should be passed with its ownership. |
| 33 WebSharedWorkerProxy( | 35 WebSharedWorkerProxy( |
| 34 std::unique_ptr<blink::WebSharedWorkerConnectListener> listener, | 36 std::unique_ptr<blink::WebSharedWorkerConnectListener> listener, |
| 35 ViewHostMsg_CreateWorker_Params params, | 37 ViewHostMsg_CreateWorker_Params params, |
| 36 blink::WebMessagePortChannel* channel); | 38 blink::WebMessagePortChannel* channel); |
| 37 ~WebSharedWorkerProxy() override; | 39 ~WebSharedWorkerProxy() override; |
| 38 | 40 |
| 39 private: | 41 private: |
| 40 void connect(ViewHostMsg_CreateWorker_Params params, | 42 void connect(ViewHostMsg_CreateWorker_Params params, |
| 41 blink::WebMessagePortChannel* channel); | 43 blink::WebMessagePortChannel* channel); |
| 42 | 44 |
| 43 // IPC::Listener implementation. | 45 // IPC::Listener implementation. |
| 44 bool OnMessageReceived(const IPC::Message& message) override; | 46 bool OnMessageReceived(const IPC::Message& message) override; |
| 45 | 47 |
| 46 void OnWorkerCreated(); | 48 void OnWorkerCreated(); |
| 47 void OnWorkerScriptLoadFailed(); | 49 void OnWorkerScriptLoadFailed(); |
| 48 void OnWorkerConnected(); | 50 void OnWorkerConnected(std::vector<char> features); |
| 51 void OnWorkerDestroyed(); | |
| 52 void OnCountFeature(uint32_t feature); | |
| 49 | 53 |
| 50 // Routing id associated with this worker - used to receive messages from the | 54 // Routing id associated with this worker - used to receive messages from the |
| 51 // worker, and also to route messages to the worker (WorkerService contains | 55 // worker, and also to route messages to the worker (WorkerService contains |
| 52 // a map that maps between these renderer-side route IDs and worker-side | 56 // a map that maps between these renderer-side route IDs and worker-side |
| 53 // routing ids). | 57 // routing ids). |
| 54 int route_id_; | 58 int route_id_; |
| 55 | 59 |
| 56 IPC::MessageRouter* const router_; | 60 IPC::MessageRouter* const router_; |
| 57 | 61 |
| 58 int message_port_id_; | 62 int message_port_id_; |
| 59 std::unique_ptr<blink::WebSharedWorkerConnectListener> listener_; | 63 std::unique_ptr<blink::WebSharedWorkerConnectListener> listener_; |
| 60 | 64 |
| 61 DISALLOW_COPY_AND_ASSIGN(WebSharedWorkerProxy); | 65 DISALLOW_COPY_AND_ASSIGN(WebSharedWorkerProxy); |
| 62 }; | 66 }; |
| 63 | 67 |
| 64 } // namespace content | 68 } // namespace content |
| 65 | 69 |
| 66 #endif // CONTENT_RENDERER_SHARED_WORKER_WEBSHAREDWORKER_PROXY_H_ | 70 #endif // CONTENT_RENDERER_SHARED_WORKER_WEBSHAREDWORKER_PROXY_H_ |
| OLD | NEW |