summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormichaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-06 20:40:56 +0000
committermichaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-06 20:40:56 +0000
commit14396e9b2d58eda3d5734c57a80783e2dc0a705f (patch)
tree0ef906e2df709f9201d0f37544d4519a557852ee
parentbbf362b447de9cdd023e933ae219731fc01d0571 (diff)
downloadchromium_src-14396e9b2d58eda3d5734c57a80783e2dc0a705f.zip
chromium_src-14396e9b2d58eda3d5734c57a80783e2dc0a705f.tar.gz
chromium_src-14396e9b2d58eda3d5734c57a80783e2dc0a705f.tar.bz2
More groundwork for making appcache work in workers.
Widen the IPC message used to start and initialize a worker to include the additional fields needed to initialize the appcache host for that worker. And set those values when sending that message from a renderer. BUG=39368 TEST=manual and existing tests apply Review URL: http://codereview.chromium.org/2013001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46610 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/common/render_messages.h7
-rw-r--r--chrome/renderer/render_view.cc6
-rw-r--r--chrome/renderer/websharedworker_proxy.cc7
-rw-r--r--chrome/renderer/webworker_base.cc11
-rw-r--r--chrome/renderer/webworker_base.h48
-rw-r--r--chrome/renderer/webworker_proxy.cc9
-rw-r--r--chrome/renderer/webworker_proxy.h3
-rw-r--r--chrome/worker/webworkerclient_proxy.cc3
8 files changed, 69 insertions, 25 deletions
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index 85510a5..7f6ce16 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -578,6 +578,13 @@ struct ViewHostMsg_CreateWorker_Params {
// The route ID to associate with the worker. If MSG_ROUTING_NONE is passed,
// a new unique ID is created and assigned to the worker.
int route_id;
+
+ // The ID of the parent's appcache host, only valid for dedicated workers.
+ int parent_appcache_host_id;
+
+ // The ID of the appcache the main shared worker script resource was loaded
+ // from, only valid for shared workers.
+ int64 script_resource_appcache_id;
};
// Creates a new view via a control message since the view doesn't yet exist.
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 4823e2e..7f52d82 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -2094,7 +2094,11 @@ WebPlugin* RenderView::createPlugin(
}
WebWorker* RenderView::createWorker(WebFrame* frame, WebWorkerClient* client) {
- return new WebWorkerProxy(client, RenderThread::current(), routing_id_);
+ WebApplicationCacheHostImpl* appcache_host =
+ WebApplicationCacheHostImpl::FromFrame(frame);
+ int appcache_host_id = appcache_host ? appcache_host->host_id() : 0;
+ return new WebWorkerProxy(client, RenderThread::current(), routing_id_,
+ appcache_host_id);
}
WebSharedWorker* RenderView::createSharedWorker(
diff --git a/chrome/renderer/websharedworker_proxy.cc b/chrome/renderer/websharedworker_proxy.cc
index 13b02f6..8c79cb8 100644
--- a/chrome/renderer/websharedworker_proxy.cc
+++ b/chrome/renderer/websharedworker_proxy.cc
@@ -17,7 +17,8 @@ WebSharedWorkerProxy::WebSharedWorkerProxy(ChildThread* child_thread,
: WebWorkerBase(child_thread,
document_id,
exists ? route_id : MSG_ROUTING_NONE,
- render_view_route_id),
+ render_view_route_id,
+ 0),
pending_route_id_(route_id),
connect_listener_(NULL) {
}
@@ -33,8 +34,8 @@ void WebSharedWorkerProxy::startWorkerContext(
const WebKit::WebString& source_code,
long long script_resource_appcache_id) {
DCHECK(!isStarted());
- CreateWorkerContext(script_url, true, name, user_agent, source_code,
- pending_route_id_);
+ CreateSharedWorkerContext(script_url, name, user_agent, source_code,
+ pending_route_id_, script_resource_appcache_id);
}
void WebSharedWorkerProxy::terminateWorkerContext() {
diff --git a/chrome/renderer/webworker_base.cc b/chrome/renderer/webworker_base.cc
index 2bc10b5..d98a5b6 100644
--- a/chrome/renderer/webworker_base.cc
+++ b/chrome/renderer/webworker_base.cc
@@ -21,11 +21,13 @@ WebWorkerBase::WebWorkerBase(
ChildThread* child_thread,
unsigned long long document_id,
int route_id,
- int render_view_route_id)
+ int render_view_route_id,
+ int parent_appcache_host_id)
: route_id_(route_id),
render_view_route_id_(render_view_route_id),
child_thread_(child_thread),
- document_id_(document_id) {
+ document_id_(document_id),
+ parent_appcache_host_id_(parent_appcache_host_id) {
if (route_id_ != MSG_ROUTING_NONE)
child_thread_->AddRoute(route_id_, this);
}
@@ -55,7 +57,8 @@ void WebWorkerBase::CreateWorkerContext(const GURL& script_url,
const string16& name,
const string16& user_agent,
const string16& source_code,
- int pending_route_id) {
+ int pending_route_id,
+ int64 script_resource_appcache_id) {
DCHECK(route_id_ == MSG_ROUTING_NONE);
ViewHostMsg_CreateWorker_Params params;
params.url = script_url;
@@ -64,6 +67,8 @@ void WebWorkerBase::CreateWorkerContext(const GURL& script_url,
params.document_id = document_id_;
params.render_view_route_id = render_view_route_id_;
params.route_id = pending_route_id;
+ params.parent_appcache_host_id = parent_appcache_host_id_;
+ params.script_resource_appcache_id = script_resource_appcache_id;
IPC::Message* create_message = new ViewHostMsg_CreateWorker(
params, &route_id_);
child_thread_->Send(create_message);
diff --git a/chrome/renderer/webworker_base.h b/chrome/renderer/webworker_base.h
index b6b3da8..f867926 100644
--- a/chrome/renderer/webworker_base.h
+++ b/chrome/renderer/webworker_base.h
@@ -19,20 +19,27 @@ class GURL;
// worker process to start.
class WebWorkerBase : public IPC::Channel::Listener {
public:
- WebWorkerBase(ChildThread* child_thread,
- unsigned long long document_id,
- int route_id,
- int render_view_route_id);
-
virtual ~WebWorkerBase();
- // Creates and initializes a new worker context.
- void CreateWorkerContext(const GURL& script_url,
- bool is_shared,
- const string16& name,
- const string16& user_agent,
- const string16& source_code,
- int pending_route_id);
+ // Creates and initializes a new dedicated worker context.
+ void CreateDedicatedWorkerContext(const GURL& script_url,
+ const string16& user_agent,
+ const string16& source_code) {
+ CreateWorkerContext(script_url, false, string16(), user_agent,
+ source_code, MSG_ROUTING_NONE, 0);
+ }
+
+ // Creates and initializes a new shared worker context.
+ void CreateSharedWorkerContext(const GURL& script_url,
+ const string16& name,
+ const string16& user_agent,
+ const string16& source_code,
+ int pending_route_id,
+ int64 script_resource_appcache_id) {
+ CreateWorkerContext(script_url, true, name, user_agent,
+ source_code, pending_route_id,
+ script_resource_appcache_id);
+ }
// Returns true if the worker is running (can send messages to it).
bool IsStarted();
@@ -51,6 +58,12 @@ class WebWorkerBase : public IPC::Channel::Listener {
void SendQueuedMessages();
protected:
+ WebWorkerBase(ChildThread* child_thread,
+ unsigned long long document_id,
+ int route_id,
+ int render_view_route_id,
+ int parent_appcache_host_id);
+
// Routing id associated with this worker - used to receive messages from the
// worker, and also to route messages to the worker (WorkerService contains
// a map that maps between these renderer-side route IDs and worker-side
@@ -63,10 +76,21 @@ class WebWorkerBase : public IPC::Channel::Listener {
ChildThread* child_thread_;
private:
+ void CreateWorkerContext(const GURL& script_url,
+ bool is_shared,
+ const string16& name,
+ const string16& user_agent,
+ const string16& source_code,
+ int pending_route_id,
+ int64 script_resource_appcache_id);
+
// ID of our parent document (used to shutdown workers when the parent
// document is detached).
unsigned long long document_id_;
+ // ID of our parent's appcache host, only valid for dedicated workers.
+ int parent_appcache_host_id_;
+
// Stores messages that were sent before the StartWorkerContext message.
std::vector<IPC::Message*> queued_messages_;
};
diff --git a/chrome/renderer/webworker_proxy.cc b/chrome/renderer/webworker_proxy.cc
index aa7b7f4..abbb51f 100644
--- a/chrome/renderer/webworker_proxy.cc
+++ b/chrome/renderer/webworker_proxy.cc
@@ -21,8 +21,10 @@ using WebKit::WebWorkerClient;
WebWorkerProxy::WebWorkerProxy(
WebWorkerClient* client,
ChildThread* child_thread,
- int render_view_route_id)
- : WebWorkerBase(child_thread, 0, MSG_ROUTING_NONE, render_view_route_id),
+ int render_view_route_id,
+ int parent_appcache_host_id)
+ : WebWorkerBase(child_thread, 0, MSG_ROUTING_NONE, render_view_route_id,
+ parent_appcache_host_id),
client_(client) {
// TODO(atwilson): Change to pass in a real document_id when we support nested
// workers.
@@ -46,8 +48,7 @@ void WebWorkerProxy::startWorkerContext(
const WebURL& script_url,
const WebString& user_agent,
const WebString& source_code) {
- CreateWorkerContext(script_url, false, string16(), user_agent, source_code,
- MSG_ROUTING_NONE);
+ CreateDedicatedWorkerContext(script_url, user_agent, source_code);
}
void WebWorkerProxy::terminateWorkerContext() {
diff --git a/chrome/renderer/webworker_proxy.h b/chrome/renderer/webworker_proxy.h
index 112b561..c878f4f 100644
--- a/chrome/renderer/webworker_proxy.h
+++ b/chrome/renderer/webworker_proxy.h
@@ -26,7 +26,8 @@ class WebWorkerProxy : public WebKit::WebWorker, private WebWorkerBase {
public:
WebWorkerProxy(WebKit::WebWorkerClient* client,
ChildThread* child_thread,
- int render_view_route_id);
+ int render_view_route_id,
+ int parent_appcache_host_id);
~WebWorkerProxy();
// WebWorker implementation.
diff --git a/chrome/worker/webworkerclient_proxy.cc b/chrome/worker/webworkerclient_proxy.cc
index ca36659..ac061f4 100644
--- a/chrome/worker/webworkerclient_proxy.cc
+++ b/chrome/worker/webworkerclient_proxy.cc
@@ -102,7 +102,8 @@ void WebWorkerClientProxy::workerContextDestroyed() {
WebKit::WebWorker* WebWorkerClientProxy::createWorker(
WebKit::WebWorkerClient* client) {
- return new WebWorkerProxy(client, WorkerThread::current(), 0);
+ return new WebWorkerProxy(client, WorkerThread::current(), 0, 0);
+ // TODO(michaeln): Fill in the appcache_host_id parameter value.
}
bool WebWorkerClientProxy::Send(IPC::Message* message) {