diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-31 17:27:45 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-31 17:27:45 +0000 |
commit | 76543b9c43515c8c68413b25d682b7c15a151905 (patch) | |
tree | 3fa26b07a2de8102561d5ded5828797fa9a375ab /chrome/browser/worker_host | |
parent | f341f8f58ceeae4efe38daf3c26ad4581f98fd2d (diff) | |
download | chromium_src-76543b9c43515c8c68413b25d682b7c15a151905.zip chromium_src-76543b9c43515c8c68413b25d682b7c15a151905.tar.gz chromium_src-76543b9c43515c8c68413b25d682b7c15a151905.tar.bz2 |
Replace the RenderProcessHost.PID function that returns the OS-generated
process ID with an internally-generated id() function. This allows us the
guarantee that the IDs are unique over the entire run of the application.
This also cleans up some code associated with managing the PID.
The main potentially interesting change is now the PID is set uniquely for
every creation of RenderProcessHost. It used to be set cleared if the process
went away, and re-set if the process was re-created. The ID generation is in
ChildProcesInfo so it is also unique between workers and plugins. I had to
change some significant things in resource_dispatcher_host_unittest to take
into account this new generation of IDs.
BUG=17828
TEST=none
Review URL: http://codereview.chromium.org/160203
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24899 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/worker_host')
-rw-r--r-- | chrome/browser/worker_host/worker_process_host.cc | 27 | ||||
-rw-r--r-- | chrome/browser/worker_host/worker_process_host.h | 4 | ||||
-rw-r--r-- | chrome/browser/worker_host/worker_service.cc | 19 | ||||
-rw-r--r-- | chrome/browser/worker_host/worker_service.h | 8 |
4 files changed, 29 insertions, 29 deletions
diff --git a/chrome/browser/worker_host/worker_process_host.cc b/chrome/browser/worker_host/worker_process_host.cc index 69d3a96..9570743 100644 --- a/chrome/browser/worker_host/worker_process_host.cc +++ b/chrome/browser/worker_host/worker_process_host.cc @@ -40,13 +40,13 @@ // Notifies RenderViewHost that one or more worker objects crashed. class WorkerCrashTask : public Task { public: - WorkerCrashTask(int render_process_id, int render_view_id) - : render_process_id_(render_process_id), + WorkerCrashTask(int render_process_unique_id, int render_view_id) + : render_process_unique_id_(render_process_unique_id), render_view_id_(render_view_id) { } void Run() { RenderViewHost* host = - RenderViewHost::FromID(render_process_id_, render_view_id_); + RenderViewHost::FromID(render_process_unique_id_, render_view_id_); if (host) { RenderViewHostDelegate::BrowserIntegration* integration_delegate = host->delegate()->GetBrowserIntegrationDelegate(); @@ -56,7 +56,7 @@ class WorkerCrashTask : public Task { } private: - int render_process_id_; + int render_process_unique_id_; int render_view_id_; }; @@ -79,10 +79,10 @@ WorkerProcessHost::~WorkerProcessHost() { MessageLoop* ui_loop = WorkerService::GetInstance()->ui_loop(); for (Instances::iterator i = instances_.begin(); i != instances_.end(); ++i) { ui_loop->PostTask(FROM_HERE, new WorkerCrashTask( - i->renderer_process_id, i->render_view_route_id)); + i->renderer_id, i->render_view_route_id)); } - ChildProcessSecurityPolicy::GetInstance()->Remove(GetProcessId()); + ChildProcessSecurityPolicy::GetInstance()->Remove(id()); } bool WorkerProcessHost::Init() { @@ -128,14 +128,14 @@ bool WorkerProcessHost::Init() { return false; SetHandle(process); - ChildProcessSecurityPolicy::GetInstance()->Add(GetProcessId()); + ChildProcessSecurityPolicy::GetInstance()->Add(id()); return true; } void WorkerProcessHost::CreateWorker(const WorkerInstance& instance) { ChildProcessSecurityPolicy::GetInstance()->GrantRequestURL( - GetProcessId(), instance.url); + id(), instance.url); instances_.push_back(instance); Send(new WorkerProcessMsg_CreateWorker( @@ -149,7 +149,7 @@ void WorkerProcessHost::CreateWorker(const WorkerInstance& instance) { bool WorkerProcessHost::FilterMessage(const IPC::Message& message, int sender_pid) { for (Instances::iterator i = instances_.begin(); i != instances_.end(); ++i) { - if (i->sender_pid == sender_pid && + if (i->sender_id == sender_pid && i->sender_route_id == message.routing_id()) { RelayMessage( message, this, i->worker_route_id, next_route_id_callback_.get()); @@ -299,15 +299,14 @@ void WorkerProcessHost::OnCreateDedicatedWorker(const GURL& url, 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_process_id, - instances_.front().render_view_route_id, this, GetProcessId(), *route_id); + url, instances_.front().renderer_id, + instances_.front().render_view_route_id, this, id(), *route_id); } void WorkerProcessHost::OnCancelCreateDedicatedWorker(int route_id) { - WorkerService::GetInstance()->CancelCreateDedicatedWorker( - GetProcessId(), route_id); + WorkerService::GetInstance()->CancelCreateDedicatedWorker(id(), route_id); } void WorkerProcessHost::OnForwardToWorker(const IPC::Message& message) { - WorkerService::GetInstance()->ForwardMessage(message, GetProcessId()); + WorkerService::GetInstance()->ForwardMessage(message, id()); } diff --git a/chrome/browser/worker_host/worker_process_host.h b/chrome/browser/worker_host/worker_process_host.h index 648d731..65f4999 100644 --- a/chrome/browser/worker_host/worker_process_host.h +++ b/chrome/browser/worker_host/worker_process_host.h @@ -19,11 +19,11 @@ class WorkerProcessHost : public ChildProcessHost { // between the renderer and worker processes. struct WorkerInstance { GURL url; - int renderer_process_id; + int renderer_id; int render_view_route_id; int worker_route_id; IPC::Message::Sender* sender; - int sender_pid; + int sender_id; int sender_route_id; }; diff --git a/chrome/browser/worker_host/worker_service.cc b/chrome/browser/worker_host/worker_service.cc index df8ba51..a8ce3f0 100644 --- a/chrome/browser/worker_host/worker_service.cc +++ b/chrome/browser/worker_host/worker_service.cc @@ -48,10 +48,10 @@ WorkerService::~WorkerService() { } bool WorkerService::CreateDedicatedWorker(const GURL &url, - int renderer_process_id, + int renderer_id, int render_view_route_id, IPC::Message::Sender* sender, - int sender_pid, + 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 @@ -59,11 +59,11 @@ bool WorkerService::CreateDedicatedWorker(const GURL &url, // it to. WorkerProcessHost::WorkerInstance instance; instance.url = url; - instance.renderer_process_id = renderer_process_id; + 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_pid = sender_pid; + instance.sender_id = sender_id; instance.sender_route_id = sender_route_id; WorkerProcessHost* worker = NULL; @@ -92,11 +92,12 @@ bool WorkerService::CreateDedicatedWorker(const GURL &url, return true; } -void WorkerService::CancelCreateDedicatedWorker(int sender_pid, +void WorkerService::CancelCreateDedicatedWorker(int sender_id, int sender_route_id) { for (WorkerProcessHost::Instances::iterator i = queued_workers_.begin(); i != queued_workers_.end(); ++i) { - if (i->sender_pid == sender_pid && i->sender_route_id == sender_route_id) { + if (i->sender_id == sender_id && + i->sender_route_id == sender_route_id) { queued_workers_.erase(i); return; } @@ -111,12 +112,12 @@ void WorkerService::CancelCreateDedicatedWorker(int sender_pid, for (WorkerProcessHost::Instances::const_iterator instance = worker->instances().begin(); instance != worker->instances().end(); ++instance) { - if (instance->sender_pid == sender_pid && + if (instance->sender_id == sender_id && instance->sender_route_id == sender_route_id) { // Fake a worker destroyed message so that WorkerProcessHost cleans up // properly. WorkerHostMsg_WorkerContextDestroyed msg(sender_route_id); - ForwardMessage(msg, sender_pid); + ForwardMessage(msg, sender_id); return; } } @@ -198,7 +199,7 @@ bool WorkerService::CanCreateWorkerProcess( total_workers++; if (total_workers >= kMaxWorkersWhenSeparate) return false; - if (cur_instance->renderer_process_id == instance.renderer_process_id && + if (cur_instance->renderer_id == instance.renderer_id && cur_instance->render_view_route_id == instance.render_view_route_id) { workers_per_tab++; if (workers_per_tab >= kMaxWorkersPerTabWhenSeparate) diff --git a/chrome/browser/worker_host/worker_service.h b/chrome/browser/worker_host/worker_service.h index b7cb6e0..0887b32 100644 --- a/chrome/browser/worker_host/worker_service.h +++ b/chrome/browser/worker_host/worker_service.h @@ -29,18 +29,18 @@ class WorkerService : public NotificationObserver { // Creates a dedicated worker. Returns true on success. bool CreateDedicatedWorker(const GURL &url, - int renderer_process_id, + int renderer_pid, int render_view_route_id, IPC::Message::Sender* sender, - int sender_pid, + int sender_id, int sender_route_id); // Cancel creation of a dedicated worker that hasn't started yet. - void CancelCreateDedicatedWorker(int sender_pid, int sender_route_id); + void CancelCreateDedicatedWorker(int sender_id, int sender_route_id); // Called by the worker creator when a message arrives that should be // forwarded to the worker process. - void ForwardMessage(const IPC::Message& message, int sender_pid); + void ForwardMessage(const IPC::Message& message, int sender_id); MessageLoop* ui_loop() { return ui_loop_; } |