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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 } // namespace | 85 } // namespace |
86 | 86 |
87 // Notifies RenderViewHost that one or more worker objects crashed. | 87 // Notifies RenderViewHost that one or more worker objects crashed. |
88 void WorkerCrashCallback(int render_process_unique_id, int render_view_id) { | 88 void WorkerCrashCallback(int render_process_unique_id, int render_view_id) { |
89 RenderViewHostImpl* host = | 89 RenderViewHostImpl* host = |
90 RenderViewHostImpl::FromID(render_process_unique_id, render_view_id); | 90 RenderViewHostImpl::FromID(render_process_unique_id, render_view_id); |
91 if (host) | 91 if (host) |
92 host->GetDelegate()->WorkerCrashed(); | 92 host->GetDelegate()->WorkerCrashed(); |
93 } | 93 } |
94 | 94 |
95 WorkerProcessHost::WorkerProcessHost(content::ResourceContext* resource_context) | 95 WorkerProcessHost::WorkerProcessHost(ResourceContext* resource_context) |
96 : resource_context_(resource_context) { | 96 : resource_context_(resource_context) { |
97 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 97 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
98 DCHECK(resource_context); | 98 DCHECK(resource_context); |
99 process_.reset( | 99 process_.reset( |
100 new BrowserChildProcessHostImpl(content::PROCESS_TYPE_WORKER, this)); | 100 new BrowserChildProcessHostImpl(content::PROCESS_TYPE_WORKER, this)); |
101 } | 101 } |
102 | 102 |
103 WorkerProcessHost::~WorkerProcessHost() { | 103 WorkerProcessHost::~WorkerProcessHost() { |
104 // If we crashed, tell the RenderViewHosts. | 104 // If we crashed, tell the RenderViewHosts. |
105 for (Instances::iterator i = instances_.begin(); i != instances_.end(); ++i) { | 105 for (Instances::iterator i = instances_.begin(); i != instances_.end(); ++i) { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 process_->Launch( | 191 process_->Launch( |
192 #if defined(OS_WIN) | 192 #if defined(OS_WIN) |
193 FilePath(), | 193 FilePath(), |
194 #elif defined(OS_POSIX) | 194 #elif defined(OS_POSIX) |
195 use_zygote, | 195 use_zygote, |
196 base::EnvironmentVector(), | 196 base::EnvironmentVector(), |
197 #endif | 197 #endif |
198 cmd_line); | 198 cmd_line); |
199 | 199 |
200 fileapi::FileSystemContext* file_system_context = | 200 fileapi::FileSystemContext* file_system_context = |
201 ResourceContext::GetFileSystemContext(resource_context_); | 201 GetFileSystemContextForResourceContext(resource_context_); |
202 ChildProcessSecurityPolicyImpl::GetInstance()->AddWorker( | 202 ChildProcessSecurityPolicyImpl::GetInstance()->AddWorker( |
203 process_->GetData().id, render_process_id); | 203 process_->GetData().id, render_process_id); |
204 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 204 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
205 switches::kDisableFileSystem)) { | 205 switches::kDisableFileSystem)) { |
206 // Grant most file permissions to this worker. | 206 // Grant most file permissions to this worker. |
207 // PLATFORM_FILE_TEMPORARY, PLATFORM_FILE_HIDDEN and | 207 // PLATFORM_FILE_TEMPORARY, PLATFORM_FILE_HIDDEN and |
208 // PLATFORM_FILE_DELETE_ON_CLOSE are not granted, because no existing API | 208 // PLATFORM_FILE_DELETE_ON_CLOSE are not granted, because no existing API |
209 // requests them. | 209 // requests them. |
210 // This is for the filesystem sandbox. | 210 // This is for the filesystem sandbox. |
211 ChildProcessSecurityPolicyImpl::GetInstance()->GrantPermissionsForFile( | 211 ChildProcessSecurityPolicyImpl::GetInstance()->GrantPermissionsForFile( |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 base::Bind(&WorkerServiceImpl::next_worker_route_id, | 259 base::Bind(&WorkerServiceImpl::next_worker_route_id, |
260 base::Unretained(WorkerServiceImpl::GetInstance()))); | 260 base::Unretained(WorkerServiceImpl::GetInstance()))); |
261 process_->GetHost()->AddFilter(worker_message_filter_); | 261 process_->GetHost()->AddFilter(worker_message_filter_); |
262 process_->GetHost()->AddFilter(new AppCacheDispatcherHost( | 262 process_->GetHost()->AddFilter(new AppCacheDispatcherHost( |
263 static_cast<ChromeAppCacheService*>( | 263 static_cast<ChromeAppCacheService*>( |
264 ResourceContext::GetAppCacheService(resource_context_)), | 264 ResourceContext::GetAppCacheService(resource_context_)), |
265 process_->GetData().id)); | 265 process_->GetData().id)); |
266 process_->GetHost()->AddFilter(new FileAPIMessageFilter( | 266 process_->GetHost()->AddFilter(new FileAPIMessageFilter( |
267 process_->GetData().id, | 267 process_->GetData().id, |
268 request_context, | 268 request_context, |
269 ResourceContext::GetFileSystemContext(resource_context_), | 269 GetFileSystemContextForResourceContext(resource_context_), |
270 content::GetChromeBlobStorageContextForResourceContext( | 270 content::GetChromeBlobStorageContextForResourceContext( |
271 resource_context_))); | 271 resource_context_))); |
272 process_->GetHost()->AddFilter(new FileUtilitiesMessageFilter( | 272 process_->GetHost()->AddFilter(new FileUtilitiesMessageFilter( |
273 process_->GetData().id)); | 273 process_->GetData().id)); |
274 process_->GetHost()->AddFilter(new MimeRegistryMessageFilter()); | 274 process_->GetHost()->AddFilter(new MimeRegistryMessageFilter()); |
275 process_->GetHost()->AddFilter(new DatabaseMessageFilter( | 275 process_->GetHost()->AddFilter(new DatabaseMessageFilter( |
276 content::GetDatabaseTrackerForResourceContext(resource_context_))); | 276 content::GetDatabaseTrackerForResourceContext(resource_context_))); |
277 | 277 |
278 SocketStreamDispatcherHost* socket_stream_dispatcher_host = | 278 SocketStreamDispatcherHost* socket_stream_dispatcher_host = |
279 new SocketStreamDispatcherHost(render_process_id, | 279 new SocketStreamDispatcherHost(render_process_id, |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 } | 684 } |
685 } | 685 } |
686 return false; | 686 return false; |
687 } | 687 } |
688 | 688 |
689 WorkerProcessHost::WorkerInstance::FilterInfo | 689 WorkerProcessHost::WorkerInstance::FilterInfo |
690 WorkerProcessHost::WorkerInstance::GetFilter() const { | 690 WorkerProcessHost::WorkerInstance::GetFilter() const { |
691 DCHECK(NumFilters() == 1); | 691 DCHECK(NumFilters() == 1); |
692 return *filters_.begin(); | 692 return *filters_.begin(); |
693 } | 693 } |
OLD | NEW |