summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-24 02:01:11 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-24 02:01:11 +0000
commitfd09950346afe96c4d86d37d98fd45003872ab3f (patch)
tree115466bfb6c258ef2b190bbea6c02f0e53b17582 /chrome
parent06fc8e6e54172eecff83e72fa36d038f26403328 (diff)
downloadchromium_src-fd09950346afe96c4d86d37d98fd45003872ab3f.zip
chromium_src-fd09950346afe96c4d86d37d98fd45003872ab3f.tar.gz
chromium_src-fd09950346afe96c4d86d37d98fd45003872ab3f.tar.bz2
Finish hooking up the worker process UI: use the domains of the workers as the title in the task manager, and show an infobar when a page's workers die.
I also cleaned up the code in RenderView which creates a window and widget, since when I originally wrote it I wasn't aware of RenderViewHost::FromID. Review URL: http://codereview.chromium.org/45025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12335 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/generated_resources.grd3
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc8
-rw-r--r--chrome/browser/renderer_host/render_view_host.h8
-rw-r--r--chrome/browser/renderer_host/render_view_host_delegate.h3
-rw-r--r--chrome/browser/renderer_host/render_widget_helper.cc24
-rw-r--r--chrome/browser/renderer_host/render_widget_helper.h6
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.cc4
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.h6
-rw-r--r--chrome/browser/tab_contents/web_contents.cc6
-rw-r--r--chrome/browser/tab_contents/web_contents.h1
-rw-r--r--chrome/browser/worker_host/worker_process_host.cc60
-rw-r--r--chrome/browser/worker_host/worker_process_host.h6
-rw-r--r--chrome/browser/worker_host/worker_service.cc4
-rw-r--r--chrome/browser/worker_host/worker_service.h1
-rw-r--r--chrome/common/child_process_info.h4
-rw-r--r--chrome/common/render_messages_internal.h13
-rw-r--r--chrome/renderer/render_view.cc2
-rw-r--r--chrome/renderer/webworker_proxy.cc11
-rw-r--r--chrome/renderer/webworker_proxy.h6
19 files changed, 130 insertions, 46 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index c7c5581..b645645 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -3142,6 +3142,9 @@ each locale. -->
<message name="IDS_PLUGIN_CRASHED_PROMPT" desc="Info Bar message to notify about a crashed plugin">
The following plug-in has crashed : <ph name="PLUGIN_NAME">$1<ex>Shockwave</ex></ph>
</message>
+ <message name="IDS_WEBWORKER_CRASHED_PROMPT" desc="Info Bar message to notify about a crashed WebWorker">
+ A part of this page (HTML WebWorker) has crashed, so it might not function correctly.
+ </message>
<message name="IDS_JS_OUT_OF_MEMORY_PROMPT" desc="Info Bar message to notify JS out of memory">
Script on the page used too much memory. Reload to enable scripts again.
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index 826dff2..cb6110b 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -672,8 +672,6 @@ void RenderViewHost::OnMessageReceived(const IPC::Message& msg) {
bool msg_is_ok = true;
IPC_BEGIN_MESSAGE_MAP_EX(RenderViewHost, msg, msg_is_ok)
- IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWindowWithRoute, OnMsgCreateWindow)
- IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWidgetWithRoute, OnMsgCreateWidget)
IPC_MESSAGE_HANDLER(ViewHostMsg_ShowView, OnMsgShowView)
IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnMsgShowWidget)
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunModal, OnMsgRunModal)
@@ -785,8 +783,8 @@ void RenderViewHost::Shutdown() {
RenderWidgetHost::Shutdown();
}
-void RenderViewHost::OnMsgCreateWindow(int route_id,
- ModalDialogEvent modal_dialog_event) {
+void RenderViewHost::CreateNewWindow(int route_id,
+ ModalDialogEvent modal_dialog_event) {
RenderViewHostDelegate::View* view = delegate_->GetViewDelegate();
if (!view)
return;
@@ -800,7 +798,7 @@ void RenderViewHost::OnMsgCreateWindow(int route_id,
view->CreateNewWindow(route_id, waitable_event);
}
-void RenderViewHost::OnMsgCreateWidget(int route_id, bool activatable) {
+void RenderViewHost::CreateNewWidget(int route_id, bool activatable) {
RenderViewHostDelegate::View* view = delegate_->GetViewDelegate();
if (view)
view->CreateNewWidget(route_id, activatable);
diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h
index 31e5315..fdaf769 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -423,6 +423,12 @@ class RenderViewHost : public RenderWidgetHost {
virtual bool CanBlur() const;
virtual gfx::Rect GetRootWindowResizerRect() const;
+ // Creates a new RenderView with the given route id.
+ void CreateNewWindow(int route_id, ModalDialogEvent modal_dialog_event);
+
+ // Creates a new RenderWidget with the given route id.
+ void CreateNewWidget(int route_id, bool activatable);
+
protected:
// RenderWidgetHost protected overrides.
virtual void UnhandledKeyboardEvent(const NativeWebKeyboardEvent& event);
@@ -431,8 +437,6 @@ class RenderViewHost : public RenderWidgetHost {
virtual void NotifyRendererResponsive();
// IPC message handlers.
- void OnMsgCreateWindow(int route_id, ModalDialogEvent modal_dialog_event);
- void OnMsgCreateWidget(int route_id, bool activatable);
void OnMsgShowView(int route_id,
WindowOpenDisposition disposition,
const gfx::Rect& initial_pos,
diff --git a/chrome/browser/renderer_host/render_view_host_delegate.h b/chrome/browser/renderer_host/render_view_host_delegate.h
index 1c10c62..fc7c8c4 100644
--- a/chrome/browser/renderer_host/render_view_host_delegate.h
+++ b/chrome/browser/renderer_host/render_view_host_delegate.h
@@ -365,6 +365,9 @@ class RenderViewHostDelegate {
// Notification from the renderer that a plugin instance has crashed.
virtual void OnCrashedPlugin(const FilePath& plugin_path) { }
+ // Notification that a worker process has crashed.
+ virtual void OnCrashedWorker() { }
+
// Notification from the renderer that JS runs out of memory.
virtual void OnJSOutOfMemory() { }
diff --git a/chrome/browser/renderer_host/render_widget_helper.cc b/chrome/browser/renderer_host/render_widget_helper.cc
index 9cf1172..4432352 100644
--- a/chrome/browser/renderer_host/render_widget_helper.cc
+++ b/chrome/browser/renderer_host/render_widget_helper.cc
@@ -7,6 +7,7 @@
#include "base/thread.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/renderer_host/render_process_host.h"
+#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
#include "chrome/common/render_messages.h"
@@ -236,19 +237,16 @@ void RenderWidgetHelper::CreateNewWindow(int opener_id,
resource_dispatcher_host_->BlockRequestsForRoute(
render_process_id_, *route_id);
- // The easiest way to reach RenderViewHost is just to send a routed message.
- ViewHostMsg_CreateWindowWithRoute msg(opener_id, *route_id,
- modal_dialog_event_internal);
-
ui_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &RenderWidgetHelper::OnCreateWindowOnUI, msg, *route_id));
+ this, &RenderWidgetHelper::OnCreateWindowOnUI, opener_id, *route_id,
+ modal_dialog_event_internal));
}
void RenderWidgetHelper::OnCreateWindowOnUI(
- const IPC::Message& message, int route_id) {
- RenderProcessHost* host = RenderProcessHost::FromID(render_process_id_);
+ int opener_id, int route_id, ModalDialogEvent modal_dialog_event) {
+ RenderViewHost* host = RenderViewHost::FromID(render_process_id_, opener_id);
if (host)
- host->OnMessageReceived(message);
+ host->CreateNewWindow(route_id, modal_dialog_event);
g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
NewRunnableMethod(this, &RenderWidgetHelper::OnCreateWindowOnIO, route_id));
@@ -263,16 +261,16 @@ void RenderWidgetHelper::CreateNewWidget(int opener_id,
bool activatable,
int* route_id) {
*route_id = GetNextRoutingID();
- ViewHostMsg_CreateWidgetWithRoute msg(opener_id, *route_id, activatable);
ui_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &RenderWidgetHelper::OnCreateWidgetOnUI, msg));
+ this, &RenderWidgetHelper::OnCreateWidgetOnUI, opener_id, *route_id,
+ activatable));
}
void RenderWidgetHelper::OnCreateWidgetOnUI(
- const IPC::Message& message) {
- RenderProcessHost* host = RenderProcessHost::FromID(render_process_id_);
+ int opener_id, int route_id, bool activatable) {
+ RenderViewHost* host = RenderViewHost::FromID(render_process_id_, opener_id);
if (host)
- host->OnMessageReceived(message);
+ host->CreateNewWidget(route_id, activatable);
}
#if defined(OS_MACOSX)
diff --git a/chrome/browser/renderer_host/render_widget_helper.h b/chrome/browser/renderer_host/render_widget_helper.h
index 193a09c..e1b306e 100644
--- a/chrome/browser/renderer_host/render_widget_helper.h
+++ b/chrome/browser/renderer_host/render_widget_helper.h
@@ -155,13 +155,15 @@ class RenderWidgetHelper :
void OnDispatchPaintMsg(PaintMsgProxy* proxy);
// Called on the UI thread to finish creating a window.
- void OnCreateWindowOnUI(const IPC::Message& message, int route_id);
+ void OnCreateWindowOnUI(int opener_id,
+ int route_id,
+ ModalDialogEvent modal_dialog_event);
// Called on the IO thread after a window was created on the UI thread.
void OnCreateWindowOnIO(int route_id);
// Called on the UI thread to finish creating a widget.
- void OnCreateWidgetOnUI(const IPC::Message& message);
+ void OnCreateWidgetOnUI(int opener_id, int route_id, bool activatable);
// Called on the IO thread to cancel resource requests for the render widget.
void OnCancelResourceRequests(int render_widget_id);
diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc
index 2527ac7..8a635e0 100644
--- a/chrome/browser/renderer_host/resource_message_filter.cc
+++ b/chrome/browser/renderer_host/resource_message_filter.cc
@@ -470,9 +470,11 @@ void ResourceMessageFilter::OnOpenChannelToPlugin(const GURL& url,
}
void ResourceMessageFilter::OnCreateDedicatedWorker(const GURL& url,
+ int render_view_route_id,
int* route_id) {
*route_id = render_widget_helper_->GetNextRoutingID();
- WorkerService::GetInstance()->CreateDedicatedWorker(url, this, *route_id);
+ WorkerService::GetInstance()->CreateDedicatedWorker(
+ url, render_view_route_id, this, *route_id);
}
void ResourceMessageFilter::OnForwardToWorker(const IPC::Message& message) {
diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h
index 94b1e6e..8023d43 100644
--- a/chrome/browser/renderer_host/resource_message_filter.h
+++ b/chrome/browser/renderer_host/resource_message_filter.h
@@ -17,6 +17,7 @@
#include "base/string16.h"
#include "build/build_config.h"
#include "chrome/browser/net/resolve_proxy_msg_helper.h"
+#include "chrome/browser/renderer_host/render_widget_helper.h"
#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
#include "chrome/common/ipc_channel_proxy.h"
#include "chrome/common/modal_dialog_event.h"
@@ -92,6 +93,7 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
ResourceDispatcherHost* resource_dispatcher_host() {
return resource_dispatcher_host_;
}
+ MessageLoop* ui_loop() { return render_widget_helper_->ui_loop(); }
// NotificationObserver implementation.
virtual void Observe(NotificationType type,
@@ -137,7 +139,9 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
const std::string& clsid,
const std::wstring& locale,
IPC::Message* reply_msg);
- void OnCreateDedicatedWorker(const GURL& url, int* route_id);
+ void OnCreateDedicatedWorker(const GURL& url,
+ int render_view_route_id,
+ int* route_id);
void OnForwardToWorker(const IPC::Message& msg);
void OnDownloadUrl(const IPC::Message& message,
const GURL& url,
diff --git a/chrome/browser/tab_contents/web_contents.cc b/chrome/browser/tab_contents/web_contents.cc
index 09c58f4..fa7e904 100644
--- a/chrome/browser/tab_contents/web_contents.cc
+++ b/chrome/browser/tab_contents/web_contents.cc
@@ -1439,6 +1439,12 @@ void WebContents::OnCrashedPlugin(const FilePath& plugin_path) {
#endif
}
+void WebContents::OnCrashedWorker() {
+ AddInfoBar(new SimpleAlertInfoBarDelegate(
+ this, l10n_util::GetString(IDS_WEBWORKER_CRASHED_PROMPT),
+ NULL));
+}
+
void WebContents::OnJSOutOfMemory() {
AddInfoBar(new SimpleAlertInfoBarDelegate(
this, l10n_util::GetString(IDS_JS_OUT_OF_MEMORY_PROMPT), NULL));
diff --git a/chrome/browser/tab_contents/web_contents.h b/chrome/browser/tab_contents/web_contents.h
index 8f46524..21ca7eb 100644
--- a/chrome/browser/tab_contents/web_contents.h
+++ b/chrome/browser/tab_contents/web_contents.h
@@ -391,6 +391,7 @@ class WebContents : public TabContents,
virtual WebPreferences GetWebkitPrefs();
virtual void OnMissingPluginStatus(int status);
virtual void OnCrashedPlugin(const FilePath& plugin_path);
+ virtual void OnCrashedWorker();
virtual void OnJSOutOfMemory();
virtual void ShouldClosePage(bool proceed) {
render_manager_.ShouldClosePage(proceed);
diff --git a/chrome/browser/worker_host/worker_process_host.cc b/chrome/browser/worker_host/worker_process_host.cc
index d696df6..88b4a23 100644
--- a/chrome/browser/worker_host/worker_process_host.cc
+++ b/chrome/browser/worker_host/worker_process_host.cc
@@ -4,11 +4,15 @@
#include "chrome/browser/worker_host/worker_process_host.h"
+#include <set>
+
#include "base/command_line.h"
#include "base/debug_util.h"
#include "base/path_service.h"
#include "base/process_util.h"
+#include "base/string_util.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/renderer_host/resource_message_filter.h"
#include "chrome/browser/worker_host/worker_service.h"
#include "chrome/common/chrome_switches.h"
@@ -16,11 +20,31 @@
#include "chrome/common/process_watcher.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/worker_messages.h"
+#include "net/base/registry_controlled_domain.h"
#if defined(OS_WIN)
#include "chrome/browser/sandbox_policy.h"
#endif
+// 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),
+ render_view_id_(render_view_id) { }
+
+ void Run() {
+ RenderViewHost* host =
+ RenderViewHost::FromID(render_process_id_, render_view_id_);
+ if (host)
+ host->delegate()->OnCrashedWorker();
+ }
+
+ private:
+ int render_process_id_;
+ int render_view_id_;
+};
+
WorkerProcessHost::WorkerProcessHost(
ResourceDispatcherHost* resource_dispatcher_host_)
@@ -28,12 +52,14 @@ WorkerProcessHost::WorkerProcessHost(
}
WorkerProcessHost::~WorkerProcessHost() {
+ // If we crashed, tell the RenderViewHost.
+ for (Instances::iterator i = instances_.begin(); i != instances_.end(); ++i) {
+ i->filter->ui_loop()->PostTask(FROM_HERE, new WorkerCrashTask(
+ i->filter->GetProcessId(), i->render_view_route_id));
+ }
}
bool WorkerProcessHost::Init() {
- // TODO(jabdelmalek): figure out what to set as the title.
- set_name(L"TBD");
-
if (!CreateChannel())
return false;
@@ -59,15 +85,20 @@ bool WorkerProcessHost::Init() {
}
void WorkerProcessHost::CreateWorker(const GURL& url,
+ int render_view_route_id,
int worker_route_id,
int renderer_route_id,
ResourceMessageFilter* filter) {
WorkerInstance instance;
+ instance.url = url;
+ instance.render_view_route_id = render_view_route_id;
instance.worker_route_id = worker_route_id;
instance.renderer_route_id = renderer_route_id;
instance.filter = filter;
instances_.push_back(instance);
Send(new WorkerProcessMsg_CreateWorker(url, worker_route_id));
+
+ UpdateTitle();
}
bool WorkerProcessHost::FilterMessage(const IPC::Message& message) {
@@ -95,6 +126,11 @@ void WorkerProcessHost::OnMessageReceived(const IPC::Message& message) {
IPC::Message* new_message = new IPC::Message(message);
new_message->set_routing_id(i->renderer_route_id);
i->filter->Send(new_message);
+
+ if (message.type() == WorkerHostMsg_WorkerContextDestroyed::ID) {
+ instances_.erase(i);
+ UpdateTitle();
+ }
break;
}
}
@@ -109,3 +145,21 @@ void WorkerProcessHost::RendererShutdown(ResourceMessageFilter* filter) {
}
}
}
+
+void WorkerProcessHost::UpdateTitle() {
+ std::set<std::string> worker_domains;
+ for (Instances::iterator i = instances_.begin(); i != instances_.end(); ++i) {
+ worker_domains.insert(
+ net::RegistryControlledDomainService::GetDomainAndRegistry(i->url));
+ }
+
+ std::string title;
+ for (std::set<std::string>::iterator i = worker_domains.begin();
+ i != worker_domains.end(); ++i) {
+ if (!title.empty())
+ title += ", ";
+ title += *i;
+ }
+
+ set_name(ASCIIToWide(title));
+}
diff --git a/chrome/browser/worker_host/worker_process_host.h b/chrome/browser/worker_host/worker_process_host.h
index 15a61e2..0a885ea 100644
--- a/chrome/browser/worker_host/worker_process_host.h
+++ b/chrome/browser/worker_host/worker_process_host.h
@@ -24,6 +24,7 @@ class WorkerProcessHost : public ChildProcessHost {
// Creates a worker object in the process.
void CreateWorker(const GURL& url,
+ int render_view_route_id,
int worker_route_id,
int renderer_route_id,
ResourceMessageFilter* filter);
@@ -43,9 +44,14 @@ class WorkerProcessHost : public ChildProcessHost {
// Called when a message arrives from the worker process.
void OnMessageReceived(const IPC::Message& message);
+ // Updates the title shown in the task manager.
+ void UpdateTitle();
+
// Contains information about each worker instance, needed to forward messages
// between the renderer and worker processes.
struct WorkerInstance {
+ GURL url;
+ int render_view_route_id;
int worker_route_id;
int renderer_route_id;
ResourceMessageFilter* filter;
diff --git a/chrome/browser/worker_host/worker_service.cc b/chrome/browser/worker_host/worker_service.cc
index 7eb5c69..675326f 100644
--- a/chrome/browser/worker_host/worker_service.cc
+++ b/chrome/browser/worker_host/worker_service.cc
@@ -23,6 +23,7 @@ WorkerService::~WorkerService() {
}
bool WorkerService::CreateDedicatedWorker(const GURL &url,
+ int render_view_route_id,
ResourceMessageFilter* filter,
int renderer_route_id) {
WorkerProcessHost* worker = NULL;
@@ -45,7 +46,8 @@ bool WorkerService::CreateDedicatedWorker(const GURL &url,
// 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.
- worker->CreateWorker(url, ++next_worker_route_id_, renderer_route_id, filter);
+ worker->CreateWorker(url, render_view_route_id, ++next_worker_route_id_,
+ renderer_route_id, filter);
return true;
}
diff --git a/chrome/browser/worker_host/worker_service.h b/chrome/browser/worker_host/worker_service.h
index 7deac0d..4f00c15 100644
--- a/chrome/browser/worker_host/worker_service.h
+++ b/chrome/browser/worker_host/worker_service.h
@@ -26,6 +26,7 @@ class WorkerService {
// Creates a dedicated worker. Returns true on success.
bool CreateDedicatedWorker(const GURL &url,
+ int render_view_route_id,
ResourceMessageFilter* filter,
int renderer_route_id);
diff --git a/chrome/common/child_process_info.h b/chrome/common/child_process_info.h
index dc37d41..0b8386b 100644
--- a/chrome/common/child_process_info.h
+++ b/chrome/common/child_process_info.h
@@ -72,11 +72,11 @@ class ChildProcessInfo {
bool operator <(const ChildProcessInfo& rhs) const {
if (process_.handle() != rhs.process_.handle())
return process_ .handle() < rhs.process_.handle();
- return name_ < rhs.name_;
+ return false;
}
bool operator ==(const ChildProcessInfo& rhs) const {
- return (process_.handle() == rhs.process_.handle()) && (name_ == rhs.name_);
+ return process_.handle() == rhs.process_.handle();
}
// Generates a unique channel name for a child renderer/plugin process.
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index d9206d1..577bde2 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -543,16 +543,6 @@ IPC_BEGIN_MESSAGES(ViewHost)
bool /* focus on show */,
int /* route_id */)
- // These two messages are sent as a result of the above two, in the browser
- // process, from RenderWidgetHelper to RenderViewHost.
- IPC_MESSAGE_ROUTED2(ViewHostMsg_CreateWindowWithRoute,
- int /* route_id */,
- ModalDialogEvent /* modal_dialog_event */)
-
- IPC_MESSAGE_ROUTED2(ViewHostMsg_CreateWidgetWithRoute,
- int /* route_id */,
- bool /* activatable */)
-
// These two messages are sent to the parent RenderViewHost to display the
// page/widget that was created by CreateView/CreateWidget. routing_id
// refers to the id that was returned from the Create message above.
@@ -1225,8 +1215,9 @@ IPC_BEGIN_MESSAGES(ViewHost)
// A renderer sends this to the browser process when it wants to create a
// worker. The browser will create the worker process if necessary, and
// will return the route id on success. On error returns MSG_ROUTING_NONE.
- IPC_SYNC_MESSAGE_CONTROL1_1(ViewHostMsg_CreateDedicatedWorker,
+ IPC_SYNC_MESSAGE_CONTROL2_1(ViewHostMsg_CreateDedicatedWorker,
GURL /* url */,
+ int /* render_view_route_id */,
int /* route_id */)
// Wraps an IPC message that's destined to the worker on the renderer->browser
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index dafb0ad..e6899dc 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -1910,7 +1910,7 @@ void RenderView::OnMissingPluginStatus(WebPluginDelegate* delegate,
WebWorker* RenderView::CreateWebWorker(WebWorkerClient* client) {
#if defined(OS_WIN)
- return new WebWorkerProxy(client);
+ return new WebWorkerProxy(client, routing_id_);
#else
// TODO(port): out of process workers
NOTIMPLEMENTED();
diff --git a/chrome/renderer/webworker_proxy.cc b/chrome/renderer/webworker_proxy.cc
index 0da55f3..43ff9f5 100644
--- a/chrome/renderer/webworker_proxy.cc
+++ b/chrome/renderer/webworker_proxy.cc
@@ -9,8 +9,12 @@
#include "chrome/renderer/render_thread.h"
#include "webkit/glue/webworkerclient.h"
-WebWorkerProxy::WebWorkerProxy(WebWorkerClient* client)
- : route_id_(MSG_ROUTING_NONE), client_(client) {
+WebWorkerProxy::WebWorkerProxy(
+ WebWorkerClient* client,
+ int render_view_route_id)
+ : route_id_(MSG_ROUTING_NONE),
+ render_view_route_id_(render_view_route_id),
+ client_(client) {
}
WebWorkerProxy::~WebWorkerProxy() {
@@ -21,7 +25,8 @@ void WebWorkerProxy::StartWorkerContext(
const string16& user_agent,
const string16& source_code) {
RenderThread::current()->Send(
- new ViewHostMsg_CreateDedicatedWorker(script_url, &route_id_));
+ new ViewHostMsg_CreateDedicatedWorker(
+ script_url, render_view_route_id_, &route_id_));
if (route_id_ == MSG_ROUTING_NONE)
return;
diff --git a/chrome/renderer/webworker_proxy.h b/chrome/renderer/webworker_proxy.h
index e068e8e..94c199d 100644
--- a/chrome/renderer/webworker_proxy.h
+++ b/chrome/renderer/webworker_proxy.h
@@ -26,7 +26,7 @@ class Message;
class WebWorkerProxy : public WebWorker,
public IPC::Channel::Listener {
public:
- WebWorkerProxy(WebWorkerClient* client);
+ WebWorkerProxy(WebWorkerClient* client, int render_view_route_id);
virtual ~WebWorkerProxy();
// WebWorker implementation.
@@ -45,8 +45,12 @@ class WebWorkerProxy : public WebWorker,
private:
bool Send(IPC::Message* message);
+ // The routing id used to reach WebWorkerClientProxy in the worker process.
int route_id_;
+ // The routing id for the RenderView that created this worker.
+ int render_view_route_id_;
+
// Used to communicate to the WebCore::Worker object in response to IPC
// messages.
WebWorkerClient* client_;