summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authormichaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-27 22:43:19 +0000
committermichaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-27 22:43:19 +0000
commite5390a4d7d04cf148ace753239662a1bb32e5e4a (patch)
tree53192f394861d20aa36f80a96ced884f4ae3893d /chrome
parentfdb244d98291c7f801bb0a36c06de4a71b4895ae (diff)
downloadchromium_src-e5390a4d7d04cf148ace753239662a1bb32e5e4a.zip
chromium_src-e5390a4d7d04cf148ace753239662a1bb32e5e4a.tar.gz
chromium_src-e5390a4d7d04cf148ace753239662a1bb32e5e4a.tar.bz2
Fully connect the dots between workers and appcache resource loading.
* Split WorkerService CreateWorker into distinct methods for 'shared' vs 'dedicated' workers. * Include additional appcache params in WorkerService CreateSharedWorker and CreateDedicatedWorker methods. * Store those additional params in WorkerInstance object. * Pass those additional params to the worker process. * Use those additional params when initiating the appcache host for the worker when calling SelectCacheForWorker and SelectCacheForSharedWorker. * Add browser process message handlers and dispatching for the SelectCacheForWorker and SelectCacheForSharedWorker IPC messages. * Runtime enable the appcache feature in the worker processes. BUG=39368 TEST=manual for now, but i need to create layout tests for this Review URL: http://codereview.chromium.org/2238001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48441 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/appcache/appcache_dispatcher_host.cc28
-rw-r--r--chrome/browser/appcache/appcache_dispatcher_host.h3
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.cc19
-rw-r--r--chrome/browser/worker_host/worker_process_host.cc30
-rw-r--r--chrome/browser/worker_host/worker_process_host.h11
-rw-r--r--chrome/browser/worker_host/worker_service.cc46
-rw-r--r--chrome/browser/worker_host/worker_service.h48
-rw-r--r--chrome/worker/worker_thread.cc4
-rw-r--r--chrome/worker/worker_webapplicationcachehost_impl.cc9
9 files changed, 167 insertions, 31 deletions
diff --git a/chrome/browser/appcache/appcache_dispatcher_host.cc b/chrome/browser/appcache/appcache_dispatcher_host.cc
index 2ef6fca..2edb22f 100644
--- a/chrome/browser/appcache/appcache_dispatcher_host.cc
+++ b/chrome/browser/appcache/appcache_dispatcher_host.cc
@@ -63,6 +63,10 @@ bool AppCacheDispatcherHost::OnMessageReceived(const IPC::Message& msg,
IPC_MESSAGE_HANDLER(AppCacheMsg_RegisterHost, OnRegisterHost);
IPC_MESSAGE_HANDLER(AppCacheMsg_UnregisterHost, OnUnregisterHost);
IPC_MESSAGE_HANDLER(AppCacheMsg_SelectCache, OnSelectCache);
+ IPC_MESSAGE_HANDLER(AppCacheMsg_SelectCacheForWorker,
+ OnSelectCacheForWorker);
+ IPC_MESSAGE_HANDLER(AppCacheMsg_SelectCacheForSharedWorker,
+ OnSelectCacheForSharedWorker);
IPC_MESSAGE_HANDLER(AppCacheMsg_MarkAsForeignEntry, OnMarkAsForeignEntry);
IPC_MESSAGE_HANDLER_DELAY_REPLY(AppCacheMsg_GetStatus, OnGetStatus);
IPC_MESSAGE_HANDLER_DELAY_REPLY(AppCacheMsg_StartUpdate, OnStartUpdate);
@@ -104,6 +108,30 @@ void AppCacheDispatcherHost::OnSelectCache(
}
}
+void AppCacheDispatcherHost::OnSelectCacheForWorker(
+ int host_id, int parent_process_id, int parent_host_id) {
+ if (appcache_service_.get()) {
+ if (!backend_impl_.SelectCacheForWorker(
+ host_id, parent_process_id, parent_host_id)) {
+ ReceivedBadMessage(AppCacheMsg_SelectCacheForWorker::ID);
+ }
+ } else {
+ frontend_proxy_.OnCacheSelected(
+ host_id, appcache::kNoCacheId, appcache::UNCACHED);
+ }
+}
+
+void AppCacheDispatcherHost::OnSelectCacheForSharedWorker(
+ int host_id, int64 appcache_id) {
+ if (appcache_service_.get()) {
+ if (!backend_impl_.SelectCacheForSharedWorker(host_id, appcache_id))
+ ReceivedBadMessage(AppCacheMsg_SelectCacheForSharedWorker::ID);
+ } else {
+ frontend_proxy_.OnCacheSelected(
+ host_id, appcache::kNoCacheId, appcache::UNCACHED);
+ }
+}
+
void AppCacheDispatcherHost::OnMarkAsForeignEntry(
int host_id, const GURL& document_url,
int64 cache_document_was_loaded_from) {
diff --git a/chrome/browser/appcache/appcache_dispatcher_host.h b/chrome/browser/appcache/appcache_dispatcher_host.h
index c4831a4..887a9af 100644
--- a/chrome/browser/appcache/appcache_dispatcher_host.h
+++ b/chrome/browser/appcache/appcache_dispatcher_host.h
@@ -50,6 +50,9 @@ class AppCacheDispatcherHost {
void OnSelectCache(int host_id, const GURL& document_url,
int64 cache_document_was_loaded_from,
const GURL& opt_manifest_url);
+ void OnSelectCacheForWorker(int host_id, int parent_process_id,
+ int parent_host_id);
+ void OnSelectCacheForSharedWorker(int host_id, int64 appcache_id);
void OnMarkAsForeignEntry(int host_id, const GURL& document_url,
int64 cache_document_was_loaded_from);
void OnGetStatus(int host_id, IPC::Message* reply_msg);
diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc
index 5e3b3c4..7319db1 100644
--- a/chrome/browser/renderer_host/resource_message_filter.cc
+++ b/chrome/browser/renderer_host/resource_message_filter.cc
@@ -824,11 +824,20 @@ void ResourceMessageFilter::OnCreateWorker(
const ViewHostMsg_CreateWorker_Params& params, int* route_id) {
*route_id = params.route_id != MSG_ROUTING_NONE ?
params.route_id : render_widget_helper_->GetNextRoutingID();
- WorkerService::GetInstance()->CreateWorker(
- params.url, params.is_shared, off_the_record(), params.name,
- params.document_id, id(), params.render_view_route_id, this, *route_id,
- static_cast<ChromeURLRequestContext*>(
- request_context_->GetURLRequestContext()));
+ if (params.is_shared)
+ WorkerService::GetInstance()->CreateSharedWorker(
+ params.url, off_the_record(), params.name,
+ params.document_id, id(), params.render_view_route_id, this, *route_id,
+ params.script_resource_appcache_id,
+ static_cast<ChromeURLRequestContext*>(
+ request_context_->GetURLRequestContext()));
+ else
+ WorkerService::GetInstance()->CreateDedicatedWorker(
+ params.url, off_the_record(),
+ params.document_id, id(), params.render_view_route_id, this, *route_id,
+ id(), params.parent_appcache_host_id,
+ static_cast<ChromeURLRequestContext*>(
+ request_context_->GetURLRequestContext()));
}
void ResourceMessageFilter::OnLookupSharedWorker(
diff --git a/chrome/browser/worker_host/worker_process_host.cc b/chrome/browser/worker_host/worker_process_host.cc
index aecb07c..9672c1b 100644
--- a/chrome/browser/worker_host/worker_process_host.cc
+++ b/chrome/browser/worker_host/worker_process_host.cc
@@ -211,9 +211,9 @@ void WorkerProcessHost::CreateWorker(const WorkerInstance& instance) {
params.is_shared = instance.shared();
params.name = instance.name();
params.route_id = instance.worker_route_id();
- params.creator_process_id = 0; // TODO(michaeln): Set these param values.
- params.creator_appcache_host_id = 0;
- params.shared_worker_appcache_id = 0;
+ params.creator_process_id = instance.parent_process_id();
+ params.creator_appcache_host_id = instance.parent_appcache_host_id();
+ params.shared_worker_appcache_id = instance.main_resource_appcache_id();
Send(new WorkerProcessMsg_CreateWorker(params));
UpdateTitle();
@@ -481,11 +481,19 @@ void WorkerProcessHost::OnCreateWorker(
instances_.front().worker_document_set()->documents().begin();
*route_id = params.route_id == MSG_ROUTING_NONE ?
WorkerService::GetInstance()->next_worker_route_id() : params.route_id;
- WorkerService::GetInstance()->CreateWorker(
- params.url, params.is_shared, instances_.front().off_the_record(),
- params.name, params.document_id, first_parent->renderer_id(),
- first_parent->render_view_route_id(), this, *route_id,
- request_context_);
+
+ if (params.is_shared)
+ WorkerService::GetInstance()->CreateSharedWorker(
+ params.url, instances_.front().off_the_record(),
+ params.name, params.document_id, first_parent->renderer_id(),
+ first_parent->render_view_route_id(), this, *route_id,
+ params.script_resource_appcache_id, request_context_);
+ else
+ WorkerService::GetInstance()->CreateDedicatedWorker(
+ params.url, instances_.front().off_the_record(),
+ params.document_id, first_parent->renderer_id(),
+ first_parent->render_view_route_id(), this, *route_id,
+ id(), params.parent_appcache_host_id, request_context_);
}
void WorkerProcessHost::OnCancelCreateDedicatedWorker(int route_id) {
@@ -522,6 +530,9 @@ WorkerProcessHost::WorkerInstance::WorkerInstance(
bool off_the_record,
const string16& name,
int worker_route_id,
+ int parent_process_id,
+ int parent_appcache_host_id,
+ int64 main_resource_appcache_id,
ChromeURLRequestContext* request_context)
: url_(url),
shared_(shared),
@@ -529,6 +540,9 @@ WorkerProcessHost::WorkerInstance::WorkerInstance(
closed_(false),
name_(name),
worker_route_id_(worker_route_id),
+ parent_process_id_(parent_process_id),
+ parent_appcache_host_id_(parent_appcache_host_id),
+ main_resource_appcache_id_(main_resource_appcache_id),
request_context_(request_context),
worker_document_set_(new WorkerDocumentSet()) {
DCHECK(!request_context ||
diff --git a/chrome/browser/worker_host/worker_process_host.h b/chrome/browser/worker_host/worker_process_host.h
index a18897d..0278d1c 100644
--- a/chrome/browser/worker_host/worker_process_host.h
+++ b/chrome/browser/worker_host/worker_process_host.h
@@ -43,6 +43,9 @@ class WorkerProcessHost : public ChildProcessHost {
bool off_the_record,
const string16& name,
int worker_route_id,
+ int parent_process_id,
+ int parent_appcache_host_id,
+ int64 main_resource_appcache_id,
ChromeURLRequestContext* request_context);
// Unique identifier for a worker client.
@@ -82,6 +85,11 @@ class WorkerProcessHost : public ChildProcessHost {
const GURL& url() const { return url_; }
const string16 name() const { return name_; }
int worker_route_id() const { return worker_route_id_; }
+ int parent_process_id() const { return parent_process_id_; }
+ int parent_appcache_host_id() const { return parent_appcache_host_id_; }
+ int64 main_resource_appcache_id() const {
+ return main_resource_appcache_id_;
+ }
WorkerDocumentSet* worker_document_set() const {
return worker_document_set_;
}
@@ -97,6 +105,9 @@ class WorkerProcessHost : public ChildProcessHost {
bool closed_;
string16 name_;
int worker_route_id_;
+ int parent_process_id_;
+ int parent_appcache_host_id_;
+ int64 main_resource_appcache_id_;
scoped_refptr<ChromeURLRequestContext> request_context_;
SenderList senders_;
scoped_refptr<WorkerDocumentSet> worker_document_set_;
diff --git a/chrome/browser/worker_host/worker_service.cc b/chrome/browser/worker_host/worker_service.cc
index 2f50e33..73848d6 100644
--- a/chrome/browser/worker_host/worker_service.cc
+++ b/chrome/browser/worker_host/worker_service.cc
@@ -46,8 +46,44 @@ void WorkerService::Initialize(ResourceDispatcherHost* rdh) {
WorkerService::~WorkerService() {
}
+bool WorkerService::CreateDedicatedWorker(
+ const GURL& url,
+ bool is_off_the_record,
+ unsigned long long document_id,
+ int renderer_pid,
+ int render_view_route_id,
+ IPC::Message::Sender* sender,
+ int sender_route_id,
+ int parent_process_id,
+ int parent_appcache_host_id,
+ ChromeURLRequestContext* request_context) {
+ return CreateWorker(url, false, is_off_the_record, string16(),
+ document_id, renderer_pid, render_view_route_id,
+ sender, sender_route_id,
+ parent_process_id, parent_appcache_host_id, 0,
+ request_context);
+}
+
+bool WorkerService::CreateSharedWorker(
+ const GURL& url,
+ bool is_off_the_record,
+ const string16& name,
+ unsigned long long document_id,
+ int renderer_pid,
+ int render_view_route_id,
+ IPC::Message::Sender* sender,
+ int sender_route_id,
+ int64 main_resource_appcache_id,
+ ChromeURLRequestContext* request_context) {
+ return CreateWorker(url, true, is_off_the_record, name,
+ document_id, renderer_pid, render_view_route_id,
+ sender, sender_route_id,
+ 0, 0, main_resource_appcache_id,
+ request_context);
+}
+
bool WorkerService::CreateWorker(
- const GURL &url,
+ const GURL& url,
bool is_shared,
bool off_the_record,
const string16& name,
@@ -56,6 +92,9 @@ bool WorkerService::CreateWorker(
int render_view_route_id,
IPC::Message::Sender* sender,
int sender_route_id,
+ int parent_process_id,
+ int parent_appcache_host_id,
+ int64 main_resource_appcache_id,
ChromeURLRequestContext* request_context) {
// Generate a unique route id for the browser-worker communication that's
// unique among all worker processes. That way when the worker process sends
@@ -66,6 +105,9 @@ bool WorkerService::CreateWorker(
off_the_record,
name,
next_worker_route_id(),
+ parent_process_id,
+ parent_appcache_host_id,
+ main_resource_appcache_id,
request_context);
instance.AddSender(sender, sender_route_id);
instance.worker_document_set()->Add(
@@ -543,7 +585,7 @@ WorkerService::CreatePendingInstance(const GURL& url,
// No existing pending worker - create a new one.
WorkerProcessHost::WorkerInstance pending(
- url, true, off_the_record, name, MSG_ROUTING_NONE, NULL);
+ url, true, off_the_record, name, MSG_ROUTING_NONE, 0, 0, 0, NULL);
pending_shared_workers_.push_back(pending);
return &pending_shared_workers_.back();
}
diff --git a/chrome/browser/worker_host/worker_service.h b/chrome/browser/worker_host/worker_service.h
index 50c381a..fb1c0ca 100644
--- a/chrome/browser/worker_host/worker_service.h
+++ b/chrome/browser/worker_host/worker_service.h
@@ -25,17 +25,29 @@ class WorkerService : public NotificationObserver {
// Initialize the WorkerService. OK to be called multiple times.
void Initialize(ResourceDispatcherHost* rdh);
- // Creates a worker. Returns true on success.
- bool CreateWorker(const GURL &url,
- bool is_shared,
- bool is_off_the_record,
- const string16& name,
- unsigned long long document_id,
- int renderer_pid,
- int render_view_route_id,
- IPC::Message::Sender* sender,
- int sender_route_id,
- ChromeURLRequestContext* request_context);
+ // Creates a decidated worker. Returns true on success.
+ bool CreateDedicatedWorker(const GURL &url,
+ bool is_off_the_record,
+ unsigned long long document_id,
+ int renderer_pid,
+ int render_view_route_id,
+ IPC::Message::Sender* sender,
+ int sender_route_id,
+ int parent_process_id,
+ int parent_appcache_host_id,
+ ChromeURLRequestContext* request_context);
+
+ // Creates a shared worker. Returns true on success.
+ bool CreateSharedWorker(const GURL &url,
+ bool is_off_the_record,
+ const string16& name,
+ unsigned long long document_id,
+ int renderer_pid,
+ int render_view_route_id,
+ IPC::Message::Sender* sender,
+ int sender_route_id,
+ int64 main_resource_appcache_id,
+ ChromeURLRequestContext* request_context);
// Validates the passed URL and checks for the existence of matching shared
// worker. Returns true if the url was found, and sets the url_mismatch out
@@ -88,6 +100,20 @@ class WorkerService : public NotificationObserver {
WorkerService();
~WorkerService();
+ bool CreateWorker(const GURL &url,
+ bool is_shared,
+ bool is_off_the_record,
+ const string16& name,
+ unsigned long long document_id,
+ int renderer_pid,
+ int render_view_route_id,
+ IPC::Message::Sender* sender,
+ int sender_route_id,
+ int parent_process_id,
+ int parent_appcache_host_id,
+ int64 main_resource_appcache_id,
+ ChromeURLRequestContext* request_context);
+
// Given a WorkerInstance, create an associated worker process.
bool CreateWorkerFromInstance(WorkerProcessHost::WorkerInstance instance);
diff --git a/chrome/worker/worker_thread.cc b/chrome/worker/worker_thread.cc
index 3e4a1d1..4048f8a 100644
--- a/chrome/worker/worker_thread.cc
+++ b/chrome/worker/worker_thread.cc
@@ -42,9 +42,7 @@ WorkerThread::WorkerThread() {
WebKit::WebRuntimeFeatures::enableDatabase(
!command_line.HasSwitch(switches::kDisableDatabases));
- // TODO(michaeln): Enable once the browser process is ready to receive
- // the appcache messages.
- WebKit::WebRuntimeFeatures::enableApplicationCache(false &&
+ WebKit::WebRuntimeFeatures::enableApplicationCache(
!command_line.HasSwitch(switches::kDisableApplicationCache));
#if defined(OS_WIN)
diff --git a/chrome/worker/worker_webapplicationcachehost_impl.cc b/chrome/worker/worker_webapplicationcachehost_impl.cc
index 1778595..dafa1ea 100644
--- a/chrome/worker/worker_webapplicationcachehost_impl.cc
+++ b/chrome/worker/worker_webapplicationcachehost_impl.cc
@@ -13,6 +13,11 @@ WorkerWebApplicationCacheHostImpl::WorkerWebApplicationCacheHostImpl(
WebKit::WebApplicationCacheHostClient* client)
: WebApplicationCacheHostImpl(client,
WorkerThread::current()->appcache_dispatcher()->backend_proxy()) {
- // TODO(michaeln): Send a worker specific init message.
- // backend_->SelectCacheForWorker(init_info);
+ if (init_info.is_shared_worker)
+ backend()->SelectCacheForSharedWorker(host_id(),
+ init_info.main_resource_appcache_id);
+ else
+ backend()->SelectCacheForWorker(host_id(),
+ init_info.parent_process_id,
+ init_info.parent_appcache_host_id);
}