diff options
author | atwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-05 16:27:06 +0000 |
---|---|---|
committer | atwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-05 16:27:06 +0000 |
commit | 6898bbedb15bfddf91ea125e3ffde4b1789d9bf3 (patch) | |
tree | e3950c1d597f704af541572cfc39e9874131d667 /chrome/browser/worker_host | |
parent | 1bbe5f61a331b2fb3cd1c0e18cf3aefa7105e635 (diff) | |
download | chromium_src-6898bbedb15bfddf91ea125e3ffde4b1789d9bf3.zip chromium_src-6898bbedb15bfddf91ea125e3ffde4b1789d9bf3.tar.gz chromium_src-6898bbedb15bfddf91ea125e3ffde4b1789d9bf3.tar.bz2 |
Added beginnings of browser-process support for shared workers.
Refactored WebWorkerClientProxy into two classes - WebWorkerDispatcher which dispatches incoming IPCs for the worker, and WebWorkerClientProxy, which handles outgoing API calls from WebWorkerImpl. This allows WebWorkerClientProxy to be reused by WebSharedWorkerDispatcher.
BUG=26233
TEST=none (will enable layout tests when basic functionality available)
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=31077
Review URL: http://codereview.chromium.org/351004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31096 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/worker_host')
-rw-r--r-- | chrome/browser/worker_host/worker_process_host.cc | 21 | ||||
-rw-r--r-- | chrome/browser/worker_host/worker_process_host.h | 10 | ||||
-rw-r--r-- | chrome/browser/worker_host/worker_service.cc | 16 | ||||
-rw-r--r-- | chrome/browser/worker_host/worker_service.h | 14 |
4 files changed, 37 insertions, 24 deletions
diff --git a/chrome/browser/worker_host/worker_process_host.cc b/chrome/browser/worker_host/worker_process_host.cc index eb6d2fe..02e3cc6 100644 --- a/chrome/browser/worker_host/worker_process_host.cc +++ b/chrome/browser/worker_host/worker_process_host.cc @@ -139,8 +139,10 @@ void WorkerProcessHost::CreateWorker(const WorkerInstance& instance) { id(), instance.url); instances_.push_back(instance); - Send(new WorkerProcessMsg_CreateWorker( - instance.url, instance.worker_route_id)); + Send(new WorkerProcessMsg_CreateWorker(instance.url, + instance.is_shared, + instance.name, + instance.worker_route_id)); UpdateTitle(); instances_.back().sender->Send( @@ -175,8 +177,7 @@ void WorkerProcessHost::OnMessageReceived(const IPC::Message& message) { if (!handled) { handled = true; IPC_BEGIN_MESSAGE_MAP_EX(WorkerProcessHost, message, msg_is_ok) - IPC_MESSAGE_HANDLER(ViewHostMsg_CreateDedicatedWorker, - OnCreateDedicatedWorker) + IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWorker, OnCreateWorker) IPC_MESSAGE_HANDLER(ViewHostMsg_CancelCreateDedicatedWorker, OnCancelCreateDedicatedWorker) IPC_MESSAGE_HANDLER(ViewHostMsg_ForwardToWorker, @@ -321,13 +322,15 @@ void WorkerProcessHost::UpdateTitle() { set_name(ASCIIToWide(display_title)); } -void WorkerProcessHost::OnCreateDedicatedWorker(const GURL& url, - int render_view_route_id, - int* route_id) { +void WorkerProcessHost::OnCreateWorker(const GURL& url, + bool is_shared, + const string16& name, + int render_view_route_id, + int* route_id) { DCHECK(instances_.size() == 1); // Only called when one process per worker. *route_id = WorkerService::GetInstance()->next_worker_route_id(); - WorkerService::GetInstance()->CreateDedicatedWorker( - url, instances_.front().renderer_id, + WorkerService::GetInstance()->CreateWorker( + url, is_shared, name, instances_.front().renderer_id, instances_.front().render_view_route_id, this, id(), *route_id); } diff --git a/chrome/browser/worker_host/worker_process_host.h b/chrome/browser/worker_host/worker_process_host.h index 65f4999..1fae373 100644 --- a/chrome/browser/worker_host/worker_process_host.h +++ b/chrome/browser/worker_host/worker_process_host.h @@ -19,6 +19,8 @@ class WorkerProcessHost : public ChildProcessHost { // between the renderer and worker processes. struct WorkerInstance { GURL url; + bool is_shared; + string16 name; int renderer_id; int render_view_route_id; int worker_route_id; @@ -73,9 +75,11 @@ class WorkerProcessHost : public ChildProcessHost { // Updates the title shown in the task manager. void UpdateTitle(); - void OnCreateDedicatedWorker(const GURL& url, - int render_view_route_id, - int* route_id); + void OnCreateWorker(const GURL& url, + bool is_shared, + const string16& name, + int render_view_route_id, + int* route_id); void OnCancelCreateDedicatedWorker(int route_id); void OnForwardToWorker(const IPC::Message& message); diff --git a/chrome/browser/worker_host/worker_service.cc b/chrome/browser/worker_host/worker_service.cc index a54bb2a..334917f 100644 --- a/chrome/browser/worker_host/worker_service.cc +++ b/chrome/browser/worker_host/worker_service.cc @@ -44,24 +44,28 @@ void WorkerService::Initialize(ResourceDispatcherHost* rdh) { WorkerService::~WorkerService() { } -bool WorkerService::CreateDedicatedWorker(const GURL &url, - int renderer_id, - int render_view_route_id, - IPC::Message::Sender* sender, - int sender_id, - int sender_route_id) { +bool WorkerService::CreateWorker(const GURL &url, + bool is_shared, + const string16& name, + int renderer_id, + int render_view_route_id, + IPC::Message::Sender* sender, + int sender_id, + int sender_route_id) { // Generate a unique route id for the browser-worker communication that's // unique among all worker processes. That way when the worker process sends // a wrapped IPC message through us, we know which WorkerProcessHost to give // it to. WorkerProcessHost::WorkerInstance instance; instance.url = url; + instance.name = name; instance.renderer_id = renderer_id; instance.render_view_route_id = render_view_route_id; instance.worker_route_id = next_worker_route_id(); instance.sender = sender; instance.sender_id = sender_id; instance.sender_route_id = sender_route_id; + instance.is_shared = is_shared; WorkerProcessHost* worker = NULL; if (CommandLine::ForCurrentProcess()->HasSwitch( diff --git a/chrome/browser/worker_host/worker_service.h b/chrome/browser/worker_host/worker_service.h index 0bd6f58..40267aa 100644 --- a/chrome/browser/worker_host/worker_service.h +++ b/chrome/browser/worker_host/worker_service.h @@ -26,12 +26,14 @@ class WorkerService : public NotificationObserver { void Initialize(ResourceDispatcherHost* rdh); // Creates a dedicated worker. Returns true on success. - bool CreateDedicatedWorker(const GURL &url, - int renderer_pid, - int render_view_route_id, - IPC::Message::Sender* sender, - int sender_id, - int sender_route_id); + bool CreateWorker(const GURL &url, + bool is_shared, + const string16& name, + int renderer_pid, + int render_view_route_id, + IPC::Message::Sender* sender, + int sender_id, + int sender_route_id); // Cancel creation of a dedicated worker that hasn't started yet. void CancelCreateDedicatedWorker(int sender_id, int sender_route_id); |