Index: content/browser/worker_host/worker_process_host.cc |
=================================================================== |
--- content/browser/worker_host/worker_process_host.cc (revision 118420) |
+++ content/browser/worker_host/worker_process_host.cc (working copy) |
@@ -16,6 +16,7 @@ |
#include "base/string_util.h" |
#include "base/utf_string_conversions.h" |
#include "content/browser/appcache/appcache_dispatcher_host.h" |
+#include "content/browser/browser_child_process_host.h" |
#include "content/browser/child_process_security_policy.h" |
#include "content/browser/debugger/worker_devtools_message_filter.h" |
#include "content/browser/file_system/file_system_dispatcher_host.h" |
@@ -48,6 +49,7 @@ |
#include "webkit/glue/resource_type.h" |
using content::BrowserThread; |
+using content::ChildProcessData; |
using content::ChildProcessHost; |
using content::UserMetricsAction; |
using content::WorkerServiceImpl; |
@@ -86,10 +88,11 @@ |
WorkerProcessHost::WorkerProcessHost( |
const content::ResourceContext* resource_context) |
- : BrowserChildProcessHost(content::PROCESS_TYPE_WORKER), |
- resource_context_(resource_context) { |
+ : resource_context_(resource_context) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
DCHECK(resource_context); |
+ process_.reset(new BrowserChildProcessHost( |
+ content::PROCESS_TYPE_WORKER, this)); |
} |
WorkerProcessHost::~WorkerProcessHost() { |
@@ -108,11 +111,15 @@ |
this, i->worker_route_id()); |
} |
- ChildProcessSecurityPolicy::GetInstance()->Remove(data().id); |
+ ChildProcessSecurityPolicy::GetInstance()->Remove(process_->GetData().id); |
} |
+bool WorkerProcessHost::Send(IPC::Message* message) { |
+ return process_->Send(message); |
+} |
+ |
bool WorkerProcessHost::Init(int render_process_id) { |
- std::string channel_id = child_process_host()->CreateChannel(); |
+ std::string channel_id = process_->GetHost()->CreateChannel(); |
if (channel_id.empty()) |
return false; |
@@ -175,7 +182,7 @@ |
} |
#endif |
- Launch( |
+ process_->Launch( |
#if defined(OS_WIN) |
FilePath(), |
#elif defined(OS_POSIX) |
@@ -185,7 +192,7 @@ |
cmd_line); |
ChildProcessSecurityPolicy::GetInstance()->AddWorker( |
- data().id, render_process_id); |
+ process_->GetData().id, render_process_id); |
if (!CommandLine::ForCurrentProcess()->HasSwitch( |
switches::kDisableFileSystem)) { |
// Grant most file permissions to this worker. |
@@ -194,7 +201,7 @@ |
// requests them. |
// This is for the filesystem sandbox. |
ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile( |
- data().id, resource_context_->file_system_context()-> |
+ process_->GetData().id, resource_context_->file_system_context()-> |
sandbox_provider()->new_base_path(), |
base::PLATFORM_FILE_OPEN | |
base::PLATFORM_FILE_CREATE | |
@@ -211,7 +218,7 @@ |
// This is so that we can read and move stuff out of the old filesystem |
// sandbox. |
ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile( |
- data().id, resource_context_->file_system_context()-> |
+ process_->GetData().id, resource_context_->file_system_context()-> |
sandbox_provider()->old_base_path(), |
base::PLATFORM_FILE_READ | base::PLATFORM_FILE_WRITE | |
base::PLATFORM_FILE_WRITE_ATTRIBUTES | |
@@ -219,7 +226,7 @@ |
// This is so that we can rename the old sandbox out of the way so that |
// we know we've taken care of it. |
ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile( |
- data().id, resource_context_->file_system_context()-> |
+ process_->GetData().id, resource_context_->file_system_context()-> |
sandbox_provider()->renamed_old_base_path(), |
base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_CREATE_ALWAYS | |
base::PLATFORM_FILE_WRITE); |
@@ -236,37 +243,38 @@ |
resource_context_->request_context(); |
ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter( |
- data().id, content::PROCESS_TYPE_WORKER, resource_context_, |
+ process_->GetData().id, content::PROCESS_TYPE_WORKER, resource_context_, |
new URLRequestContextSelector(request_context)); |
- child_process_host()->AddFilter(resource_message_filter); |
+ process_->GetHost()->AddFilter(resource_message_filter); |
worker_message_filter_ = new WorkerMessageFilter( |
render_process_id, resource_context_, |
base::Bind(&WorkerServiceImpl::next_worker_route_id, |
base::Unretained(WorkerServiceImpl::GetInstance()))); |
- child_process_host()->AddFilter(worker_message_filter_); |
- child_process_host()->AddFilter(new AppCacheDispatcherHost( |
- resource_context_->appcache_service(), data().id)); |
- child_process_host()->AddFilter(new FileSystemDispatcherHost( |
+ process_->GetHost()->AddFilter(worker_message_filter_); |
+ process_->GetHost()->AddFilter(new AppCacheDispatcherHost( |
+ resource_context_->appcache_service(), process_->GetData().id)); |
+ process_->GetHost()->AddFilter(new FileSystemDispatcherHost( |
request_context, resource_context_->file_system_context())); |
- child_process_host()->AddFilter(new FileUtilitiesMessageFilter(data().id)); |
- child_process_host()->AddFilter(new BlobMessageFilter( |
- data().id, resource_context_->blob_storage_context())); |
- child_process_host()->AddFilter(new MimeRegistryMessageFilter()); |
- child_process_host()->AddFilter(new DatabaseMessageFilter( |
+ process_->GetHost()->AddFilter(new FileUtilitiesMessageFilter( |
+ process_->GetData().id)); |
+ process_->GetHost()->AddFilter(new BlobMessageFilter( |
+ process_->GetData().id, resource_context_->blob_storage_context())); |
+ process_->GetHost()->AddFilter(new MimeRegistryMessageFilter()); |
+ process_->GetHost()->AddFilter(new DatabaseMessageFilter( |
resource_context_->database_tracker())); |
SocketStreamDispatcherHost* socket_stream_dispatcher_host = |
new SocketStreamDispatcherHost( |
new URLRequestContextSelector(request_context), resource_context_); |
- child_process_host()->AddFilter(socket_stream_dispatcher_host); |
- child_process_host()->AddFilter( |
- new content::WorkerDevToolsMessageFilter(data().id)); |
+ process_->GetHost()->AddFilter(socket_stream_dispatcher_host); |
+ process_->GetHost()->AddFilter( |
+ new content::WorkerDevToolsMessageFilter(process_->GetData().id)); |
} |
void WorkerProcessHost::CreateWorker(const WorkerInstance& instance) { |
ChildProcessSecurityPolicy::GetInstance()->GrantRequestURL( |
- data().id, instance.url()); |
+ process_->GetData().id, instance.url()); |
instances_.push_back(instance); |
@@ -320,7 +328,8 @@ |
NOTREACHED(); |
content::RecordAction(UserMetricsAction("BadMessageTerminate_WPH")); |
base::KillProcess( |
- data().handle, content::RESULT_CODE_KILLED_BAD_MESSAGE, false); |
+ process_->GetData().handle, content::RESULT_CODE_KILLED_BAD_MESSAGE, |
+ false); |
} |
if (handled) |
@@ -490,7 +499,7 @@ |
display_title += *i; |
} |
- SetName(ASCIIToUTF16(display_title)); |
+ process_->SetName(ASCIIToUTF16(display_title)); |
} |
void WorkerProcessHost::DocumentDetached(WorkerMessageFilter* filter, |
@@ -512,6 +521,10 @@ |
Send(new WorkerMsg_TerminateWorkerContext(worker_route_id)); |
} |
+const ChildProcessData& WorkerProcessHost::GetData() { |
+ return process_->GetData(); |
+} |
+ |
WorkerProcessHost::WorkerInstance::WorkerInstance( |
const GURL& url, |
const string16& name, |