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_WORKER_WEBSHAREDWORKER_STUB_H_ | 5 #ifndef CONTENT_WORKER_WEBSHAREDWORKER_STUB_H_ |
6 #define CONTENT_WORKER_WEBSHAREDWORKER_STUB_H_ | 6 #define CONTENT_WORKER_WEBSHAREDWORKER_STUB_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "content/child/scoped_child_process_reference.h" | 9 #include "content/child/scoped_child_process_reference.h" |
10 #include "content/worker/websharedworkerclient_proxy.h" | 10 #include "content/worker/websharedworkerclient_proxy.h" |
11 #include "content/worker/worker_webapplicationcachehost_impl.h" | 11 #include "content/worker/worker_webapplicationcachehost_impl.h" |
12 #include "ipc/ipc_listener.h" | 12 #include "ipc/ipc_listener.h" |
13 #include "third_party/WebKit/public/web/WebSharedWorker.h" | 13 #include "third_party/WebKit/public/web/WebSharedWorker.h" |
14 #include "url/gurl.h" | 14 #include "url/gurl.h" |
15 | 15 |
16 namespace blink { | 16 namespace blink { |
17 class WebSharedWorker; | 17 class WebSharedWorker; |
18 } | 18 } |
19 | 19 |
20 namespace content { | 20 namespace content { |
21 | 21 |
22 class SharedWorkerDevToolsAgent; | 22 class SharedWorkerDevToolsAgent; |
23 | 23 |
24 // This class creates a WebSharedWorker, and translates incoming IPCs to the | 24 // This class creates a WebSharedWorker, and translates incoming IPCs to the |
25 // appropriate WebSharedWorker APIs. | 25 // appropriate WebSharedWorker APIs. |
26 class WebSharedWorkerStub : public IPC::Listener { | 26 class WebSharedWorkerStub : public IPC::Listener { |
27 public: | 27 public: |
28 WebSharedWorkerStub(const string16& name, int route_id, | 28 WebSharedWorkerStub(const base::string16& name, int route_id, |
29 const WorkerAppCacheInitInfo& appcache_init_info); | 29 const WorkerAppCacheInitInfo& appcache_init_info); |
30 | 30 |
31 // IPC::Listener implementation. | 31 // IPC::Listener implementation. |
32 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 32 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
33 virtual void OnChannelError() OVERRIDE; | 33 virtual void OnChannelError() OVERRIDE; |
34 | 34 |
35 // Invoked when the WebSharedWorkerClientProxy is shutting down. | 35 // Invoked when the WebSharedWorkerClientProxy is shutting down. |
36 void Shutdown(); | 36 void Shutdown(); |
37 | 37 |
38 // Called after terminating the worker context to make sure that the worker | 38 // Called after terminating the worker context to make sure that the worker |
39 // actually terminates (is not stuck in an infinite loop). | 39 // actually terminates (is not stuck in an infinite loop). |
40 void EnsureWorkerContextTerminates(); | 40 void EnsureWorkerContextTerminates(); |
41 | 41 |
42 WebSharedWorkerClientProxy* client() { return &client_; } | 42 WebSharedWorkerClientProxy* client() { return &client_; } |
43 | 43 |
44 const WorkerAppCacheInitInfo& appcache_init_info() const { | 44 const WorkerAppCacheInitInfo& appcache_init_info() const { |
45 return appcache_init_info_; | 45 return appcache_init_info_; |
46 } | 46 } |
47 | 47 |
48 // Returns the script url of this worker. | 48 // Returns the script url of this worker. |
49 const GURL& url(); | 49 const GURL& url(); |
50 | 50 |
51 | 51 |
52 private: | 52 private: |
53 virtual ~WebSharedWorkerStub(); | 53 virtual ~WebSharedWorkerStub(); |
54 | 54 |
55 void OnConnect(int sent_message_port_id, int routing_id); | 55 void OnConnect(int sent_message_port_id, int routing_id); |
56 void OnStartWorkerContext( | 56 void OnStartWorkerContext( |
57 const GURL& url, const string16& user_agent, const string16& source_code, | 57 const GURL& url, const base::string16& user_agent, |
58 const string16& content_security_policy, | 58 const base::string16& source_code, |
| 59 const base::string16& content_security_policy, |
59 blink::WebContentSecurityPolicyType policy_type); | 60 blink::WebContentSecurityPolicyType policy_type); |
60 | 61 |
61 void OnTerminateWorkerContext(); | 62 void OnTerminateWorkerContext(); |
62 | 63 |
63 ScopedChildProcessReference process_ref_; | 64 ScopedChildProcessReference process_ref_; |
64 | 65 |
65 int route_id_; | 66 int route_id_; |
66 WorkerAppCacheInitInfo appcache_init_info_; | 67 WorkerAppCacheInitInfo appcache_init_info_; |
67 | 68 |
68 // WebSharedWorkerClient that responds to outgoing API calls | 69 // WebSharedWorkerClient that responds to outgoing API calls |
69 // from the worker object. | 70 // from the worker object. |
70 WebSharedWorkerClientProxy client_; | 71 WebSharedWorkerClientProxy client_; |
71 | 72 |
72 blink::WebSharedWorker* impl_; | 73 blink::WebSharedWorker* impl_; |
73 string16 name_; | 74 base::string16 name_; |
74 bool started_; | 75 bool started_; |
75 GURL url_; | 76 GURL url_; |
76 scoped_ptr<SharedWorkerDevToolsAgent> worker_devtools_agent_; | 77 scoped_ptr<SharedWorkerDevToolsAgent> worker_devtools_agent_; |
77 | 78 |
78 typedef std::pair<int, int> PendingConnectInfo; | 79 typedef std::pair<int, int> PendingConnectInfo; |
79 typedef std::vector<PendingConnectInfo> PendingConnectInfoList; | 80 typedef std::vector<PendingConnectInfo> PendingConnectInfoList; |
80 PendingConnectInfoList pending_connects_; | 81 PendingConnectInfoList pending_connects_; |
81 | 82 |
82 DISALLOW_COPY_AND_ASSIGN(WebSharedWorkerStub); | 83 DISALLOW_COPY_AND_ASSIGN(WebSharedWorkerStub); |
83 }; | 84 }; |
84 | 85 |
85 } // namespace content | 86 } // namespace content |
86 | 87 |
87 #endif // CONTENT_WORKER_WEBSHAREDWORKER_STUB_H_ | 88 #endif // CONTENT_WORKER_WEBSHAREDWORKER_STUB_H_ |
OLD | NEW |