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 #include "content/browser/worker_host/worker_process_host.h" | 5 #include "content/browser/worker_host/worker_process_host.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/base_switches.h" | 10 #include "base/base_switches.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "content/browser/renderer_host/database_message_filter.h" | 24 #include "content/browser/renderer_host/database_message_filter.h" |
25 #include "content/browser/renderer_host/file_utilities_message_filter.h" | 25 #include "content/browser/renderer_host/file_utilities_message_filter.h" |
26 #include "content/browser/renderer_host/render_view_host.h" | 26 #include "content/browser/renderer_host/render_view_host.h" |
27 #include "content/browser/renderer_host/render_view_host_delegate.h" | 27 #include "content/browser/renderer_host/render_view_host_delegate.h" |
28 #include "content/browser/renderer_host/socket_stream_dispatcher_host.h" | 28 #include "content/browser/renderer_host/socket_stream_dispatcher_host.h" |
29 #include "content/browser/resource_context.h" | 29 #include "content/browser/resource_context.h" |
30 #include "content/browser/user_metrics.h" | 30 #include "content/browser/user_metrics.h" |
31 #include "content/browser/worker_host/message_port_service.h" | 31 #include "content/browser/worker_host/message_port_service.h" |
32 #include "content/browser/worker_host/worker_message_filter.h" | 32 #include "content/browser/worker_host/worker_message_filter.h" |
33 #include "content/browser/worker_host/worker_service.h" | 33 #include "content/browser/worker_host/worker_service.h" |
| 34 #include "content/common/child_process_host.h" |
34 #include "content/common/debug_flags.h" | 35 #include "content/common/debug_flags.h" |
35 #include "content/common/view_messages.h" | 36 #include "content/common/view_messages.h" |
36 #include "content/common/worker_messages.h" | 37 #include "content/common/worker_messages.h" |
37 #include "content/public/browser/browser_thread.h" | 38 #include "content/public/browser/browser_thread.h" |
38 #include "content/public/browser/content_browser_client.h" | 39 #include "content/public/browser/content_browser_client.h" |
39 #include "content/public/common/content_switches.h" | 40 #include "content/public/common/content_switches.h" |
40 #include "content/public/common/result_codes.h" | 41 #include "content/public/common/result_codes.h" |
41 #include "ipc/ipc_switches.h" | 42 #include "ipc/ipc_switches.h" |
42 #include "net/base/mime_util.h" | 43 #include "net/base/mime_util.h" |
43 #include "net/base/registry_controlled_domain.h" | 44 #include "net/base/registry_controlled_domain.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 parent_iter->render_view_id())); | 105 parent_iter->render_view_id())); |
105 } | 106 } |
106 WorkerService::GetInstance()->NotifyWorkerDestroyed(this, | 107 WorkerService::GetInstance()->NotifyWorkerDestroyed(this, |
107 i->worker_route_id()); | 108 i->worker_route_id()); |
108 } | 109 } |
109 | 110 |
110 ChildProcessSecurityPolicy::GetInstance()->Remove(id()); | 111 ChildProcessSecurityPolicy::GetInstance()->Remove(id()); |
111 } | 112 } |
112 | 113 |
113 bool WorkerProcessHost::Init(int render_process_id) { | 114 bool WorkerProcessHost::Init(int render_process_id) { |
114 if (!CreateChannel()) | 115 if (!child_process_host()->CreateChannel()) |
115 return false; | 116 return false; |
116 | 117 |
117 #if defined(OS_LINUX) | 118 #if defined(OS_LINUX) |
118 int flags = CHILD_ALLOW_SELF; | 119 int flags = ChildProcessHost::CHILD_ALLOW_SELF; |
119 #else | 120 #else |
120 int flags = CHILD_NORMAL; | 121 int flags = ChildProcessHost::CHILD_NORMAL; |
121 #endif | 122 #endif |
122 | 123 |
123 FilePath exe_path = GetChildPath(flags); | 124 FilePath exe_path = ChildProcessHost::GetChildPath(flags); |
124 if (exe_path.empty()) | 125 if (exe_path.empty()) |
125 return false; | 126 return false; |
126 | 127 |
127 CommandLine* cmd_line = new CommandLine(exe_path); | 128 CommandLine* cmd_line = new CommandLine(exe_path); |
128 cmd_line->AppendSwitchASCII(switches::kProcessType, switches::kWorkerProcess); | 129 cmd_line->AppendSwitchASCII(switches::kProcessType, switches::kWorkerProcess); |
129 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id()); | 130 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, |
| 131 child_process_host()->channel_id()); |
130 std::string locale = | 132 std::string locale = |
131 content::GetContentClient()->browser()->GetApplicationLocale(); | 133 content::GetContentClient()->browser()->GetApplicationLocale(); |
132 cmd_line->AppendSwitchASCII(switches::kLang, locale); | 134 cmd_line->AppendSwitchASCII(switches::kLang, locale); |
133 | 135 |
134 static const char* const kSwitchNames[] = { | 136 static const char* const kSwitchNames[] = { |
135 switches::kWebWorkerShareProcesses, | 137 switches::kWebWorkerShareProcesses, |
136 switches::kDisableApplicationCache, | 138 switches::kDisableApplicationCache, |
137 switches::kDisableDatabases, | 139 switches::kDisableDatabases, |
138 switches::kEnableLogging, | 140 switches::kEnableLogging, |
139 switches::kLoggingLevel, | 141 switches::kLoggingLevel, |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 | 232 |
231 void WorkerProcessHost::CreateMessageFilters(int render_process_id) { | 233 void WorkerProcessHost::CreateMessageFilters(int render_process_id) { |
232 DCHECK(resource_context_); | 234 DCHECK(resource_context_); |
233 net::URLRequestContext* request_context = | 235 net::URLRequestContext* request_context = |
234 resource_context_->request_context(); | 236 resource_context_->request_context(); |
235 | 237 |
236 ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter( | 238 ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter( |
237 id(), content::PROCESS_TYPE_WORKER, resource_context_, | 239 id(), content::PROCESS_TYPE_WORKER, resource_context_, |
238 new URLRequestContextSelector(request_context), | 240 new URLRequestContextSelector(request_context), |
239 resource_dispatcher_host_); | 241 resource_dispatcher_host_); |
240 AddFilter(resource_message_filter); | 242 child_process_host()->AddFilter(resource_message_filter); |
241 | 243 |
242 worker_message_filter_ = new WorkerMessageFilter( | 244 worker_message_filter_ = new WorkerMessageFilter( |
243 render_process_id, resource_context_, resource_dispatcher_host_, | 245 render_process_id, resource_context_, resource_dispatcher_host_, |
244 base::Bind(&WorkerService::next_worker_route_id, | 246 base::Bind(&WorkerService::next_worker_route_id, |
245 base::Unretained(WorkerService::GetInstance()))); | 247 base::Unretained(WorkerService::GetInstance()))); |
246 AddFilter(worker_message_filter_); | 248 child_process_host()->AddFilter(worker_message_filter_); |
247 AddFilter(new AppCacheDispatcherHost( | 249 child_process_host()->AddFilter(new AppCacheDispatcherHost( |
248 resource_context_->appcache_service(), id())); | 250 resource_context_->appcache_service(), id())); |
249 AddFilter(new FileSystemDispatcherHost( | 251 child_process_host()->AddFilter(new FileSystemDispatcherHost( |
250 request_context, resource_context_->file_system_context())); | 252 request_context, resource_context_->file_system_context())); |
251 AddFilter(new FileUtilitiesMessageFilter(id())); | 253 child_process_host()->AddFilter(new FileUtilitiesMessageFilter(id())); |
252 AddFilter(new BlobMessageFilter( | 254 child_process_host()->AddFilter(new BlobMessageFilter( |
253 id(), resource_context_->blob_storage_context())); | 255 id(), resource_context_->blob_storage_context())); |
254 AddFilter(new MimeRegistryMessageFilter()); | 256 child_process_host()->AddFilter(new MimeRegistryMessageFilter()); |
255 AddFilter(new DatabaseMessageFilter( | 257 child_process_host()->AddFilter(new DatabaseMessageFilter( |
256 resource_context_->database_tracker())); | 258 resource_context_->database_tracker())); |
257 | 259 |
258 SocketStreamDispatcherHost* socket_stream_dispatcher_host = | 260 SocketStreamDispatcherHost* socket_stream_dispatcher_host = |
259 new SocketStreamDispatcherHost( | 261 new SocketStreamDispatcherHost( |
260 new URLRequestContextSelector(request_context), resource_context_); | 262 new URLRequestContextSelector(request_context), resource_context_); |
261 AddFilter(socket_stream_dispatcher_host); | 263 child_process_host()->AddFilter(socket_stream_dispatcher_host); |
262 AddFilter(new content::WorkerDevToolsMessageFilter(id())); | 264 child_process_host()->AddFilter(new content::WorkerDevToolsMessageFilter(id())
); |
263 } | 265 } |
264 | 266 |
265 void WorkerProcessHost::CreateWorker(const WorkerInstance& instance) { | 267 void WorkerProcessHost::CreateWorker(const WorkerInstance& instance) { |
266 ChildProcessSecurityPolicy::GetInstance()->GrantRequestURL( | 268 ChildProcessSecurityPolicy::GetInstance()->GrantRequestURL( |
267 id(), instance.url()); | 269 id(), instance.url()); |
268 | 270 |
269 instances_.push_back(instance); | 271 instances_.push_back(instance); |
270 | 272 |
271 WorkerProcessMsg_CreateWorker_Params params; | 273 WorkerProcessMsg_CreateWorker_Params params; |
272 params.url = instance.url(); | 274 params.url = instance.url(); |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 } | 625 } |
624 } | 626 } |
625 return false; | 627 return false; |
626 } | 628 } |
627 | 629 |
628 WorkerProcessHost::WorkerInstance::FilterInfo | 630 WorkerProcessHost::WorkerInstance::FilterInfo |
629 WorkerProcessHost::WorkerInstance::GetFilter() const { | 631 WorkerProcessHost::WorkerInstance::GetFilter() const { |
630 DCHECK(NumFilters() == 1); | 632 DCHECK(NumFilters() == 1); |
631 return *filters_.begin(); | 633 return *filters_.begin(); |
632 } | 634 } |
OLD | NEW |