Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: content/browser/worker_host/worker_process_host.cc

Issue 10909182: Make FileSystemContext respect StoragePartitions. filesystem:// urls will be properly isolated (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove useless headers. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 CreateMessageFilters(render_process_id); 253 CreateMessageFilters(render_process_id);
248 254
249 return true; 255 return true;
250 } 256 }
251 257
252 void WorkerProcessHost::CreateMessageFilters(int render_process_id) { 258 void WorkerProcessHost::CreateMessageFilters(int render_process_id) {
253 ChromeBlobStorageContext* blob_storage_context = 259 ChromeBlobStorageContext* blob_storage_context =
254 content::GetChromeBlobStorageContextForResourceContext( 260 content::GetChromeBlobStorageContextForResourceContext(
255 resource_context_); 261 resource_context_);
256 262
257 // TODO(michaeln): This is hacky but correct. The request context should be 263 net::URLRequestContextGetter* url_request_context =
258 // more directly accessible than digging it out of the appcache service. 264 partition_.url_request_context();
259 net::URLRequestContext* request_context = 265 net::URLRequestContextGetter* media_url_request_context =
260 partition_.appcache_service()->request_context(); 266 partition_.url_request_context();
261 267
262 ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter( 268 ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter(
263 process_->GetData().id, content::PROCESS_TYPE_WORKER, resource_context_, 269 process_->GetData().id, content::PROCESS_TYPE_WORKER, resource_context_,
264 partition_.appcache_service(), 270 partition_.appcache_service(),
265 blob_storage_context, 271 blob_storage_context,
266 new URLRequestContextSelector(request_context)); 272 new URLRequestContextSelector(url_request_context,
273 media_url_request_context));
267 process_->GetHost()->AddFilter(resource_message_filter); 274 process_->GetHost()->AddFilter(resource_message_filter);
268 275
269 worker_message_filter_ = new WorkerMessageFilter( 276 worker_message_filter_ = new WorkerMessageFilter(
270 render_process_id, resource_context_, partition_, 277 render_process_id, resource_context_, partition_,
271 base::Bind(&WorkerServiceImpl::next_worker_route_id, 278 base::Bind(&WorkerServiceImpl::next_worker_route_id,
272 base::Unretained(WorkerServiceImpl::GetInstance()))); 279 base::Unretained(WorkerServiceImpl::GetInstance())));
273 process_->GetHost()->AddFilter(worker_message_filter_); 280 process_->GetHost()->AddFilter(worker_message_filter_);
274 process_->GetHost()->AddFilter(new AppCacheDispatcherHost( 281 process_->GetHost()->AddFilter(new AppCacheDispatcherHost(
275 partition_.appcache_service(), 282 partition_.appcache_service(),
276 process_->GetData().id)); 283 process_->GetData().id));
277 process_->GetHost()->AddFilter(new FileAPIMessageFilter( 284 process_->GetHost()->AddFilter(new FileAPIMessageFilter(
278 process_->GetData().id, 285 process_->GetData().id,
279 request_context, 286 url_request_context,
280 partition_.filesystem_context(), 287 partition_.filesystem_context(),
281 blob_storage_context)); 288 blob_storage_context));
282 process_->GetHost()->AddFilter(new FileUtilitiesMessageFilter( 289 process_->GetHost()->AddFilter(new FileUtilitiesMessageFilter(
283 process_->GetData().id)); 290 process_->GetData().id));
284 process_->GetHost()->AddFilter(new MimeRegistryMessageFilter()); 291 process_->GetHost()->AddFilter(new MimeRegistryMessageFilter());
285 process_->GetHost()->AddFilter( 292 process_->GetHost()->AddFilter(
286 new DatabaseMessageFilter(partition_.database_tracker())); 293 new DatabaseMessageFilter(partition_.database_tracker()));
287 294
288 SocketStreamDispatcherHost* socket_stream_dispatcher_host = 295 SocketStreamDispatcherHost* socket_stream_dispatcher_host =
289 new SocketStreamDispatcherHost(render_process_id, 296 new SocketStreamDispatcherHost(
290 new URLRequestContextSelector(request_context), resource_context_); 297 render_process_id,
298 new URLRequestContextSelector(url_request_context,
299 media_url_request_context),
300 resource_context_);
291 process_->GetHost()->AddFilter(socket_stream_dispatcher_host); 301 process_->GetHost()->AddFilter(socket_stream_dispatcher_host);
292 process_->GetHost()->AddFilter( 302 process_->GetHost()->AddFilter(
293 new content::WorkerDevToolsMessageFilter(process_->GetData().id)); 303 new content::WorkerDevToolsMessageFilter(process_->GetData().id));
294 process_->GetHost()->AddFilter(new IndexedDBDispatcherHost( 304 process_->GetHost()->AddFilter(new IndexedDBDispatcherHost(
295 process_->GetData().id, partition_.indexed_db_context())); 305 process_->GetData().id, partition_.indexed_db_context()));
296 } 306 }
297 307
298 void WorkerProcessHost::CreateWorker(const WorkerInstance& instance) { 308 void WorkerProcessHost::CreateWorker(const WorkerInstance& instance) {
299 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( 309 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL(
300 process_->GetData().id, instance.url()); 310 process_->GetData().id, instance.url());
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 } 716 }
707 } 717 }
708 return false; 718 return false;
709 } 719 }
710 720
711 WorkerProcessHost::WorkerInstance::FilterInfo 721 WorkerProcessHost::WorkerInstance::FilterInfo
712 WorkerProcessHost::WorkerInstance::GetFilter() const { 722 WorkerProcessHost::WorkerInstance::GetFilter() const {
713 DCHECK(NumFilters() == 1); 723 DCHECK(NumFilters() == 1);
714 return *filters_.begin(); 724 return *filters_.begin();
715 } 725 }
OLDNEW
« no previous file with comments | « content/browser/storage_partition_impl_map.cc ('k') | content/browser/worker_host/worker_storage_partition.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698