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

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

Issue 9425026: Remove getters for HTML5 related objects from the ResourceContext interface. Half of them weren't u… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: review comments Created 8 years, 10 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
« no previous file with comments | « content/browser/resource_context_impl.cc ('k') | content/content_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <vector> 8 #include <vector>
9 9
10 #include "base/base_switches.h" 10 #include "base/base_switches.h"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/message_loop.h" 15 #include "base/message_loop.h"
16 #include "base/string_util.h" 16 #include "base/string_util.h"
17 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
18 #include "content/browser/appcache/appcache_dispatcher_host.h" 18 #include "content/browser/appcache/appcache_dispatcher_host.h"
19 #include "content/browser/appcache/chrome_appcache_service.h"
19 #include "content/browser/browser_child_process_host_impl.h" 20 #include "content/browser/browser_child_process_host_impl.h"
20 #include "content/browser/child_process_security_policy_impl.h" 21 #include "content/browser/child_process_security_policy_impl.h"
21 #include "content/browser/debugger/worker_devtools_manager.h" 22 #include "content/browser/debugger/worker_devtools_manager.h"
22 #include "content/browser/debugger/worker_devtools_message_filter.h" 23 #include "content/browser/debugger/worker_devtools_message_filter.h"
23 #include "content/browser/file_system/file_system_dispatcher_host.h" 24 #include "content/browser/file_system/file_system_dispatcher_host.h"
24 #include "content/browser/in_process_webkit/indexed_db_dispatcher_host.h" 25 #include "content/browser/in_process_webkit/indexed_db_dispatcher_host.h"
25 #include "content/browser/mime_registry_message_filter.h" 26 #include "content/browser/mime_registry_message_filter.h"
26 #include "content/browser/renderer_host/blob_message_filter.h" 27 #include "content/browser/renderer_host/blob_message_filter.h"
27 #include "content/browser/renderer_host/database_message_filter.h" 28 #include "content/browser/renderer_host/database_message_filter.h"
28 #include "content/browser/renderer_host/file_utilities_message_filter.h" 29 #include "content/browser/renderer_host/file_utilities_message_filter.h"
29 #include "content/browser/renderer_host/render_view_host.h" 30 #include "content/browser/renderer_host/render_view_host.h"
30 #include "content/browser/renderer_host/socket_stream_dispatcher_host.h" 31 #include "content/browser/renderer_host/socket_stream_dispatcher_host.h"
32 #include "content/browser/resource_context_impl.h"
31 #include "content/browser/worker_host/message_port_service.h" 33 #include "content/browser/worker_host/message_port_service.h"
32 #include "content/browser/worker_host/worker_message_filter.h" 34 #include "content/browser/worker_host/worker_message_filter.h"
33 #include "content/browser/worker_host/worker_service_impl.h" 35 #include "content/browser/worker_host/worker_service_impl.h"
34 #include "content/common/child_process_host_impl.h" 36 #include "content/common/child_process_host_impl.h"
35 #include "content/common/debug_flags.h" 37 #include "content/common/debug_flags.h"
36 #include "content/common/view_messages.h" 38 #include "content/common/view_messages.h"
37 #include "content/common/worker_messages.h" 39 #include "content/common/worker_messages.h"
38 #include "content/public/browser/browser_thread.h" 40 #include "content/public/browser/browser_thread.h"
39 #include "content/public/browser/content_browser_client.h" 41 #include "content/public/browser/content_browser_client.h"
40 #include "content/public/browser/render_view_host_delegate.h" 42 #include "content/public/browser/render_view_host_delegate.h"
41 #include "content/public/browser/resource_context.h"
42 #include "content/public/browser/user_metrics.h" 43 #include "content/public/browser/user_metrics.h"
43 #include "content/public/common/content_switches.h" 44 #include "content/public/common/content_switches.h"
44 #include "content/public/common/result_codes.h" 45 #include "content/public/common/result_codes.h"
45 #include "ipc/ipc_switches.h" 46 #include "ipc/ipc_switches.h"
46 #include "net/base/mime_util.h" 47 #include "net/base/mime_util.h"
47 #include "net/base/registry_controlled_domain.h" 48 #include "net/base/registry_controlled_domain.h"
48 #include "ui/base/ui_base_switches.h" 49 #include "ui/base/ui_base_switches.h"
49 #include "webkit/fileapi/file_system_context.h" 50 #include "webkit/fileapi/file_system_context.h"
50 #include "webkit/fileapi/sandbox_mount_point_provider.h" 51 #include "webkit/fileapi/sandbox_mount_point_provider.h"
51 #include "webkit/glue/resource_type.h" 52 #include "webkit/glue/resource_type.h"
52 53
53 using content::BrowserThread; 54 using content::BrowserThread;
54 using content::ChildProcessData; 55 using content::ChildProcessData;
55 using content::ChildProcessHost; 56 using content::ChildProcessHost;
57 using content::ResourceContext;
56 using content::UserMetricsAction; 58 using content::UserMetricsAction;
57 using content::WorkerDevToolsManager; 59 using content::WorkerDevToolsManager;
58 using content::WorkerServiceImpl; 60 using content::WorkerServiceImpl;
59 61
60 namespace { 62 namespace {
61 63
62 // Helper class that we pass to SocketStreamDispatcherHost so that it can find 64 // Helper class that we pass to SocketStreamDispatcherHost so that it can find
63 // the right net::URLRequestContext for a request. 65 // the right net::URLRequestContext for a request.
64 class URLRequestContextSelector 66 class URLRequestContextSelector
65 : public ResourceMessageFilter::URLRequestContextSelector { 67 : public ResourceMessageFilter::URLRequestContextSelector {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 189
188 process_->Launch( 190 process_->Launch(
189 #if defined(OS_WIN) 191 #if defined(OS_WIN)
190 FilePath(), 192 FilePath(),
191 #elif defined(OS_POSIX) 193 #elif defined(OS_POSIX)
192 use_zygote, 194 use_zygote,
193 base::environment_vector(), 195 base::environment_vector(),
194 #endif 196 #endif
195 cmd_line); 197 cmd_line);
196 198
199 fileapi::FileSystemContext* file_system_context =
200 ResourceContext::GetFileSystemContext(resource_context_);
197 ChildProcessSecurityPolicyImpl::GetInstance()->AddWorker( 201 ChildProcessSecurityPolicyImpl::GetInstance()->AddWorker(
198 process_->GetData().id, render_process_id); 202 process_->GetData().id, render_process_id);
199 if (!CommandLine::ForCurrentProcess()->HasSwitch( 203 if (!CommandLine::ForCurrentProcess()->HasSwitch(
200 switches::kDisableFileSystem)) { 204 switches::kDisableFileSystem)) {
201 // Grant most file permissions to this worker. 205 // Grant most file permissions to this worker.
202 // PLATFORM_FILE_TEMPORARY, PLATFORM_FILE_HIDDEN and 206 // PLATFORM_FILE_TEMPORARY, PLATFORM_FILE_HIDDEN and
203 // PLATFORM_FILE_DELETE_ON_CLOSE are not granted, because no existing API 207 // PLATFORM_FILE_DELETE_ON_CLOSE are not granted, because no existing API
204 // requests them. 208 // requests them.
205 // This is for the filesystem sandbox. 209 // This is for the filesystem sandbox.
206 ChildProcessSecurityPolicyImpl::GetInstance()->GrantPermissionsForFile( 210 ChildProcessSecurityPolicyImpl::GetInstance()->GrantPermissionsForFile(
207 process_->GetData().id, resource_context_->GetFileSystemContext()-> 211 process_->GetData().id,
208 sandbox_provider()->new_base_path(), 212 file_system_context->sandbox_provider()->new_base_path(),
209 base::PLATFORM_FILE_OPEN | 213 base::PLATFORM_FILE_OPEN |
210 base::PLATFORM_FILE_CREATE | 214 base::PLATFORM_FILE_CREATE |
211 base::PLATFORM_FILE_OPEN_ALWAYS | 215 base::PLATFORM_FILE_OPEN_ALWAYS |
212 base::PLATFORM_FILE_CREATE_ALWAYS | 216 base::PLATFORM_FILE_CREATE_ALWAYS |
213 base::PLATFORM_FILE_OPEN_TRUNCATED | 217 base::PLATFORM_FILE_OPEN_TRUNCATED |
214 base::PLATFORM_FILE_READ | 218 base::PLATFORM_FILE_READ |
215 base::PLATFORM_FILE_WRITE | 219 base::PLATFORM_FILE_WRITE |
216 base::PLATFORM_FILE_EXCLUSIVE_READ | 220 base::PLATFORM_FILE_EXCLUSIVE_READ |
217 base::PLATFORM_FILE_EXCLUSIVE_WRITE | 221 base::PLATFORM_FILE_EXCLUSIVE_WRITE |
218 base::PLATFORM_FILE_ASYNC | 222 base::PLATFORM_FILE_ASYNC |
219 base::PLATFORM_FILE_WRITE_ATTRIBUTES | 223 base::PLATFORM_FILE_WRITE_ATTRIBUTES |
220 base::PLATFORM_FILE_ENUMERATE); 224 base::PLATFORM_FILE_ENUMERATE);
221 // This is so that we can read and move stuff out of the old filesystem 225 // This is so that we can read and move stuff out of the old filesystem
222 // sandbox. 226 // sandbox.
223 ChildProcessSecurityPolicyImpl::GetInstance()->GrantPermissionsForFile( 227 ChildProcessSecurityPolicyImpl::GetInstance()->GrantPermissionsForFile(
224 process_->GetData().id, resource_context_->GetFileSystemContext()-> 228 process_->GetData().id,
225 sandbox_provider()->old_base_path(), 229 file_system_context->sandbox_provider()->old_base_path(),
226 base::PLATFORM_FILE_READ | base::PLATFORM_FILE_WRITE | 230 base::PLATFORM_FILE_READ | base::PLATFORM_FILE_WRITE |
227 base::PLATFORM_FILE_WRITE_ATTRIBUTES | 231 base::PLATFORM_FILE_WRITE_ATTRIBUTES |
228 base::PLATFORM_FILE_ENUMERATE); 232 base::PLATFORM_FILE_ENUMERATE);
229 // This is so that we can rename the old sandbox out of the way so that 233 // This is so that we can rename the old sandbox out of the way so that
230 // we know we've taken care of it. 234 // we know we've taken care of it.
231 ChildProcessSecurityPolicyImpl::GetInstance()->GrantPermissionsForFile( 235 ChildProcessSecurityPolicyImpl::GetInstance()->GrantPermissionsForFile(
232 process_->GetData().id, resource_context_->GetFileSystemContext()-> 236 process_->GetData().id,
233 sandbox_provider()->renamed_old_base_path(), 237 file_system_context->sandbox_provider()->renamed_old_base_path(),
234 base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_CREATE_ALWAYS | 238 base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_CREATE_ALWAYS |
235 base::PLATFORM_FILE_WRITE); 239 base::PLATFORM_FILE_WRITE);
236 } 240 }
237 241
238 CreateMessageFilters(render_process_id); 242 CreateMessageFilters(render_process_id);
239 243
240 return true; 244 return true;
241 } 245 }
242 246
243 void WorkerProcessHost::CreateMessageFilters(int render_process_id) { 247 void WorkerProcessHost::CreateMessageFilters(int render_process_id) {
244 net::URLRequestContext* request_context = 248 net::URLRequestContext* request_context =
245 resource_context_->GetRequestContext(); 249 resource_context_->GetRequestContext();
246 250
247 ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter( 251 ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter(
248 process_->GetData().id, content::PROCESS_TYPE_WORKER, resource_context_, 252 process_->GetData().id, content::PROCESS_TYPE_WORKER, resource_context_,
249 new URLRequestContextSelector(request_context)); 253 new URLRequestContextSelector(request_context));
250 process_->GetHost()->AddFilter(resource_message_filter); 254 process_->GetHost()->AddFilter(resource_message_filter);
251 255
252 worker_message_filter_ = new WorkerMessageFilter( 256 worker_message_filter_ = new WorkerMessageFilter(
253 render_process_id, resource_context_, 257 render_process_id, resource_context_,
254 base::Bind(&WorkerServiceImpl::next_worker_route_id, 258 base::Bind(&WorkerServiceImpl::next_worker_route_id,
255 base::Unretained(WorkerServiceImpl::GetInstance()))); 259 base::Unretained(WorkerServiceImpl::GetInstance())));
256 process_->GetHost()->AddFilter(worker_message_filter_); 260 process_->GetHost()->AddFilter(worker_message_filter_);
257 process_->GetHost()->AddFilter(new AppCacheDispatcherHost( 261 process_->GetHost()->AddFilter(new AppCacheDispatcherHost(
258 resource_context_->GetAppCacheService(), process_->GetData().id)); 262 static_cast<ChromeAppCacheService*>(
263 ResourceContext::GetAppCacheService(resource_context_)),
264 process_->GetData().id));
259 process_->GetHost()->AddFilter(new FileSystemDispatcherHost( 265 process_->GetHost()->AddFilter(new FileSystemDispatcherHost(
260 request_context, resource_context_->GetFileSystemContext())); 266 request_context,
267 ResourceContext::GetFileSystemContext(resource_context_)));
261 process_->GetHost()->AddFilter(new FileUtilitiesMessageFilter( 268 process_->GetHost()->AddFilter(new FileUtilitiesMessageFilter(
262 process_->GetData().id)); 269 process_->GetData().id));
263 process_->GetHost()->AddFilter(new BlobMessageFilter( 270 process_->GetHost()->AddFilter(new BlobMessageFilter(
264 process_->GetData().id, resource_context_->GetBlobStorageContext())); 271 process_->GetData().id,
272 content::GetChromeBlobStorageContextForResourceContext(
273 resource_context_)));
265 process_->GetHost()->AddFilter(new MimeRegistryMessageFilter()); 274 process_->GetHost()->AddFilter(new MimeRegistryMessageFilter());
266 process_->GetHost()->AddFilter(new DatabaseMessageFilter( 275 process_->GetHost()->AddFilter(new DatabaseMessageFilter(
267 resource_context_->GetDatabaseTracker())); 276 content::GetDatabaseTrackerForResourceContext(resource_context_)));
268 277
269 SocketStreamDispatcherHost* socket_stream_dispatcher_host = 278 SocketStreamDispatcherHost* socket_stream_dispatcher_host =
270 new SocketStreamDispatcherHost( 279 new SocketStreamDispatcherHost(
271 new URLRequestContextSelector(request_context), resource_context_); 280 new URLRequestContextSelector(request_context), resource_context_);
272 process_->GetHost()->AddFilter(socket_stream_dispatcher_host); 281 process_->GetHost()->AddFilter(socket_stream_dispatcher_host);
273 process_->GetHost()->AddFilter( 282 process_->GetHost()->AddFilter(
274 new content::WorkerDevToolsMessageFilter(process_->GetData().id)); 283 new content::WorkerDevToolsMessageFilter(process_->GetData().id));
275 process_->GetHost()->AddFilter(new IndexedDBDispatcherHost( 284 process_->GetHost()->AddFilter(new IndexedDBDispatcherHost(
276 process_->GetData().id, resource_context_->GetWebKitContext())); 285 process_->GetData().id,
286 content::GetWebKitContextForResourceContext(resource_context_)));
277 } 287 }
278 288
279 void WorkerProcessHost::CreateWorker(const WorkerInstance& instance) { 289 void WorkerProcessHost::CreateWorker(const WorkerInstance& instance) {
280 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( 290 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL(
281 process_->GetData().id, instance.url()); 291 process_->GetData().id, instance.url());
282 292
283 instances_.push_back(instance); 293 instances_.push_back(instance);
284 294
285 WorkerProcessMsg_CreateWorker_Params params; 295 WorkerProcessMsg_CreateWorker_Params params;
286 params.url = instance.url(); 296 params.url = instance.url();
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 } 675 }
666 } 676 }
667 return false; 677 return false;
668 } 678 }
669 679
670 WorkerProcessHost::WorkerInstance::FilterInfo 680 WorkerProcessHost::WorkerInstance::FilterInfo
671 WorkerProcessHost::WorkerInstance::GetFilter() const { 681 WorkerProcessHost::WorkerInstance::GetFilter() const {
672 DCHECK(NumFilters() == 1); 682 DCHECK(NumFilters() == 1);
673 return *filters_.begin(); 683 return *filters_.begin();
674 } 684 }
OLDNEW
« no previous file with comments | « content/browser/resource_context_impl.cc ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698