| 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_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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
| 14 #include "ipc/ipc_channel.h" | 14 #include "ipc/ipc_listener.h" |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSharedWorker.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSharedWorker.h" |
| 16 | 16 |
| 17 class ChildThread; | 17 class ChildThread; |
| 18 | 18 |
| 19 // Implementation of the WebSharedWorker APIs. This object is intended to only | 19 // Implementation of the WebSharedWorker APIs. This object is intended to only |
| 20 // live long enough to allow the caller to send a "connect" event to the worker | 20 // live long enough to allow the caller to send a "connect" event to the worker |
| 21 // thread. Once the connect event has been sent, all future communication will | 21 // thread. Once the connect event has been sent, all future communication will |
| 22 // happen via the WebMessagePortChannel, and the WebSharedWorker instance will | 22 // happen via the WebMessagePortChannel, and the WebSharedWorker instance will |
| 23 // be freed. | 23 // be freed. |
| 24 class WebSharedWorkerProxy : public WebKit::WebSharedWorker, | 24 class WebSharedWorkerProxy : public WebKit::WebSharedWorker, |
| 25 private IPC::Channel::Listener { | 25 private IPC::Listener { |
| 26 public: | 26 public: |
| 27 // If the worker not loaded yet, route_id == MSG_ROUTING_NONE | 27 // If the worker not loaded yet, route_id == MSG_ROUTING_NONE |
| 28 WebSharedWorkerProxy(ChildThread* child_thread, | 28 WebSharedWorkerProxy(ChildThread* child_thread, |
| 29 unsigned long long document_id, | 29 unsigned long long document_id, |
| 30 bool exists, | 30 bool exists, |
| 31 int route_id, | 31 int route_id, |
| 32 int render_view_route_id); | 32 int render_view_route_id); |
| 33 virtual ~WebSharedWorkerProxy(); | 33 virtual ~WebSharedWorkerProxy(); |
| 34 | 34 |
| 35 // Implementations of WebSharedWorker APIs | 35 // Implementations of WebSharedWorker APIs |
| 36 virtual bool isStarted(); | 36 virtual bool isStarted(); |
| 37 virtual void connect(WebKit::WebMessagePortChannel* channel, | 37 virtual void connect(WebKit::WebMessagePortChannel* channel, |
| 38 ConnectListener* listener); | 38 ConnectListener* listener); |
| 39 | 39 |
| 40 virtual void startWorkerContext( | 40 virtual void startWorkerContext( |
| 41 const WebKit::WebURL& script_url, | 41 const WebKit::WebURL& script_url, |
| 42 const WebKit::WebString& name, | 42 const WebKit::WebString& name, |
| 43 const WebKit::WebString& user_agent, | 43 const WebKit::WebString& user_agent, |
| 44 const WebKit::WebString& source_code, | 44 const WebKit::WebString& source_code, |
| 45 const WebKit::WebString& content_security_policy, | 45 const WebKit::WebString& content_security_policy, |
| 46 WebKit::WebContentSecurityPolicyType policy_type, | 46 WebKit::WebContentSecurityPolicyType policy_type, |
| 47 long long script_resource_appcache_id); | 47 long long script_resource_appcache_id); |
| 48 | 48 |
| 49 virtual void terminateWorkerContext(); | 49 virtual void terminateWorkerContext(); |
| 50 virtual void clientDestroyed(); | 50 virtual void clientDestroyed(); |
| 51 | 51 |
| 52 private: | 52 private: |
| 53 // IPC::Channel::Listener implementation. | 53 // IPC::Listener implementation. |
| 54 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 54 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 55 | 55 |
| 56 // Returns true if the worker is running (can send messages to it). | 56 // Returns true if the worker is running (can send messages to it). |
| 57 bool IsStarted(); | 57 bool IsStarted(); |
| 58 | 58 |
| 59 // Disconnects the worker (stops listening for incoming messages). | 59 // Disconnects the worker (stops listening for incoming messages). |
| 60 void Disconnect(); | 60 void Disconnect(); |
| 61 | 61 |
| 62 // Sends a message to the worker thread (forwarded via the RenderViewHost). | 62 // Sends a message to the worker thread (forwarded via the RenderViewHost). |
| 63 // If WorkerStarted() has not yet been called, message is queued. | 63 // If WorkerStarted() has not yet been called, message is queued. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 // The id for the placeholder worker instance we've stored on the | 102 // The id for the placeholder worker instance we've stored on the |
| 103 // browser process (we need to pass this same route id back in when creating | 103 // browser process (we need to pass this same route id back in when creating |
| 104 // the worker). | 104 // the worker). |
| 105 int pending_route_id_; | 105 int pending_route_id_; |
| 106 ConnectListener* connect_listener_; | 106 ConnectListener* connect_listener_; |
| 107 | 107 |
| 108 DISALLOW_COPY_AND_ASSIGN(WebSharedWorkerProxy); | 108 DISALLOW_COPY_AND_ASSIGN(WebSharedWorkerProxy); |
| 109 }; | 109 }; |
| 110 | 110 |
| 111 #endif // CONTENT_RENDERER_WEBSHAREDWORKER_PROXY_H_ | 111 #endif // CONTENT_RENDERER_WEBSHAREDWORKER_PROXY_H_ |
| OLD | NEW |