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 #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 <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 28 matching lines...) Expand all Loading... |
39 #include "content/common/view_messages.h" | 39 #include "content/common/view_messages.h" |
40 #include "content/common/worker_messages.h" | 40 #include "content/common/worker_messages.h" |
41 #include "content/public/browser/browser_thread.h" | 41 #include "content/public/browser/browser_thread.h" |
42 #include "content/public/browser/content_browser_client.h" | 42 #include "content/public/browser/content_browser_client.h" |
43 #include "content/public/browser/user_metrics.h" | 43 #include "content/public/browser/user_metrics.h" |
44 #include "content/public/common/content_switches.h" | 44 #include "content/public/common/content_switches.h" |
45 #include "content/public/common/result_codes.h" | 45 #include "content/public/common/result_codes.h" |
46 #include "ipc/ipc_switches.h" | 46 #include "ipc/ipc_switches.h" |
47 #include "net/base/mime_util.h" | 47 #include "net/base/mime_util.h" |
48 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 48 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 49 #include "net/url_request/url_request_context_getter.h" |
49 #include "ui/base/ui_base_switches.h" | 50 #include "ui/base/ui_base_switches.h" |
50 #include "webkit/fileapi/file_system_context.h" | 51 #include "webkit/fileapi/file_system_context.h" |
51 #include "webkit/fileapi/sandbox_mount_point_provider.h" | 52 #include "webkit/fileapi/sandbox_mount_point_provider.h" |
52 #include "webkit/glue/resource_type.h" | 53 #include "webkit/glue/resource_type.h" |
53 | 54 |
54 using content::BrowserThread; | 55 using content::BrowserThread; |
55 using content::ChildProcessData; | 56 using content::ChildProcessData; |
56 using content::ChildProcessHost; | 57 using content::ChildProcessHost; |
57 using content::RenderViewHostImpl; | 58 using content::RenderViewHostImpl; |
58 using content::ResourceContext; | 59 using content::ResourceContext; |
59 using content::ResourceMessageFilter; | 60 using content::ResourceMessageFilter; |
60 using content::SocketStreamDispatcherHost; | 61 using content::SocketStreamDispatcherHost; |
61 using content::UserMetricsAction; | 62 using content::UserMetricsAction; |
62 using content::WorkerDevToolsManager; | 63 using content::WorkerDevToolsManager; |
63 using content::WorkerServiceImpl; | 64 using content::WorkerServiceImpl; |
64 | 65 |
65 namespace { | 66 namespace { |
66 | 67 |
67 // Helper class that we pass to SocketStreamDispatcherHost so that it can find | 68 // Helper class that we pass to SocketStreamDispatcherHost so that it can find |
68 // the right net::URLRequestContext for a request. | 69 // the right net::URLRequestContext for a request. |
69 class URLRequestContextSelector | 70 class URLRequestContextSelector |
70 : public ResourceMessageFilter::URLRequestContextSelector { | 71 : public ResourceMessageFilter::URLRequestContextSelector { |
71 public: | 72 public: |
72 explicit URLRequestContextSelector( | 73 explicit URLRequestContextSelector( |
73 net::URLRequestContext* url_request_context) | 74 net::URLRequestContextGetter* url_request_context, |
74 : url_request_context_(url_request_context) { | 75 net::URLRequestContextGetter* media_url_request_context) |
| 76 : url_request_context_(url_request_context), |
| 77 media_url_request_context_(media_url_request_context) { |
75 } | 78 } |
76 virtual ~URLRequestContextSelector() {} | 79 virtual ~URLRequestContextSelector() {} |
77 | 80 |
78 virtual net::URLRequestContext* GetRequestContext( | 81 virtual net::URLRequestContext* GetRequestContext( |
79 ResourceType::Type resource_type) { | 82 ResourceType::Type resource_type) { |
80 return url_request_context_; | 83 if (resource_type == ResourceType::MEDIA) |
| 84 return media_url_request_context_->GetURLRequestContext(); |
| 85 return url_request_context_->GetURLRequestContext(); |
81 } | 86 } |
82 | 87 |
83 private: | 88 private: |
84 net::URLRequestContext* url_request_context_; | 89 net::URLRequestContextGetter* url_request_context_; |
| 90 net::URLRequestContextGetter* media_url_request_context_; |
85 }; | 91 }; |
86 | 92 |
87 } // namespace | 93 } // namespace |
88 | 94 |
89 // Notifies RenderViewHost that one or more worker objects crashed. | 95 // Notifies RenderViewHost that one or more worker objects crashed. |
90 void WorkerCrashCallback(int render_process_unique_id, int render_view_id) { | 96 void WorkerCrashCallback(int render_process_unique_id, int render_view_id) { |
91 RenderViewHostImpl* host = | 97 RenderViewHostImpl* host = |
92 RenderViewHostImpl::FromID(render_process_unique_id, render_view_id); | 98 RenderViewHostImpl::FromID(render_process_unique_id, render_view_id); |
93 if (host) | 99 if (host) |
94 host->GetDelegate()->WorkerCrashed(); | 100 host->GetDelegate()->WorkerCrashed(); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 CreateMessageFilters(render_process_id); | 254 CreateMessageFilters(render_process_id); |
249 | 255 |
250 return true; | 256 return true; |
251 } | 257 } |
252 | 258 |
253 void WorkerProcessHost::CreateMessageFilters(int render_process_id) { | 259 void WorkerProcessHost::CreateMessageFilters(int render_process_id) { |
254 ChromeBlobStorageContext* blob_storage_context = | 260 ChromeBlobStorageContext* blob_storage_context = |
255 content::GetChromeBlobStorageContextForResourceContext( | 261 content::GetChromeBlobStorageContextForResourceContext( |
256 resource_context_); | 262 resource_context_); |
257 | 263 |
258 // TODO(michaeln): This is hacky but correct. The request context should be | 264 net::URLRequestContextGetter* url_request_context = |
259 // more directly accessible than digging it out of the appcache service. | 265 partition_.url_request_context(); |
260 net::URLRequestContext* request_context = | 266 net::URLRequestContextGetter* media_url_request_context = |
261 partition_.appcache_service()->request_context(); | 267 partition_.url_request_context(); |
262 | 268 |
263 ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter( | 269 ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter( |
264 process_->GetData().id, content::PROCESS_TYPE_WORKER, resource_context_, | 270 process_->GetData().id, content::PROCESS_TYPE_WORKER, resource_context_, |
265 partition_.appcache_service(), | 271 partition_.appcache_service(), |
266 blob_storage_context, | 272 blob_storage_context, |
267 new URLRequestContextSelector(request_context)); | 273 new URLRequestContextSelector(url_request_context, |
| 274 media_url_request_context)); |
268 process_->GetHost()->AddFilter(resource_message_filter); | 275 process_->GetHost()->AddFilter(resource_message_filter); |
269 | 276 |
270 worker_message_filter_ = new WorkerMessageFilter( | 277 worker_message_filter_ = new WorkerMessageFilter( |
271 render_process_id, resource_context_, partition_, | 278 render_process_id, resource_context_, partition_, |
272 base::Bind(&WorkerServiceImpl::next_worker_route_id, | 279 base::Bind(&WorkerServiceImpl::next_worker_route_id, |
273 base::Unretained(WorkerServiceImpl::GetInstance()))); | 280 base::Unretained(WorkerServiceImpl::GetInstance()))); |
274 process_->GetHost()->AddFilter(worker_message_filter_); | 281 process_->GetHost()->AddFilter(worker_message_filter_); |
275 process_->GetHost()->AddFilter(new AppCacheDispatcherHost( | 282 process_->GetHost()->AddFilter(new AppCacheDispatcherHost( |
276 partition_.appcache_service(), | 283 partition_.appcache_service(), |
277 process_->GetData().id)); | 284 process_->GetData().id)); |
278 process_->GetHost()->AddFilter(new FileAPIMessageFilter( | 285 process_->GetHost()->AddFilter(new FileAPIMessageFilter( |
279 process_->GetData().id, | 286 process_->GetData().id, |
280 request_context, | 287 url_request_context, |
281 partition_.filesystem_context(), | 288 partition_.filesystem_context(), |
282 blob_storage_context)); | 289 blob_storage_context)); |
283 process_->GetHost()->AddFilter(new FileUtilitiesMessageFilter( | 290 process_->GetHost()->AddFilter(new FileUtilitiesMessageFilter( |
284 process_->GetData().id)); | 291 process_->GetData().id)); |
285 process_->GetHost()->AddFilter(new MimeRegistryMessageFilter()); | 292 process_->GetHost()->AddFilter(new MimeRegistryMessageFilter()); |
286 process_->GetHost()->AddFilter( | 293 process_->GetHost()->AddFilter( |
287 new DatabaseMessageFilter(partition_.database_tracker())); | 294 new DatabaseMessageFilter(partition_.database_tracker())); |
288 | 295 |
289 SocketStreamDispatcherHost* socket_stream_dispatcher_host = | 296 SocketStreamDispatcherHost* socket_stream_dispatcher_host = |
290 new SocketStreamDispatcherHost(render_process_id, | 297 new SocketStreamDispatcherHost( |
291 new URLRequestContextSelector(request_context), resource_context_); | 298 render_process_id, |
| 299 new URLRequestContextSelector(url_request_context, |
| 300 media_url_request_context), |
| 301 resource_context_); |
292 process_->GetHost()->AddFilter(socket_stream_dispatcher_host); | 302 process_->GetHost()->AddFilter(socket_stream_dispatcher_host); |
293 process_->GetHost()->AddFilter( | 303 process_->GetHost()->AddFilter( |
294 new content::WorkerDevToolsMessageFilter(process_->GetData().id)); | 304 new content::WorkerDevToolsMessageFilter(process_->GetData().id)); |
295 process_->GetHost()->AddFilter(new IndexedDBDispatcherHost( | 305 process_->GetHost()->AddFilter(new IndexedDBDispatcherHost( |
296 process_->GetData().id, partition_.indexed_db_context())); | 306 process_->GetData().id, partition_.indexed_db_context())); |
297 } | 307 } |
298 | 308 |
299 void WorkerProcessHost::CreateWorker(const WorkerInstance& instance) { | 309 void WorkerProcessHost::CreateWorker(const WorkerInstance& instance) { |
300 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( | 310 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( |
301 process_->GetData().id, instance.url()); | 311 process_->GetData().id, instance.url()); |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 } | 717 } |
708 } | 718 } |
709 return false; | 719 return false; |
710 } | 720 } |
711 | 721 |
712 WorkerProcessHost::WorkerInstance::FilterInfo | 722 WorkerProcessHost::WorkerInstance::FilterInfo |
713 WorkerProcessHost::WorkerInstance::GetFilter() const { | 723 WorkerProcessHost::WorkerInstance::GetFilter() const { |
714 DCHECK(NumFilters() == 1); | 724 DCHECK(NumFilters() == 1); |
715 return *filters_.begin(); | 725 return *filters_.begin(); |
716 } | 726 } |
OLD | NEW |