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_BROWSER_WORKER_HOST_WORKER_PROCESS_HOST_H_ | 5 #ifndef CONTENT_BROWSER_WORKER_HOST_WORKER_PROCESS_HOST_H_ |
6 #define CONTENT_BROWSER_WORKER_HOST_WORKER_PROCESS_HOST_H_ | 6 #define CONTENT_BROWSER_WORKER_HOST_WORKER_PROCESS_HOST_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <list> | 9 #include <list> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/file_path.h" | 13 #include "base/file_path.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
16 #include "content/browser/worker_host/worker_document_set.h" | 16 #include "content/browser/worker_host/worker_document_set.h" |
17 #include "content/public/browser/browser_child_process_host_delegate.h" | 17 #include "content/public/browser/browser_child_process_host_delegate.h" |
18 #include "content/public/browser/browser_child_process_host_iterator.h" | 18 #include "content/public/browser/browser_child_process_host_iterator.h" |
19 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
20 #include "ipc/ipc_message.h" | 20 #include "ipc/ipc_sender.h" |
21 | 21 |
22 class BrowserChildProcessHostImpl; | 22 class BrowserChildProcessHostImpl; |
23 | 23 |
24 namespace content { | 24 namespace content { |
25 class ResourceContext; | 25 class ResourceContext; |
26 class WorkerServiceImpl; | 26 class WorkerServiceImpl; |
27 } // namespace content | 27 } // namespace content |
28 | 28 |
29 // The WorkerProcessHost is the interface that represents the browser side of | 29 // The WorkerProcessHost is the interface that represents the browser side of |
30 // the browser <-> worker communication channel. There will be one | 30 // the browser <-> worker communication channel. There will be one |
31 // WorkerProcessHost per worker process. Currently each worker runs in its own | 31 // WorkerProcessHost per worker process. Currently each worker runs in its own |
32 // process, but that may change. However, we do assume (by storing a | 32 // process, but that may change. However, we do assume (by storing a |
33 // net::URLRequestContext) that a WorkerProcessHost serves a single | 33 // net::URLRequestContext) that a WorkerProcessHost serves a single |
34 // BrowserContext. | 34 // BrowserContext. |
35 class WorkerProcessHost : public content::BrowserChildProcessHostDelegate, | 35 class WorkerProcessHost : public content::BrowserChildProcessHostDelegate, |
36 public IPC::Message::Sender { | 36 public IPC::Sender { |
37 public: | 37 public: |
38 // Contains information about each worker instance, needed to forward messages | 38 // Contains information about each worker instance, needed to forward messages |
39 // between the renderer and worker processes. | 39 // between the renderer and worker processes. |
40 class WorkerInstance { | 40 class WorkerInstance { |
41 public: | 41 public: |
42 WorkerInstance(const GURL& url, | 42 WorkerInstance(const GURL& url, |
43 const string16& name, | 43 const string16& name, |
44 int worker_route_id, | 44 int worker_route_id, |
45 int parent_process_id, | 45 int parent_process_id, |
46 int64 main_resource_appcache_id, | 46 int64 main_resource_appcache_id, |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 int parent_process_id_; | 109 int parent_process_id_; |
110 int64 main_resource_appcache_id_; | 110 int64 main_resource_appcache_id_; |
111 FilterList filters_; | 111 FilterList filters_; |
112 scoped_refptr<WorkerDocumentSet> worker_document_set_; | 112 scoped_refptr<WorkerDocumentSet> worker_document_set_; |
113 content::ResourceContext* const resource_context_; | 113 content::ResourceContext* const resource_context_; |
114 }; | 114 }; |
115 | 115 |
116 explicit WorkerProcessHost(content::ResourceContext* resource_context); | 116 explicit WorkerProcessHost(content::ResourceContext* resource_context); |
117 virtual ~WorkerProcessHost(); | 117 virtual ~WorkerProcessHost(); |
118 | 118 |
119 // IPC::Message::Sender implementation: | 119 // IPC::Sender implementation: |
120 virtual bool Send(IPC::Message* message) OVERRIDE; | 120 virtual bool Send(IPC::Message* message) OVERRIDE; |
121 | 121 |
122 // Starts the process. Returns true iff it succeeded. | 122 // Starts the process. Returns true iff it succeeded. |
123 // |render_process_id| is the renderer process responsible for starting this | 123 // |render_process_id| is the renderer process responsible for starting this |
124 // worker. | 124 // worker. |
125 bool Init(int render_process_id); | 125 bool Init(int render_process_id); |
126 | 126 |
127 // Creates a worker object in the process. | 127 // Creates a worker object in the process. |
128 void CreateWorker(const WorkerInstance& instance); | 128 void CreateWorker(const WorkerInstance& instance); |
129 | 129 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 class WorkerProcessHostIterator | 210 class WorkerProcessHostIterator |
211 : public content::BrowserChildProcessHostTypeIterator<WorkerProcessHost> { | 211 : public content::BrowserChildProcessHostTypeIterator<WorkerProcessHost> { |
212 public: | 212 public: |
213 WorkerProcessHostIterator() | 213 WorkerProcessHostIterator() |
214 : content::BrowserChildProcessHostTypeIterator<WorkerProcessHost>( | 214 : content::BrowserChildProcessHostTypeIterator<WorkerProcessHost>( |
215 content::PROCESS_TYPE_WORKER) { | 215 content::PROCESS_TYPE_WORKER) { |
216 } | 216 } |
217 }; | 217 }; |
218 | 218 |
219 #endif // CONTENT_BROWSER_WORKER_HOST_WORKER_PROCESS_HOST_H_ | 219 #endif // CONTENT_BROWSER_WORKER_HOST_WORKER_PROCESS_HOST_H_ |
OLD | NEW |