OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "content/worker/webworker_stub_base.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "content/worker/webworkerclient_proxy.h" | 10 #include "content/worker/webworkerclient_proxy.h" |
| 11 #include "content/worker/worker_webapplicationcachehost_impl.h" |
11 #include "googleurl/src/gurl.h" | 12 #include "googleurl/src/gurl.h" |
| 13 #include "ipc/ipc_channel.h" |
12 | 14 |
13 namespace WebKit { | 15 namespace WebKit { |
14 class WebSharedWorker; | 16 class WebSharedWorker; |
15 } | 17 } |
16 | 18 |
17 class SharedWorkerDevToolsAgent; | 19 class SharedWorkerDevToolsAgent; |
18 | 20 |
19 // This class creates a WebSharedWorker, and translates incoming IPCs to the | 21 // This class creates a WebSharedWorker, and translates incoming IPCs to the |
20 // appropriate WebSharedWorker APIs. | 22 // appropriate WebSharedWorker APIs. |
21 class WebSharedWorkerStub : public WebWorkerStubBase { | 23 class WebSharedWorkerStub : public IPC::Channel::Listener { |
22 public: | 24 public: |
23 WebSharedWorkerStub(const string16& name, int route_id, | 25 WebSharedWorkerStub(const string16& name, int route_id, |
24 const WorkerAppCacheInitInfo& appcache_init_info); | 26 const WorkerAppCacheInitInfo& appcache_init_info); |
25 | 27 |
26 // IPC::Channel::Listener implementation. | 28 // IPC::Channel::Listener implementation. |
27 virtual bool OnMessageReceived(const IPC::Message& message); | 29 virtual bool OnMessageReceived(const IPC::Message& message); |
28 virtual void OnChannelError(); | 30 virtual void OnChannelError(); |
29 | 31 |
30 virtual const GURL& url() const; | 32 // Invoked when the WebWorkerClientProxy is shutting down. |
| 33 void Shutdown(); |
| 34 |
| 35 // Called after terminating the worker context to make sure that the worker |
| 36 // actually terminates (is not stuck in an infinite loop). |
| 37 void EnsureWorkerContextTerminates(); |
| 38 |
| 39 WebWorkerClientProxy* client() { return &client_; } |
| 40 |
| 41 const WorkerAppCacheInitInfo& appcache_init_info() const { |
| 42 return appcache_init_info_; |
| 43 } |
| 44 |
| 45 // Returns the script url of this worker. |
| 46 const GURL& url(); |
| 47 |
31 | 48 |
32 private: | 49 private: |
33 virtual ~WebSharedWorkerStub(); | 50 virtual ~WebSharedWorkerStub(); |
34 | 51 |
35 void OnConnect(int sent_message_port_id, int routing_id); | 52 void OnConnect(int sent_message_port_id, int routing_id); |
36 void OnStartWorkerContext( | 53 void OnStartWorkerContext( |
37 const GURL& url, const string16& user_agent, const string16& source_code); | 54 const GURL& url, const string16& user_agent, const string16& source_code); |
38 void OnTerminateWorkerContext(); | 55 void OnTerminateWorkerContext(); |
39 | 56 |
| 57 int route_id_; |
| 58 WorkerAppCacheInitInfo appcache_init_info_; |
| 59 |
| 60 // WebWorkerClient that responds to outgoing API calls from the worker object. |
| 61 WebWorkerClientProxy client_; |
| 62 |
40 WebKit::WebSharedWorker* impl_; | 63 WebKit::WebSharedWorker* impl_; |
41 string16 name_; | 64 string16 name_; |
42 bool started_; | 65 bool started_; |
43 GURL url_; | 66 GURL url_; |
44 scoped_ptr<SharedWorkerDevToolsAgent> worker_devtools_agent_; | 67 scoped_ptr<SharedWorkerDevToolsAgent> worker_devtools_agent_; |
45 | 68 |
46 typedef std::pair<int, int> PendingConnectInfo; | 69 typedef std::pair<int, int> PendingConnectInfo; |
47 typedef std::vector<PendingConnectInfo> PendingConnectInfoList; | 70 typedef std::vector<PendingConnectInfo> PendingConnectInfoList; |
48 PendingConnectInfoList pending_connects_; | 71 PendingConnectInfoList pending_connects_; |
49 | 72 |
50 DISALLOW_COPY_AND_ASSIGN(WebSharedWorkerStub); | 73 DISALLOW_COPY_AND_ASSIGN(WebSharedWorkerStub); |
51 }; | 74 }; |
52 | 75 |
53 #endif // CONTENT_WORKER_WEBSHAREDWORKER_STUB_H_ | 76 #endif // CONTENT_WORKER_WEBSHAREDWORKER_STUB_H_ |
OLD | NEW |