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