diff options
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/worker_host/worker_process_host.cc | 19 | ||||
-rw-r--r-- | chrome/chrome.gyp | 2 | ||||
-rw-r--r-- | chrome/common/worker_messages.h | 54 | ||||
-rw-r--r-- | chrome/common/worker_messages_internal.h | 7 | ||||
-rw-r--r-- | chrome/worker/DEPS | 1 | ||||
-rw-r--r-- | chrome/worker/websharedworker_stub.cc | 11 | ||||
-rw-r--r-- | chrome/worker/websharedworker_stub.h | 3 | ||||
-rw-r--r-- | chrome/worker/webworker_stub.cc | 5 | ||||
-rw-r--r-- | chrome/worker/webworker_stub.h | 3 | ||||
-rw-r--r-- | chrome/worker/webworker_stub_base.cc | 4 | ||||
-rw-r--r-- | chrome/worker/webworker_stub_base.h | 8 | ||||
-rw-r--r-- | chrome/worker/webworkerclient_proxy.cc | 18 | ||||
-rw-r--r-- | chrome/worker/webworkerclient_proxy.h | 6 | ||||
-rw-r--r-- | chrome/worker/worker_thread.cc | 32 | ||||
-rw-r--r-- | chrome/worker/worker_thread.h | 14 | ||||
-rw-r--r-- | chrome/worker/worker_webapplicationcachehost_impl.cc | 18 | ||||
-rw-r--r-- | chrome/worker/worker_webapplicationcachehost_impl.h | 52 |
17 files changed, 218 insertions, 39 deletions
diff --git a/chrome/browser/worker_host/worker_process_host.cc b/chrome/browser/worker_host/worker_process_host.cc index 38dd8e3..4c8a961 100644 --- a/chrome/browser/worker_host/worker_process_host.cc +++ b/chrome/browser/worker_host/worker_process_host.cc @@ -117,6 +117,11 @@ bool WorkerProcessHost::Init() { } if (CommandLine::ForCurrentProcess()->HasSwitch( + switches::kDisableApplicationCache)) { + cmd_line->AppendSwitch(switches::kDisableApplicationCache); + } + + if (CommandLine::ForCurrentProcess()->HasSwitch( switches::kDisableDatabases)) { cmd_line->AppendSwitch(switches::kDisableDatabases); } @@ -196,10 +201,16 @@ void WorkerProcessHost::CreateWorker(const WorkerInstance& instance) { id(), instance.url()); instances_.push_back(instance); - Send(new WorkerProcessMsg_CreateWorker(instance.url(), - instance.shared(), - instance.name(), - instance.worker_route_id())); + + WorkerProcessMsg_CreateWorker_Params params; + params.url = instance.url(); + 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; + Send(new WorkerProcessMsg_CreateWorker(params)); UpdateTitle(); diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index ee1ce24..085d0e7 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -660,6 +660,8 @@ 'worker/worker_main.cc', 'worker/worker_thread.cc', 'worker/worker_thread.h', + 'worker/worker_webapplicationcachehost_impl.cc', + 'worker/worker_webapplicationcachehost_impl.h', 'worker/worker_webkitclient_impl.cc', 'worker/worker_webkitclient_impl.h', ], diff --git a/chrome/common/worker_messages.h b/chrome/common/worker_messages.h index 05f650e..1228ba3 100644 --- a/chrome/common/worker_messages.h +++ b/chrome/common/worker_messages.h @@ -13,6 +13,7 @@ #include "base/basictypes.h" #include "chrome/common/common_param_traits.h" +#include "googleurl/src/gurl.h" #include "ipc/ipc_message_utils.h" typedef std::pair<string16, std::vector<int> > QueuedMessage; @@ -30,6 +31,17 @@ struct WorkerHostMsg_PostConsoleMessageToWorkerObject_Params { string16 source_url; }; +// Parameter structure for WorkerProcessMsg_CreateWorker. +struct WorkerProcessMsg_CreateWorker_Params { + GURL url; + bool is_shared; + string16 name; + int route_id; + int creator_process_id; + int creator_appcache_host_id; // Only valid for dedicated workers. + int64 shared_worker_appcache_id; // Only valid for shared workers. +}; + namespace IPC { // Traits for WorkerHostMsg_PostConsoleMessageToWorkerObject_Params structure @@ -71,6 +83,48 @@ struct ParamTraits<WorkerHostMsg_PostConsoleMessageToWorkerObject_Params> { } }; +// Traits for WorkerProcessMsg_CreateWorker_Params. +template <> +struct ParamTraits<WorkerProcessMsg_CreateWorker_Params> { + typedef WorkerProcessMsg_CreateWorker_Params param_type; + static void Write(Message* m, const param_type& p) { + WriteParam(m, p.url); + WriteParam(m, p.is_shared); + WriteParam(m, p.name); + WriteParam(m, p.route_id); + WriteParam(m, p.creator_process_id); + WriteParam(m, p.creator_appcache_host_id); + WriteParam(m, p.shared_worker_appcache_id); + } + static bool Read(const Message* m, void** iter, param_type* p) { + return + ReadParam(m, iter, &p->url) && + ReadParam(m, iter, &p->is_shared) && + ReadParam(m, iter, &p->name) && + ReadParam(m, iter, &p->route_id) && + ReadParam(m, iter, &p->creator_process_id) && + ReadParam(m, iter, &p->creator_appcache_host_id) && + ReadParam(m, iter, &p->shared_worker_appcache_id); + } + static void Log(const param_type& p, std::wstring* l) { + l->append(L"("); + LogParam(p.url, l); + l->append(L", "); + LogParam(p.is_shared, l); + l->append(L", "); + LogParam(p.name, l); + l->append(L", "); + LogParam(p.route_id, l); + l->append(L", "); + LogParam(p.creator_process_id, l); + l->append(L", "); + LogParam(p.creator_appcache_host_id, l); + l->append(L", "); + LogParam(p.shared_worker_appcache_id, l); + l->append(L")"); + } +}; + } // namespace IPC #define MESSAGES_INTERNAL_FILE "chrome/common/worker_messages_internal.h" diff --git a/chrome/common/worker_messages_internal.h b/chrome/common/worker_messages_internal.h index be0f271..fed4096 100644 --- a/chrome/common/worker_messages_internal.h +++ b/chrome/common/worker_messages_internal.h @@ -13,11 +13,8 @@ // WorkerProcess messages // These are messages sent from the browser to the worker process. IPC_BEGIN_MESSAGES(WorkerProcess) - IPC_MESSAGE_CONTROL4(WorkerProcessMsg_CreateWorker, - GURL /* url */, - bool /* is_shared */, - string16 /* name */, - int /* route_id */) + IPC_MESSAGE_CONTROL1(WorkerProcessMsg_CreateWorker, + WorkerProcessMsg_CreateWorker_Params) // Note: these Message Port related messages can also be sent to the // renderer process. Putting them here since we don't have a shared place diff --git a/chrome/worker/DEPS b/chrome/worker/DEPS index 194de05..12aee6e 100644 --- a/chrome/worker/DEPS +++ b/chrome/worker/DEPS @@ -4,6 +4,7 @@ include_rules = [ "+chrome/renderer",
"+chrome/worker",
"+sandbox/src",
+ "+webkit/appcache",
"+webkit/glue",
]
diff --git a/chrome/worker/websharedworker_stub.cc b/chrome/worker/websharedworker_stub.cc index f398244..32b5b38 100644 --- a/chrome/worker/websharedworker_stub.cc +++ b/chrome/worker/websharedworker_stub.cc @@ -11,14 +11,13 @@ #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" WebSharedWorkerStub::WebSharedWorkerStub( - const string16& name, int route_id) - : WebWorkerStubBase(route_id), + const string16& name, int route_id, + const WorkerAppCacheInitInfo& appcache_init_info) + : WebWorkerStubBase(route_id, appcache_init_info), name_(name), started_(false) { - // TODO(atwilson): Add support for NaCl when they support MessagePorts. impl_ = WebKit::WebSharedWorker::create(client()); - } WebSharedWorkerStub::~WebSharedWorkerStub() { @@ -44,6 +43,10 @@ void WebSharedWorkerStub::OnStartWorkerContext( // try to start it simultaneously). if (started_) return; + + // TODO(michaeln): Fixup this callsite once + // https://bugs.webkit.org/show_bug.cgi?id=38605 + // has landed and rolled into view. impl_->startWorkerContext(url, name_, user_agent, source_code); started_ = true; diff --git a/chrome/worker/websharedworker_stub.h b/chrome/worker/websharedworker_stub.h index ad5a547..a2ff912 100644 --- a/chrome/worker/websharedworker_stub.h +++ b/chrome/worker/websharedworker_stub.h @@ -17,7 +17,8 @@ class WebSharedWorker; // appropriate WebSharedWorker APIs. class WebSharedWorkerStub : public WebWorkerStubBase { public: - WebSharedWorkerStub(const string16& name, int route_id); + WebSharedWorkerStub(const string16& name, int route_id, + const WorkerAppCacheInitInfo& appcache_init_info); // IPC::Channel::Listener implementation. virtual void OnMessageReceived(const IPC::Message& message); diff --git a/chrome/worker/webworker_stub.cc b/chrome/worker/webworker_stub.cc index 142adcf..89cc384 100644 --- a/chrome/worker/webworker_stub.cc +++ b/chrome/worker/webworker_stub.cc @@ -33,8 +33,9 @@ static bool UrlIsNativeWorker(const GURL& url) { return (suffix_index == pos); } -WebWorkerStub::WebWorkerStub(const GURL& url, int route_id) - : WebWorkerStubBase(route_id) { +WebWorkerStub::WebWorkerStub(const GURL& url, int route_id, + const WorkerAppCacheInitInfo& appcache_init_info) + : WebWorkerStubBase(route_id, appcache_init_info) { if (UrlIsNativeWorker(url)) { // Launch a native worker. impl_ = NativeWebWorkerImpl::create(client()); diff --git a/chrome/worker/webworker_stub.h b/chrome/worker/webworker_stub.h index dab69d0..a3f7595 100644 --- a/chrome/worker/webworker_stub.h +++ b/chrome/worker/webworker_stub.h @@ -17,7 +17,8 @@ class WebWorker; // appropriate WebWorker APIs. class WebWorkerStub : public WebWorkerStubBase { public: - WebWorkerStub(const GURL& url, int route_id); + WebWorkerStub(const GURL& url, int route_id, + const WorkerAppCacheInitInfo& appcache_init_info); // IPC::Channel::Listener implementation. virtual void OnMessageReceived(const IPC::Message& message); diff --git a/chrome/worker/webworker_stub_base.cc b/chrome/worker/webworker_stub_base.cc index b999f44..db9ab79 100644 --- a/chrome/worker/webworker_stub_base.cc +++ b/chrome/worker/webworker_stub_base.cc @@ -8,8 +8,10 @@ #include "chrome/common/child_process.h" #include "chrome/worker/worker_thread.h" -WebWorkerStubBase::WebWorkerStubBase(int route_id) +WebWorkerStubBase::WebWorkerStubBase( + int route_id, const WorkerAppCacheInitInfo& appcache_init_info) : route_id_(route_id), + appcache_init_info_(appcache_init_info), ALLOW_THIS_IN_INITIALIZER_LIST(client_(route_id, this)) { WorkerThread* workerThread = WorkerThread::current(); diff --git a/chrome/worker/webworker_stub_base.h b/chrome/worker/webworker_stub_base.h index 397f517..6206c6e 100644 --- a/chrome/worker/webworker_stub_base.h +++ b/chrome/worker/webworker_stub_base.h @@ -6,13 +6,15 @@ #define CHROME_WORKER_WEBWORKER_STUB_BASE_H_ #include "chrome/worker/webworkerclient_proxy.h" +#include "chrome/worker/worker_webapplicationcachehost_impl.h" #include "ipc/ipc_channel.h" // This class is the common base class for both WebWorkerStub and // WebSharedWorkerStub and contains common setup/teardown functionality. class WebWorkerStubBase : public IPC::Channel::Listener { public: - explicit WebWorkerStubBase(int route_id); + WebWorkerStubBase(int route_id, + const WorkerAppCacheInitInfo& appcache_init_info); virtual ~WebWorkerStubBase(); // Invoked when the WebWorkerClientProxy is shutting down. @@ -24,8 +26,12 @@ class WebWorkerStubBase : public IPC::Channel::Listener { WebWorkerClientProxy* client() { return &client_; } + const WorkerAppCacheInitInfo& appcache_init_info() const { + return appcache_init_info_; + } private: int route_id_; + WorkerAppCacheInitInfo appcache_init_info_; // WebWorkerClient that responds to outgoing API calls from the worker object. WebWorkerClientProxy client_; diff --git a/chrome/worker/webworkerclient_proxy.cc b/chrome/worker/webworkerclient_proxy.cc index ac061f4..18ed954 100644 --- a/chrome/worker/webworkerclient_proxy.cc +++ b/chrome/worker/webworkerclient_proxy.cc @@ -11,11 +11,13 @@ #include "chrome/renderer/webworker_proxy.h" #include "chrome/worker/webworker_stub_base.h" #include "chrome/worker/worker_thread.h" +#include "chrome/worker/worker_webapplicationcachehost_impl.h" #include "ipc/ipc_logging.h" #include "third_party/WebKit/WebKit/chromium/public/WebString.h" #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" #include "third_party/WebKit/WebKit/chromium/public/WebWorker.h" +using WebKit::WebApplicationCacheHost; using WebKit::WebMessagePortChannel; using WebKit::WebMessagePortChannelArray; using WebKit::WebString; @@ -28,6 +30,7 @@ using WebKit::WebWorkerClient; WebWorkerClientProxy::WebWorkerClientProxy(int route_id, WebWorkerStubBase* stub) : route_id_(route_id), + appcache_host_id_(0), stub_(stub), ALLOW_THIS_IN_INITIALIZER_LIST(kill_process_factory_(this)) { } @@ -102,8 +105,19 @@ void WebWorkerClientProxy::workerContextDestroyed() { WebKit::WebWorker* WebWorkerClientProxy::createWorker( WebKit::WebWorkerClient* client) { - return new WebWorkerProxy(client, WorkerThread::current(), 0, 0); - // TODO(michaeln): Fill in the appcache_host_id parameter value. + return new WebWorkerProxy(client, WorkerThread::current(), + 0, appcache_host_id_); +} + +WebApplicationCacheHost* WebWorkerClientProxy::createApplicationCacheHost( + WebKit::WebApplicationCacheHostClient* client) { + WorkerWebApplicationCacheHostImpl* host = + new WorkerWebApplicationCacheHostImpl(stub_->appcache_init_info(), + client); + // Remember the id of the instance we create so we have access to that + // value when creating nested dedicated workers in createWorker. + appcache_host_id_ = host->host_id(); + return host; } bool WebWorkerClientProxy::Send(IPC::Message* message) { diff --git a/chrome/worker/webworkerclient_proxy.h b/chrome/worker/webworkerclient_proxy.h index 430927c..d498895 100644 --- a/chrome/worker/webworkerclient_proxy.h +++ b/chrome/worker/webworkerclient_proxy.h @@ -71,10 +71,7 @@ class WebWorkerClientProxy : public WebKit::WebWorkerClient { } virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost( - WebKit::WebApplicationCacheHostClient*) { - // TODO(michaeln): Create and initialize an appcache host for our worker. - return NULL; - } + WebKit::WebApplicationCacheHostClient* client); void EnsureWorkerContextTerminates(); @@ -82,6 +79,7 @@ class WebWorkerClientProxy : public WebKit::WebWorkerClient { bool Send(IPC::Message* message); int route_id_; + int appcache_host_id_; WebWorkerStubBase* stub_; ScopedRunnableMethodFactory<WebWorkerClientProxy> kill_process_factory_; diff --git a/chrome/worker/worker_thread.cc b/chrome/worker/worker_thread.cc index 8f32a6a..3e4a1d1 100644 --- a/chrome/worker/worker_thread.cc +++ b/chrome/worker/worker_thread.cc @@ -7,6 +7,7 @@ #include "base/command_line.h" #include "base/lazy_instance.h" #include "base/thread_local.h" +#include "chrome/common/appcache/appcache_dispatcher.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/db_message_filter.h" #include "chrome/common/web_database_observer_impl.h" @@ -29,16 +30,22 @@ WorkerThread::WorkerThread() { webkit_client_.reset(new WorkerWebKitClientImpl); WebKit::initialize(webkit_client_.get()); + appcache_dispatcher_.reset(new AppCacheDispatcher(this)); + web_database_observer_impl_.reset(new WebDatabaseObserverImpl(this)); WebKit::WebDatabase::setObserver(web_database_observer_impl_.get()); + db_message_filter_ = new DBMessageFilter(); + channel()->AddFilter(db_message_filter_.get()); const CommandLine& command_line = *CommandLine::ForCurrentProcess(); WebKit::WebRuntimeFeatures::enableDatabase( !command_line.HasSwitch(switches::kDisableDatabases)); - db_message_filter_ = new DBMessageFilter(); - channel()->AddFilter(db_message_filter_.get()); + // TODO(michaeln): Enable once the browser process is ready to receive + // the appcache messages. + WebKit::WebRuntimeFeatures::enableApplicationCache(false && + !command_line.HasSwitch(switches::kDisableApplicationCache)); #if defined(OS_WIN) // We don't yet support notifications on non-Windows, so hide it from pages. @@ -64,20 +71,27 @@ WorkerThread* WorkerThread::current() { } void WorkerThread::OnControlMessageReceived(const IPC::Message& msg) { + // Appcache messages are handled by a delegate. + if (appcache_dispatcher_->OnMessageReceived(msg)) + return; + IPC_BEGIN_MESSAGE_MAP(WorkerThread, msg) IPC_MESSAGE_HANDLER(WorkerProcessMsg_CreateWorker, OnCreateWorker) IPC_END_MESSAGE_MAP() } -void WorkerThread::OnCreateWorker(const GURL& url, - bool is_shared, - const string16& name, - int route_id) { +void WorkerThread::OnCreateWorker( + const WorkerProcessMsg_CreateWorker_Params& params) { + WorkerAppCacheInitInfo appcache_init_info( + params.is_shared, params.creator_process_id, + params.creator_appcache_host_id, + params.shared_worker_appcache_id); + // WebWorkerStub and WebSharedWorkerStub own themselves. - if (is_shared) - new WebSharedWorkerStub(name, route_id); + if (params.is_shared) + new WebSharedWorkerStub(params.name, params.route_id, appcache_init_info); else - new WebWorkerStub(url, route_id); + new WebWorkerStub(params.url, params.route_id, appcache_init_info); } // The browser process is likely dead. Terminate all workers. diff --git a/chrome/worker/worker_thread.h b/chrome/worker/worker_thread.h index 727316c..0d905de 100644 --- a/chrome/worker/worker_thread.h +++ b/chrome/worker/worker_thread.h @@ -10,10 +10,12 @@ #include "chrome/common/child_thread.h" class GURL; +class AppCacheDispatcher; class DBMessageFilter; class WebDatabaseObserverImpl; class WebWorkerStubBase; class WorkerWebKitClientImpl; +struct WorkerProcessMsg_CreateWorker_Params; class WorkerThread : public ChildThread { public: @@ -27,17 +29,19 @@ class WorkerThread : public ChildThread { void AddWorkerStub(WebWorkerStubBase* stub); void RemoveWorkerStub(WebWorkerStubBase* stub); - private: - scoped_ptr<WebDatabaseObserverImpl> web_database_observer_impl_; + AppCacheDispatcher* appcache_dispatcher() { + return appcache_dispatcher_.get(); + } + private: virtual void OnControlMessageReceived(const IPC::Message& msg); virtual void OnChannelError(); - void OnCreateWorker( - const GURL& url, bool is_shared, const string16& name, int route_id); + void OnCreateWorker(const WorkerProcessMsg_CreateWorker_Params& params); scoped_ptr<WorkerWebKitClientImpl> webkit_client_; - + scoped_ptr<AppCacheDispatcher> appcache_dispatcher_; + scoped_ptr<WebDatabaseObserverImpl> web_database_observer_impl_; scoped_refptr<DBMessageFilter> db_message_filter_; typedef std::set<WebWorkerStubBase*> WorkerStubsList; diff --git a/chrome/worker/worker_webapplicationcachehost_impl.cc b/chrome/worker/worker_webapplicationcachehost_impl.cc new file mode 100644 index 0000000..1778595 --- /dev/null +++ b/chrome/worker/worker_webapplicationcachehost_impl.cc @@ -0,0 +1,18 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/worker/worker_webapplicationcachehost_impl.h" + +#include "base/logging.h" +#include "chrome/common/appcache/appcache_dispatcher.h" +#include "chrome/worker/worker_thread.h" + +WorkerWebApplicationCacheHostImpl::WorkerWebApplicationCacheHostImpl( + const WorkerAppCacheInitInfo& init_info, + WebKit::WebApplicationCacheHostClient* client) + : WebApplicationCacheHostImpl(client, + WorkerThread::current()->appcache_dispatcher()->backend_proxy()) { + // TODO(michaeln): Send a worker specific init message. + // backend_->SelectCacheForWorker(init_info); +} diff --git a/chrome/worker/worker_webapplicationcachehost_impl.h b/chrome/worker/worker_webapplicationcachehost_impl.h new file mode 100644 index 0000000..59ba2a2 --- /dev/null +++ b/chrome/worker/worker_webapplicationcachehost_impl.h @@ -0,0 +1,52 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_WORKER_WORKER_WEBAPPLICATIONCACHEHOST_IMPL_H_ +#define CHROME_WORKER_WORKER_WEBAPPLICATIONCACHEHOST_IMPL_H_ + +#include "webkit/appcache/web_application_cache_host_impl.h" + +// Information used to construct and initialize an appcache host +// for a worker. +struct WorkerAppCacheInitInfo { + bool is_shared_worker; + int parent_process_id; + int parent_appcache_host_id; // Only valid for dedicated workers. + int64 main_resource_appcache_id; // Only valid for shared workers. + + WorkerAppCacheInitInfo() + : is_shared_worker(false), parent_process_id(0), + parent_appcache_host_id(0), main_resource_appcache_id(0) { + } + WorkerAppCacheInitInfo( + bool is_shared, int process_id, int host_id, int64 cache_id) + : is_shared_worker(is_shared), parent_process_id(process_id), + parent_appcache_host_id(host_id), main_resource_appcache_id(cache_id) { + } +}; + +class WorkerWebApplicationCacheHostImpl + : public appcache::WebApplicationCacheHostImpl { + public: + WorkerWebApplicationCacheHostImpl( + const WorkerAppCacheInitInfo& init_info, + WebKit::WebApplicationCacheHostClient* client); + + // Main resource loading is different for workers. The resource is + // loaded by the creator of the worker rather than the worker itself. + virtual void willStartMainResourceRequest(WebKit::WebURLRequest&) {} + virtual void didReceiveResponseForMainResource( + const WebKit::WebURLResponse&) {} + virtual void didReceiveDataForMainResource(const char* data, int len) {} + virtual void didFinishLoadingMainResource(bool success) {} + + // Cache selection is also different for workers. We know at construction + // time what cache to select and do so then. + virtual void selectCacheWithoutManifest() {} + virtual bool selectCacheWithManifest(const WebKit::WebURL& manifestURL) { + return true; + } +}; + +#endif // CHROME_WORKER_WORKER_WEBAPPLICATIONCACHEHOST_IMPL_H_ |