diff options
57 files changed, 1135 insertions, 523 deletions
diff --git a/chrome/DEPS b/chrome/DEPS index fb83a49..2519453 100644 --- a/chrome/DEPS +++ b/chrome/DEPS @@ -18,6 +18,9 @@ include_rules = [ # Allow inclusion of WebKit API files. "+webkit/api", + # Allow inclusion of the appcache library. + "+webkit/appcache", + # Allow inclusion of Mozilla interface headers. "+third_party/mozilla", diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.cc b/chrome/browser/renderer_host/resource_dispatcher_host.cc index 7e5cded..0066ad6 100644 --- a/chrome/browser/renderer_host/resource_dispatcher_host.cc +++ b/chrome/browser/renderer_host/resource_dispatcher_host.cc @@ -52,7 +52,7 @@ #include "net/base/ssl_cert_request_info.h" #include "net/url_request/url_request.h" #include "net/url_request/url_request_context.h" -#include "webkit/glue/webappcachecontext.h" +#include "webkit/appcache/appcache_interfaces.h" // TODO(port): Move these includes to the above section when porting is done. #if defined(OS_POSIX) @@ -237,7 +237,8 @@ void PopulateResourceResponse(URLRequest* request, request->GetCharset(&response->response_head.charset); response->response_head.filter_policy = filter_policy; response->response_head.content_length = request->GetExpectedContentSize(); - response->response_head.app_cache_id = WebAppCacheContext::kNoAppCacheId; + response->response_head.appcache_id = appcache::kNoCacheId; + response->response_head.appcache_manifest_url = GURL(); request->GetMimeType(&response->response_head.mime_type); } diff --git a/chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc b/chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc index 513c464..3b94b48 100644 --- a/chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc +++ b/chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc @@ -16,7 +16,7 @@ #include "net/url_request/url_request_job.h" #include "net/url_request/url_request_test_job.h" #include "testing/gtest/include/gtest/gtest.h" -#include "webkit/glue/webappcachecontext.h" +#include "webkit/appcache/appcache_interfaces.h" static int RequestIDForMessage(const IPC::Message& msg) { int request_id = -1; @@ -45,7 +45,7 @@ static ViewHostMsg_Resource_Request CreateResourceRequest(const char* method, request.origin_pid = 0; request.resource_type = ResourceType::SUB_RESOURCE; request.request_context = 0; - request.app_cache_context_id = WebAppCacheContext::kNoAppCacheContextId; + request.appcache_host_id = appcache::kNoHostId; return request; } diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc index 4ab489f..c8183bb 100644 --- a/chrome/browser/renderer_host/resource_message_filter.cc +++ b/chrome/browser/renderer_host/resource_message_filter.cc @@ -29,7 +29,7 @@ #include "chrome/browser/spellchecker.h" #include "chrome/browser/worker_host/message_port_dispatcher.h" #include "chrome/browser/worker_host/worker_service.h" -#include "chrome/common/app_cache/app_cache_dispatcher_host.h" +#include "chrome/common/appcache/appcache_dispatcher_host.h" #include "chrome/common/chrome_plugin_lib.h" #include "chrome/common/chrome_plugin_util.h" #include "chrome/common/chrome_switches.h" @@ -156,7 +156,7 @@ ResourceMessageFilter::ResourceMessageFilter( profile_(profile), render_widget_helper_(render_widget_helper), audio_renderer_host_(audio_renderer_host), - app_cache_dispatcher_host_(new AppCacheDispatcherHost), + appcache_dispatcher_host_(new AppCacheDispatcherHost), ALLOW_THIS_IN_INITIALIZER_LIST(dom_storage_dispatcher_host_( new DOMStorageDispatcherHost(this, profile->GetWebKitContext(), resource_dispatcher_host->webkit_thread()))), @@ -170,7 +170,7 @@ ResourceMessageFilter::ResourceMessageFilter( DCHECK(media_request_context_.get()); DCHECK(media_request_context_->cookie_store()); DCHECK(audio_renderer_host_.get()); - DCHECK(app_cache_dispatcher_host_.get()); + DCHECK(appcache_dispatcher_host_.get()); DCHECK(dom_storage_dispatcher_host_.get()); } @@ -194,7 +194,7 @@ ResourceMessageFilter::~ResourceMessageFilter() { void ResourceMessageFilter::Init(int render_process_id) { render_process_id_ = render_process_id; render_widget_helper_->Init(render_process_id, resource_dispatcher_host_); - app_cache_dispatcher_host_->Initialize(this); + appcache_dispatcher_host_->Initialize(this); } // Called on the IPC thread: @@ -257,7 +257,7 @@ bool ResourceMessageFilter::OnMessageReceived(const IPC::Message& msg) { bool msg_is_ok = true; bool handled = resource_dispatcher_host_->OnMessageReceived(msg, this, &msg_is_ok) || - app_cache_dispatcher_host_->OnMessageReceived(msg, &msg_is_ok) || + appcache_dispatcher_host_->OnMessageReceived(msg, &msg_is_ok) || dom_storage_dispatcher_host_->OnMessageReceived(msg, &msg_is_ok) || audio_renderer_host_->OnMessageReceived(msg, &msg_is_ok) || db_dispatcher_host_->OnMessageReceived(msg, &msg_is_ok) || diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h index a84ee95..f3087a8 100644 --- a/chrome/browser/renderer_host/resource_message_filter.h +++ b/chrome/browser/renderer_host/resource_message_filter.h @@ -310,7 +310,7 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter, scoped_refptr<AudioRendererHost> audio_renderer_host_; // Handles AppCache related messages. - scoped_ptr<AppCacheDispatcherHost> app_cache_dispatcher_host_; + scoped_ptr<AppCacheDispatcherHost> appcache_dispatcher_host_; // Handles DOM Storage related messages. scoped_refptr<DOMStorageDispatcherHost> dom_storage_dispatcher_host_; diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index db1c012b..2bfba7d 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -362,6 +362,7 @@ '../third_party/sqlite/sqlite.gyp:sqlite', '../third_party/zlib/zlib.gyp:zlib', '../third_party/npapi/npapi.gyp:npapi', + '../webkit/webkit.gyp:appcache', '../webkit/webkit.gyp:glue', ], 'include_dirs': [ @@ -393,12 +394,14 @@ 'common/net/url_request_intercept_job.h', 'common/web_resource/web_resource_unpacker.cc', 'common/web_resource/web_resource_unpacker.h', - 'common/app_cache/app_cache_context_impl.cc', - 'common/app_cache/app_cache_context_impl.h', - 'common/app_cache/app_cache_dispatcher.cc', - 'common/app_cache/app_cache_dispatcher.h', - 'common/app_cache/app_cache_dispatcher_host.cc', - 'common/app_cache/app_cache_dispatcher_host.h', + 'common/appcache/appcache_backend_proxy.cc', + 'common/appcache/appcache_backend_proxy.h', + 'common/appcache/appcache_dispatcher.cc', + 'common/appcache/appcache_dispatcher.h', + 'common/appcache/appcache_dispatcher_host.cc', + 'common/appcache/appcache_dispatcher_host.h', + 'common/appcache/appcache_frontend_proxy.cc', + 'common/appcache/appcache_frontend_proxy.h', 'common/automation_constants.cc', 'common/automation_constants.h', 'common/bindings_policy.h', diff --git a/chrome/common/app_cache/app_cache_context_impl.cc b/chrome/common/app_cache/app_cache_context_impl.cc deleted file mode 100644 index c622001..0000000 --- a/chrome/common/app_cache/app_cache_context_impl.cc +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (c) 2009 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/common/app_cache/app_cache_context_impl.h" - -#include "base/logging.h" -#include "chrome/common/render_messages.h" -#include "chrome/common/child_thread.h" -#include "googleurl/src/gurl.h" - -IDMap<AppCacheContextImpl> AppCacheContextImpl::all_contexts; - -// static -AppCacheContextImpl* AppCacheContextImpl::FromContextId(int id) { - return all_contexts.Lookup(id); -} - -AppCacheContextImpl::AppCacheContextImpl(IPC::Message::Sender *sender) - : context_id_(kNoAppCacheContextId), - app_cache_id_(kUnknownAppCacheId), - pending_select_request_id_(0), - sender_(sender) { - DCHECK(sender_); -} - -AppCacheContextImpl::~AppCacheContextImpl() { - UnInitializeContext(); -} - -void AppCacheContextImpl::Initialize(ContextType context_type, - WebAppCacheContext *parent) { - DCHECK(context_id_ == kNoAppCacheContextId); - DCHECK(((context_type == MAIN_FRAME) && !parent) || - ((context_type != MAIN_FRAME) && parent)); - - context_id_ = all_contexts.Add(this); - CHECK(context_id_ != kNoAppCacheContextId); - - sender_->Send(new AppCacheMsg_ContextCreated(context_type, - context_id_, - parent ? parent->GetContextID() - : kNoAppCacheContextId)); -} - -void AppCacheContextImpl::UnInitializeContext() { - if (context_id_ != kNoAppCacheContextId) { - sender_->Send(new AppCacheMsg_ContextDestroyed(context_id_)); - all_contexts.Remove(context_id_); - context_id_ = kNoAppCacheContextId; - } -} - -void AppCacheContextImpl::SelectAppCacheWithoutManifest( - const GURL &document_url, - int64 cache_document_was_loaded_from) { - DCHECK(context_id_ != kNoAppCacheContextId); - app_cache_id_ = kUnknownAppCacheId; // unknown until we get a response - sender_->Send(new AppCacheMsg_SelectAppCache( - context_id_, ++pending_select_request_id_, - document_url, cache_document_was_loaded_from, - GURL::EmptyGURL())); -} - -void AppCacheContextImpl::SelectAppCacheWithManifest( - const GURL &document_url, - int64 cache_document_was_loaded_from, - const GURL &manifest_url) { - DCHECK(context_id_ != kNoAppCacheContextId); - app_cache_id_ = kUnknownAppCacheId; // unknown until we get a response - sender_->Send(new AppCacheMsg_SelectAppCache( - context_id_, ++pending_select_request_id_, - document_url, cache_document_was_loaded_from, - manifest_url)); -} - -void AppCacheContextImpl::OnAppCacheSelected(int select_request_id, - int64 app_cache_id) { - if (select_request_id == pending_select_request_id_) { - DCHECK(app_cache_id_ == kUnknownAppCacheId); - DCHECK(app_cache_id != kUnknownAppCacheId); - app_cache_id_ = app_cache_id; - } -} diff --git a/chrome/common/app_cache/app_cache_context_impl.h b/chrome/common/app_cache/app_cache_context_impl.h deleted file mode 100644 index ec2f25f..0000000 --- a/chrome/common/app_cache/app_cache_context_impl.h +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) 2009 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_COMMON_APP_CACHE_APP_CACHE_CONTEXT_IMPL_H_ -#define CHROME_COMMON_APP_CACHE_APP_CACHE_CONTEXT_IMPL_H_ - -#include "base/id_map.h" -#include "ipc/ipc_message.h" -#include "webkit/glue/webappcachecontext.h" - -// A concrete implemenation of WebAppCacheContext for use in a child process. -class AppCacheContextImpl : public WebAppCacheContext { - public: - // Returns the context having given id or NULL if there is no such context. - static AppCacheContextImpl* FromContextId(int id); - - AppCacheContextImpl(IPC::Message::Sender* sender); - virtual ~AppCacheContextImpl(); - - // WebAppCacheContext implementation - virtual int GetContextID() { return context_id_; } - virtual int64 GetAppCacheID() { return app_cache_id_; } - virtual void Initialize(WebAppCacheContext::ContextType context_type, - WebAppCacheContext* opt_parent); - virtual void SelectAppCacheWithoutManifest( - const GURL& document_url, - int64 cache_document_was_loaded_from); - virtual void SelectAppCacheWithManifest( - const GURL& document_url, - int64 cache_document_was_loaded_from, - const GURL& manifest_url); - - // Called by AppCacheDispatcher when the browser has selected an appcache. - void OnAppCacheSelected(int select_request_id, int64 app_cache_id); - - private: - void UnInitializeContext(); - - int context_id_; - int64 app_cache_id_; - int pending_select_request_id_; - IPC::Message::Sender* sender_; - - static IDMap<AppCacheContextImpl> all_contexts; -}; - -#endif // CHROME_COMMON_APP_CACHE_APP_CACHE_CONTEXT_IMPL_H_ diff --git a/chrome/common/app_cache/app_cache_dispatcher.cc b/chrome/common/app_cache/app_cache_dispatcher.cc deleted file mode 100644 index ba81243..0000000 --- a/chrome/common/app_cache/app_cache_dispatcher.cc +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2009 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/common/app_cache/app_cache_dispatcher.h" - -#include "chrome/common/app_cache/app_cache_context_impl.h" -#include "chrome/common/render_messages.h" - -bool AppCacheDispatcher::OnMessageReceived(const IPC::Message& msg) { - bool handled = true; - IPC_BEGIN_MESSAGE_MAP(AppCacheDispatcher, msg) - IPC_MESSAGE_HANDLER(AppCacheMsg_AppCacheSelected, OnAppCacheSelected) - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP() - return handled; -} - -void AppCacheDispatcher::OnAppCacheSelected(int context_id, - int select_request_id, - int64 app_cache_id) { - AppCacheContextImpl *context = AppCacheContextImpl::FromContextId(context_id); - if (context) { - context->OnAppCacheSelected(select_request_id, app_cache_id); - } -} diff --git a/chrome/common/app_cache/app_cache_dispatcher.h b/chrome/common/app_cache/app_cache_dispatcher.h deleted file mode 100644 index 3d4cbbd..0000000 --- a/chrome/common/app_cache/app_cache_dispatcher.h +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2009 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_COMMON_APP_CACHE_APP_CACHE_DISPATCHER_H_ -#define CHROME_COMMON_APP_CACHE_APP_CACHE_DISPATCHER_H_ - -#include "base/basictypes.h" -#include "ipc/ipc_message.h" - -// Dispatches app cache related messages sent to a child process from the -// main browser process. There is one instance per child process. Messages -// are dispatched on the main child thread. The ChildThread base class -// creates an instance and delegates calls to it. -class AppCacheDispatcher { - public: - bool OnMessageReceived(const IPC::Message& msg); - - private: - // AppCacheContextImpl related messages - void OnAppCacheSelected(int context_id, - int select_request_id, - int64 app_cache_id); -}; - -#endif // CHROME_COMMON_APP_CACHE_APP_CACHE_DISPATCHER_H_ diff --git a/chrome/common/app_cache/app_cache_dispatcher_host.cc b/chrome/common/app_cache/app_cache_dispatcher_host.cc deleted file mode 100644 index 98c774d..0000000 --- a/chrome/common/app_cache/app_cache_dispatcher_host.cc +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) 2009 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/common/app_cache/app_cache_dispatcher_host.h" - -#include "chrome/common/render_messages.h" - -AppCacheDispatcherHost::~AppCacheDispatcherHost() { - if (sender_) { - // TODO(michaeln): plumb to request_context_->app_cache_service - // to remove contexts for the child process that is going away. - } -} - -void AppCacheDispatcherHost::Initialize(IPC::Message::Sender* sender) { - DCHECK(sender); - sender_ = sender; - // TODO(michaeln): plumb to request_context_->app_cache_service to - // tell it about this child process coming into existance -} - -bool AppCacheDispatcherHost::OnMessageReceived(const IPC::Message& msg, - bool *msg_ok) { - DCHECK(sender_); - *msg_ok = true; - bool handled = true; - IPC_BEGIN_MESSAGE_MAP_EX(AppCacheDispatcherHost, msg, *msg_ok) - IPC_MESSAGE_HANDLER(AppCacheMsg_ContextCreated, OnContextCreated); - IPC_MESSAGE_HANDLER(AppCacheMsg_ContextDestroyed, OnContextDestroyed); - IPC_MESSAGE_HANDLER(AppCacheMsg_SelectAppCache, OnSelectAppCache); - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP_EX() - return handled; -} - -void AppCacheDispatcherHost::OnContextCreated( - WebAppCacheContext::ContextType context_type, - int context_id, - int opt_parent_id) { - // TODO(michaeln): implement me, plumb to request_context->app_cache_service - DCHECK(context_id != WebAppCacheContext::kNoAppCacheContextId); -} - -void AppCacheDispatcherHost::OnContextDestroyed(int context_id) { - // TODO(michaeln): implement me, plumb to request_context->app_cache_service - DCHECK(context_id != WebAppCacheContext::kNoAppCacheContextId); -} - -void AppCacheDispatcherHost::OnSelectAppCache( - int context_id, - int select_request_id, - const GURL& document_url, - int64 cache_document_was_loaded_from, - const GURL& opt_manifest_url) { - // TODO(michaeln): implement me, plumb to request_context->app_cache_service - DCHECK(context_id != WebAppCacheContext::kNoAppCacheContextId); - Send(new AppCacheMsg_AppCacheSelected(context_id, select_request_id, - WebAppCacheContext::kNoAppCacheId)); -} diff --git a/chrome/common/app_cache/app_cache_dispatcher_host.h b/chrome/common/app_cache/app_cache_dispatcher_host.h deleted file mode 100644 index 749e74a..0000000 --- a/chrome/common/app_cache/app_cache_dispatcher_host.h +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) 2009 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_COMMON_APP_CACHE_APP_CACHE_DISPATCHER_HOST_H_ -#define CHROME_COMMON_APP_CACHE_APP_CACHE_DISPATCHER_HOST_H_ - -#include "base/id_map.h" -#include "ipc/ipc_message.h" -#include "webkit/glue/webappcachecontext.h" - -class GURL; - -// Handles app cache related messages sent to the main browser process from -// its child processes. There is a distinct host for each child process. -// Messages are handled on the IO thread. The ResourceMessageFilter creates -// an instance and delegates calls to it. -class AppCacheDispatcherHost { - public: - AppCacheDispatcherHost() : sender_(NULL) {} - ~AppCacheDispatcherHost(); - void Initialize(IPC::Message::Sender* sender); - bool OnMessageReceived(const IPC::Message& msg, bool* msg_is_ok); - - private: - // AppCacheContextImpl related messages - void OnContextCreated(WebAppCacheContext::ContextType context_type, - int context_id, int opt_parent_id); - void OnContextDestroyed(int context_id); - void OnSelectAppCache(int context_id, - int select_request_id, - const GURL& document_url, - int64 cache_document_was_loaded_from, - const GURL& opt_manifest_url); - - bool Send(IPC::Message* msg) { - return sender_->Send(msg); - } - - IPC::Message::Sender* sender_; -}; - -#endif // CHROME_COMMON_APP_CACHE_APP_CACHE_DISPATCHER_HOST_H_ diff --git a/chrome/common/appcache/appcache_backend_proxy.cc b/chrome/common/appcache/appcache_backend_proxy.cc new file mode 100644 index 0000000..14b81f1 --- /dev/null +++ b/chrome/common/appcache/appcache_backend_proxy.cc @@ -0,0 +1,53 @@ +// Copyright (c) 2009 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/common/appcache/appcache_backend_proxy.h" + +#include "chrome/common/render_messages.h" + +void AppCacheBackendProxy::RegisterHost(int host_id) { + sender_->Send(new AppCacheMsg_RegisterHost(host_id)); +} + +void AppCacheBackendProxy::UnregisterHost(int host_id) { + sender_->Send(new AppCacheMsg_UnregisterHost(host_id)); +} + +void AppCacheBackendProxy::SelectCache( + int host_id, + const GURL& document_url, + const int64 cache_document_was_loaded_from, + const GURL& manifest_url) { + sender_->Send(new AppCacheMsg_SelectCache( + host_id, document_url, + cache_document_was_loaded_from, + manifest_url)); +} + +void AppCacheBackendProxy::MarkAsForeignEntry( + int host_id, const GURL& document_url, + int64 cache_document_was_loaded_from) { + sender_->Send(new AppCacheMsg_MarkAsForeignEntry( + host_id, document_url, + cache_document_was_loaded_from)); +} + +appcache::Status AppCacheBackendProxy::GetStatus(int host_id) { + appcache::Status status; + sender_->Send(new AppCacheMsg_GetStatus(host_id, &status)); + return status; +} + +bool AppCacheBackendProxy::StartUpdate(int host_id) { + bool result; + sender_->Send(new AppCacheMsg_StartUpdate(host_id, &result)); + return result; +} + +bool AppCacheBackendProxy::SwapCache(int host_id) { + bool result; + sender_->Send(new AppCacheMsg_SwapCache(host_id, &result)); + return result; +} + diff --git a/chrome/common/appcache/appcache_backend_proxy.h b/chrome/common/appcache/appcache_backend_proxy.h new file mode 100644 index 0000000..5098336 --- /dev/null +++ b/chrome/common/appcache/appcache_backend_proxy.h @@ -0,0 +1,36 @@ +// Copyright (c) 2009 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_COMMON_APPCACHE_APPCACHE_BACKEND_PROXY_H_ +#define CHROME_COMMON_APPCACHE_APPCACHE_BACKEND_PROXY_H_ + +#include "ipc/ipc_message.h" +#include "webkit/appcache/appcache_interfaces.h" + +// Sends appcache related messages to the main process. +class AppCacheBackendProxy : public appcache::AppCacheBackend { + public: + explicit AppCacheBackendProxy(IPC::Message::Sender* sender) + : sender_(sender) {} + + IPC::Message::Sender* sender() const { return sender_; } + + // AppCacheBackend methods + virtual void RegisterHost(int host_id); + virtual void UnregisterHost(int host_id); + virtual void SelectCache(int host_id, + const GURL& document_url, + const int64 cache_document_was_loaded_from, + const GURL& manifest_url); + virtual void MarkAsForeignEntry(int host_id, const GURL& document_url, + int64 cache_document_was_loaded_from); + virtual appcache::Status GetStatus(int host_id); + virtual bool StartUpdate(int host_id); + virtual bool SwapCache(int host_id); + + private: + IPC::Message::Sender* sender_; +}; + +#endif // CHROME_COMMON_APPCACHE_APPCACHE_BACKEND_PROXY_H_ diff --git a/chrome/common/appcache/appcache_dispatcher.cc b/chrome/common/appcache/appcache_dispatcher.cc new file mode 100644 index 0000000..71461ba --- /dev/null +++ b/chrome/common/appcache/appcache_dispatcher.cc @@ -0,0 +1,34 @@ +// Copyright (c) 2009 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/common/appcache/appcache_dispatcher.h" + +#include "chrome/common/render_messages.h" +#include "webkit/appcache/web_application_cache_host_impl.h" + +bool AppCacheDispatcher::OnMessageReceived(const IPC::Message& msg) { + bool handled = true; + IPC_BEGIN_MESSAGE_MAP(AppCacheDispatcher, msg) + IPC_MESSAGE_HANDLER(AppCacheMsg_CacheSelected, OnCacheSelected) + IPC_MESSAGE_HANDLER(AppCacheMsg_StatusChanged, OnStatusChanged) + IPC_MESSAGE_HANDLER(AppCacheMsg_EventRaised, OnEventRaised) + IPC_MESSAGE_UNHANDLED(handled = false) + IPC_END_MESSAGE_MAP() + return handled; +} + +void AppCacheDispatcher::OnCacheSelected(int host_id, int64 cache_id, + appcache::Status status) { + frontend_impl_.OnCacheSelected(host_id, cache_id, status); +} + +void AppCacheDispatcher::OnStatusChanged(const std::vector<int>& host_ids, + appcache::Status status) { + frontend_impl_.OnStatusChanged(host_ids, status); +} + +void AppCacheDispatcher::OnEventRaised(const std::vector<int>& host_ids, + appcache::EventID event_id) { + frontend_impl_.OnEventRaised(host_ids, event_id); +} diff --git a/chrome/common/appcache/appcache_dispatcher.h b/chrome/common/appcache/appcache_dispatcher.h new file mode 100644 index 0000000..9eaef6a --- /dev/null +++ b/chrome/common/appcache/appcache_dispatcher.h @@ -0,0 +1,39 @@ +// Copyright (c) 2009 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_COMMON_APPCACHE_APPCACHE_DISPATCHER_H_ +#define CHROME_COMMON_APPCACHE_APPCACHE_DISPATCHER_H_ + +#include <vector> +#include "chrome/common/appcache/appcache_backend_proxy.h" +#include "ipc/ipc_message.h" +#include "webkit/appcache/appcache_frontend_impl.h" + +// Dispatches appcache related messages sent to a child process from the +// main browser process. There is one instance per child process. Messages +// are dispatched on the main child thread. The ChildThread base class +// creates an instance and delegates calls to it. +class AppCacheDispatcher { + public: + explicit AppCacheDispatcher(IPC::Message::Sender* sender) + : backend_proxy_(sender) {} + + AppCacheBackendProxy* backend_proxy() { return &backend_proxy_; } + + bool OnMessageReceived(const IPC::Message& msg); + + private: + // Ipc message handlers + void OnCacheSelected(int host_id, int64 cache_id, + appcache::Status status); + void OnStatusChanged(const std::vector<int>& host_ids, + appcache::Status status); + void OnEventRaised(const std::vector<int>& host_ids, + appcache::EventID event_id); + + AppCacheBackendProxy backend_proxy_; + appcache::AppCacheFrontendImpl frontend_impl_; +}; + +#endif // CHROME_COMMON_APPCACHE_APPCACHE_DISPATCHER_H_ diff --git a/chrome/common/appcache/appcache_dispatcher_host.cc b/chrome/common/appcache/appcache_dispatcher_host.cc new file mode 100644 index 0000000..b71f2d9 --- /dev/null +++ b/chrome/common/appcache/appcache_dispatcher_host.cc @@ -0,0 +1,79 @@ +// Copyright (c) 2009 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/common/appcache/appcache_dispatcher_host.h" + +#include "chrome/common/render_messages.h" + +void AppCacheDispatcherHost::Initialize(IPC::Message::Sender* sender) { + DCHECK(sender); + frontend_proxy_.set_sender(sender); + backend_impl_.Initialize(NULL, &frontend_proxy_); +} + +bool AppCacheDispatcherHost::OnMessageReceived(const IPC::Message& msg, + bool *msg_ok) { + DCHECK(frontend_proxy_.sender()); + *msg_ok = true; + bool handled = true; + IPC_BEGIN_MESSAGE_MAP_EX(AppCacheDispatcherHost, msg, *msg_ok) + IPC_MESSAGE_HANDLER(AppCacheMsg_RegisterHost, OnRegisterHost); + IPC_MESSAGE_HANDLER(AppCacheMsg_UnregisterHost, OnUnregisterHost); + IPC_MESSAGE_HANDLER(AppCacheMsg_SelectCache, OnSelectCache); + IPC_MESSAGE_HANDLER(AppCacheMsg_MarkAsForeignEntry, OnMarkAsForeignEntry); + IPC_MESSAGE_HANDLER_DELAY_REPLY(AppCacheMsg_GetStatus, OnGetStatus); + IPC_MESSAGE_HANDLER_DELAY_REPLY(AppCacheMsg_StartUpdate, OnStartUpdate); + IPC_MESSAGE_HANDLER_DELAY_REPLY(AppCacheMsg_SwapCache, OnSwapCache); + IPC_MESSAGE_UNHANDLED(handled = false) + IPC_END_MESSAGE_MAP_EX() + return handled; +} + +void AppCacheDispatcherHost::OnRegisterHost(int host_id) { + backend_impl_.RegisterHost(host_id); +} + +void AppCacheDispatcherHost::OnUnregisterHost(int host_id) { + backend_impl_.UnregisterHost(host_id); +} + +void AppCacheDispatcherHost::OnSelectCache( + int host_id, const GURL& document_url, + int64 cache_document_was_loaded_from, + const GURL& opt_manifest_url) { + backend_impl_.SelectCache(host_id, document_url, + cache_document_was_loaded_from, + opt_manifest_url); +} + +void AppCacheDispatcherHost::OnMarkAsForeignEntry( + int host_id, const GURL& document_url, + int64 cache_document_was_loaded_from) { + backend_impl_.MarkAsForeignEntry(host_id, document_url, + cache_document_was_loaded_from); +} + +void AppCacheDispatcherHost::OnGetStatus(int host_id, + IPC::Message* reply_msg) { + // TODO(michaeln): Handle the case where cache selection is not yet complete. + appcache::Status status = backend_impl_.GetStatus(host_id); + AppCacheMsg_GetStatus::WriteReplyParams(reply_msg, status); + frontend_proxy_.sender()->Send(reply_msg); +} + +void AppCacheDispatcherHost::OnStartUpdate(int host_id, + IPC::Message* reply_msg) { + // TODO(michaeln): Handle the case where cache selection is not yet complete. + bool success = backend_impl_.StartUpdate(host_id); + AppCacheMsg_StartUpdate::WriteReplyParams(reply_msg, success); + frontend_proxy_.sender()->Send(reply_msg); +} + +void AppCacheDispatcherHost::OnSwapCache(int host_id, + IPC::Message* reply_msg) { + // TODO(michaeln): Handle the case where cache selection is not yet complete. + bool success = backend_impl_.SwapCache(host_id); + AppCacheMsg_SwapCache::WriteReplyParams(reply_msg, success); + frontend_proxy_.sender()->Send(reply_msg); +} diff --git a/chrome/common/appcache/appcache_dispatcher_host.h b/chrome/common/appcache/appcache_dispatcher_host.h new file mode 100644 index 0000000..f141fdb --- /dev/null +++ b/chrome/common/appcache/appcache_dispatcher_host.h @@ -0,0 +1,44 @@ +// Copyright (c) 2009 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_COMMON_APPCACHE_APPCACHE_DISPATCHER_HOST_H_ +#define CHROME_COMMON_APPCACHE_APPCACHE_DISPATCHER_HOST_H_ + +#include <vector> +#include "chrome/common/appcache/appcache_frontend_proxy.h" +#include "ipc/ipc_message.h" +#include "webkit/appcache/appcache_backend_impl.h" + +// Handles appcache related messages sent to the main browser process from +// its child processes. There is a distinct host for each child process. +// Messages are handled on the IO thread. The ResourceMessageFilter creates +// an instance and delegates calls to it. +class AppCacheDispatcherHost { + public: + void Initialize(IPC::Message::Sender* sender); + bool OnMessageReceived(const IPC::Message& msg, bool* msg_is_ok); + + // Note: needed to satisfy ipc message dispatching macros. + bool Send(IPC::Message* msg) { + return frontend_proxy_.sender()->Send(msg); + } + + private: + // Ipc message handlers + void OnRegisterHost(int host_id); + void OnUnregisterHost(int host_id); + void OnSelectCache(int host_id, const GURL& document_url, + int64 cache_document_was_loaded_from, + const GURL& opt_manifest_url); + void OnMarkAsForeignEntry(int host_id, const GURL& document_url, + int64 cache_document_was_loaded_from); + void OnGetStatus(int host_id, IPC::Message* reply_msg); + void OnStartUpdate(int host_id, IPC::Message* reply_msg); + void OnSwapCache(int host_id, IPC::Message* reply_msg); + + AppCacheFrontendProxy frontend_proxy_; + appcache::AppCacheBackendImpl backend_impl_; +}; + +#endif // CHROME_COMMON_APPCACHE_APPCACHE_DISPATCHER_HOST_H_ diff --git a/chrome/common/appcache/appcache_frontend_proxy.cc b/chrome/common/appcache/appcache_frontend_proxy.cc new file mode 100644 index 0000000..bf20baa8 --- /dev/null +++ b/chrome/common/appcache/appcache_frontend_proxy.cc @@ -0,0 +1,23 @@ +// Copyright (c) 2009 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/common/appcache/appcache_frontend_proxy.h" + +#include "chrome/common/render_messages.h" + +void AppCacheFrontendProxy::OnCacheSelected(int host_id, int64 cache_id , + appcache::Status status) { + sender_->Send(new AppCacheMsg_CacheSelected(host_id, cache_id, status)); +} + +void AppCacheFrontendProxy::OnStatusChanged(const std::vector<int>& host_ids, + appcache::Status status) { + sender_->Send(new AppCacheMsg_StatusChanged(host_ids, status)); +} + +void AppCacheFrontendProxy::OnEventRaised(const std::vector<int>& host_ids, + appcache::EventID event_id) { + sender_->Send(new AppCacheMsg_EventRaised(host_ids, event_id)); +} + diff --git a/chrome/common/appcache/appcache_frontend_proxy.h b/chrome/common/appcache/appcache_frontend_proxy.h new file mode 100644 index 0000000..b18f9bb --- /dev/null +++ b/chrome/common/appcache/appcache_frontend_proxy.h @@ -0,0 +1,31 @@ +// Copyright (c) 2009 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_COMMON_APPCACHE_APPCACHE_FRONTEND_PROXY_H_ +#define CHROME_COMMON_APPCACHE_APPCACHE_FRONTEND_PROXY_H_ + +#include <vector> +#include "ipc/ipc_message.h" +#include "webkit/appcache/appcache_interfaces.h" + +// Sends appcache related messages to a child process. +class AppCacheFrontendProxy : public appcache::AppCacheFrontend { + public: + AppCacheFrontendProxy() : sender_(NULL) {} + void set_sender(IPC::Message::Sender* sender) { sender_ = sender; } + IPC::Message::Sender* sender() const { return sender_; } + + // AppCacheFrontend methods + virtual void OnCacheSelected(int host_id, int64 cache_id , + appcache::Status); + virtual void OnStatusChanged(const std::vector<int>& host_ids, + appcache::Status status); + virtual void OnEventRaised(const std::vector<int>& host_ids, + appcache::EventID event_id); + + private: + IPC::Message::Sender* sender_; +}; + +#endif // CHROME_COMMON_APPCACHE_APPCACHE_FRONTEND_PROXY_H_ diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index af0e901..fcbf0a4 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -29,6 +29,7 @@ #include "media/audio/audio_output.h" #include "net/base/upload_data.h" #include "net/http/http_response_headers.h" +#include "webkit/appcache/appcache_interfaces.h" #include "webkit/glue/autofill_form.h" #include "webkit/glue/context_menu.h" #include "webkit/glue/form_data.h" @@ -37,7 +38,6 @@ #include "webkit/glue/password_form_dom_manager.h" #include "webkit/glue/resource_loader_bridge.h" #include "webkit/glue/webaccessibility.h" -#include "webkit/glue/webappcachecontext.h" #include "webkit/glue/webdropdata.h" #include "webkit/glue/webmenuitem.h" #include "webkit/glue/webplugin.h" @@ -320,8 +320,8 @@ struct ViewHostMsg_Resource_Request { uint32 request_context; // Indicates which frame (or worker context) the request is being loaded into, - // or kNoAppCacheContextId. - int32 app_cache_context_id; + // or kNoHostId. + int appcache_host_id; // Optional upload data (may be null). scoped_refptr<net::UploadData> upload_data; @@ -1265,7 +1265,7 @@ struct ParamTraits<ViewHostMsg_Resource_Request> { WriteParam(m, p.origin_pid); WriteParam(m, p.resource_type); WriteParam(m, p.request_context); - WriteParam(m, p.app_cache_context_id); + WriteParam(m, p.appcache_host_id); WriteParam(m, p.upload_data); } static bool Read(const Message* m, void** iter, param_type* r) { @@ -1281,7 +1281,7 @@ struct ParamTraits<ViewHostMsg_Resource_Request> { ReadParam(m, iter, &r->origin_pid) && ReadParam(m, iter, &r->resource_type) && ReadParam(m, iter, &r->request_context) && - ReadParam(m, iter, &r->app_cache_context_id) && + ReadParam(m, iter, &r->appcache_host_id) && ReadParam(m, iter, &r->upload_data); } static void Log(const param_type& p, std::wstring* l) { @@ -1304,7 +1304,7 @@ struct ParamTraits<ViewHostMsg_Resource_Request> { l->append(L", "); LogParam(p.request_context, l); l->append(L", "); - LogParam(p.app_cache_context_id, l); + LogParam(p.appcache_host_id, l); l->append(L")"); } }; @@ -1344,7 +1344,8 @@ struct ParamTraits<webkit_glue::ResourceLoaderBridge::ResponseInfo> { WriteParam(m, p.charset); WriteParam(m, p.security_info); WriteParam(m, p.content_length); - WriteParam(m, p.app_cache_id); + WriteParam(m, p.appcache_id); + WriteParam(m, p.appcache_manifest_url); } static bool Read(const Message* m, void** iter, param_type* r) { return @@ -1355,7 +1356,8 @@ struct ParamTraits<webkit_glue::ResourceLoaderBridge::ResponseInfo> { ReadParam(m, iter, &r->charset) && ReadParam(m, iter, &r->security_info) && ReadParam(m, iter, &r->content_length) && - ReadParam(m, iter, &r->app_cache_id); + ReadParam(m, iter, &r->appcache_id) && + ReadParam(m, iter, &r->appcache_manifest_url); } static void Log(const param_type& p, std::wstring* l) { l->append(L"("); @@ -1373,7 +1375,9 @@ struct ParamTraits<webkit_glue::ResourceLoaderBridge::ResponseInfo> { l->append(L", "); LogParam(p.content_length, l); l->append(L", "); - LogParam(p.app_cache_id, l); + LogParam(p.appcache_id, l); + l->append(L", "); + LogParam(p.appcache_manifest_url, l); l->append(L")"); } }; @@ -1848,8 +1852,8 @@ struct ParamTraits<ViewMsg_AudioStreamState> { }; template <> -struct ParamTraits<WebAppCacheContext::ContextType> { - typedef WebAppCacheContext::ContextType param_type; +struct ParamTraits<appcache::Status> { + typedef appcache::Status param_type; static void Write(Message* m, const param_type& p) { m->WriteInt(static_cast<int>(p)); } @@ -1863,17 +1867,75 @@ struct ParamTraits<WebAppCacheContext::ContextType> { static void Log(const param_type& p, std::wstring* l) { std::wstring state; switch (p) { - case WebAppCacheContext::MAIN_FRAME: - state = L"MAIN_FRAME"; + case appcache::UNCACHED: + state = L"UNCACHED"; break; - case WebAppCacheContext::CHILD_FRAME: - state = L"CHILD_FRAME"; + case appcache::IDLE: + state = L"IDLE"; + break; + case appcache::CHECKING: + state = L"CHECKING"; + break; + case appcache::DOWNLOADING: + state = L"DOWNLOADING"; + break; + case appcache::UPDATE_READY: + state = L"UPDATE_READY"; + break; + case appcache::OBSOLETE: + state = L"OBSOLETE"; break; - case WebAppCacheContext::DEDICATED_WORKER: - state = L"DECICATED_WORKER"; - break; default: - state = L"UNKNOWN"; + state = L"InvalidStatusValue"; + break; + } + + LogParam(state, l); + } +}; + +template <> +struct ParamTraits<appcache::EventID> { + typedef appcache::EventID param_type; + static void Write(Message* m, const param_type& p) { + m->WriteInt(static_cast<int>(p)); + } + static bool Read(const Message* m, void** iter, param_type* p) { + int type; + if (!m->ReadInt(iter, &type)) + return false; + *p = static_cast<param_type>(type); + return true; + } + static void Log(const param_type& p, std::wstring* l) { + std::wstring state; + switch (p) { + case appcache::CHECKING_EVENT: + state = L"CHECKING_EVENT"; + break; + case appcache::ERROR_EVENT: + state = L"ERROR_EVENT"; + break; + case appcache::NO_UPDATE_EVENT: + state = L"NO_UPDATE_EVENT"; + break; + case appcache::DOWNLOADING_EVENT: + state = L"DOWNLOADING_EVENT"; + break; + case appcache::PROGRESS_EVENT: + state = L"PROGRESS_EVENT"; + break; + case appcache::UPDATE_READY_EVENT: + state = L"UPDATE_READY_EVENT"; + break; + case appcache::CACHED_EVENT: + state = L"CACHED_EVENT"; + break; + case appcache::OBSOLETE_EVENT: + state = L"OBSOLETE_EVENT"; + break; + default: + state = L"InvalidEventValue"; break; } diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index f94f8e3..6f15991 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -25,8 +25,8 @@ #include "ipc/ipc_channel_handle.h" #include "ipc/ipc_message_macros.h" #include "third_party/skia/include/core/SkBitmap.h" +#include "webkit/appcache/appcache_interfaces.h" #include "webkit/glue/dom_operations.h" -#include "webkit/glue/webappcachecontext.h" #include "webkit/glue/webcursor.h" #include "webkit/glue/webplugin.h" @@ -518,13 +518,22 @@ IPC_BEGIN_MESSAGES(View) // into a full window). IPC_MESSAGE_ROUTED0(ViewMsg_DisassociateFromPopupCount) - // Notifies the renderer of the AppCache that has been selected for a - // a particular context (or frame). This is sent in reply to - // one of the two AppCacheMsg_SelectAppCache messages. - IPC_MESSAGE_CONTROL3(AppCacheMsg_AppCacheSelected, - int /* context_id */, - int /* select_request_id */, - int64 /* cache_id */) + // Notifies the renderer of the appcache that has been selected for a + // a particular host. This is sent in reply to AppCacheMsg_SelectCache. + IPC_MESSAGE_CONTROL3(AppCacheMsg_CacheSelected, + int /* host_id */, + int64 /* appcache_id */, + appcache::Status) + + // Notifies the renderer of an AppCache status change. + IPC_MESSAGE_CONTROL2(AppCacheMsg_StatusChanged, + std::vector<int> /* host_ids */, + appcache::Status) + + // Notifies the renderer of an AppCache event. + IPC_MESSAGE_CONTROL2(AppCacheMsg_EventRaised, + std::vector<int> /* host_ids */, + appcache::EventID) // Reply to the ViewHostMsg_QueryFormFieldAutofill message with the autofill // suggestions. @@ -1341,34 +1350,49 @@ IPC_BEGIN_MESSAGES(ViewHost) gfx::NativeViewId /* window */, gfx::Rect /* Out: Window location */) - // Informs the browser of a new context. - IPC_MESSAGE_CONTROL3(AppCacheMsg_ContextCreated, - WebAppCacheContext::ContextType, - int /* context_id */, - int /* opt_parent_context_id */) - - // Informs the browser of a context being destroyed. - IPC_MESSAGE_CONTROL1(AppCacheMsg_ContextDestroyed, - int /* context_id */) - - // Initiates the cache selection algorithm for the given context. - // This is sent after new content has been committed, but prior to - // any subresource loads. An AppCacheMsg_AppCacheSelected message will - // be sent in response. - // 'context_id' indentifies a specific frame or worker - // 'select_request_id' indentifies this particular invocation the algorithm - // and will be returned to the caller with the response - // 'document_url' the url of the main resource commited to the frame - // 'cache_document_was_loaded_frame' the id of the appcache the main resource - // was loaded from or kNoAppCacheId + // Informs the browser of a new appcache host. + IPC_MESSAGE_CONTROL1(AppCacheMsg_RegisterHost, + int /* host_id */) + + // Informs the browser of an appcache host being destroyed. + IPC_MESSAGE_CONTROL1(AppCacheMsg_UnregisterHost, + int /* host_id */) + + // Initiates the cache selection algorithm for the given host. + // This is sent prior to any subresource loads. An AppCacheMsg_CacheSelected + // message will be sent in response. + // 'host_id' indentifies a specific document or worker + // 'document_url' the url of the main resource + // 'appcache_document_was_loaded_from' the id of the appcache the main + // resource was loaded from or kNoCacheId // 'opt_manifest_url' the manifest url specified in the <html> tag if any - IPC_MESSAGE_CONTROL5(AppCacheMsg_SelectAppCache, - int /* context_id */, - int /* select_request_id */, + IPC_MESSAGE_CONTROL4(AppCacheMsg_SelectCache, + int /* host_id */, GURL /* document_url */, - int64 /* cache_document_was_loaded_from */, + int64 /* appcache_document_was_loaded_from */, GURL /* opt_manifest_url */) + // Informs the browser of a 'foreign' entry in an appcache. + IPC_MESSAGE_CONTROL3(AppCacheMsg_MarkAsForeignEntry, + int /* host_id */, + GURL /* document_url */, + int64 /* appcache_document_was_loaded_from */) + + // Returns the status of the appcache associated with host_id. + IPC_SYNC_MESSAGE_CONTROL1_1(AppCacheMsg_GetStatus, + int /* host_id */, + appcache::Status) + + // Initiates an update of the appcache associated with host_id. + IPC_SYNC_MESSAGE_CONTROL1_1(AppCacheMsg_StartUpdate, + int /* host_id */, + bool /* success */) + + // Swaps a new pending appcache, if there is one, into use for host_id. + IPC_SYNC_MESSAGE_CONTROL1_1(AppCacheMsg_SwapCache, + int /* host_id */, + bool /* success */) + // Returns the resizer box location in the window this widget is embeded. // Important for Mac OS X, but not Win or Linux. IPC_SYNC_MESSAGE_ROUTED1_1(ViewHostMsg_GetRootWindowResizerRect, diff --git a/chrome/common/resource_dispatcher.cc b/chrome/common/resource_dispatcher.cc index 8167901..d0a90a5 100644 --- a/chrome/common/resource_dispatcher.cc +++ b/chrome/common/resource_dispatcher.cc @@ -55,7 +55,7 @@ class IPCResourceLoaderBridge : public ResourceLoaderBridge { int origin_pid, ResourceType::Type resource_type, uint32 request_context, - int app_cache_context_id, + int appcache_host_id, int routing_id); virtual ~IPCResourceLoaderBridge(); @@ -109,7 +109,7 @@ IPCResourceLoaderBridge::IPCResourceLoaderBridge( int origin_pid, ResourceType::Type resource_type, uint32 request_context, - int app_cache_context_id, + int appcache_host_id, int routing_id) : peer_(NULL), dispatcher_(dispatcher), @@ -127,7 +127,7 @@ IPCResourceLoaderBridge::IPCResourceLoaderBridge( request_.origin_pid = origin_pid; request_.resource_type = resource_type; request_.request_context = request_context; - request_.app_cache_context_id = app_cache_context_id; + request_.appcache_host_id = appcache_host_id; #ifdef LOG_RESOURCE_REQUESTS url_ = url.possibly_invalid_spec(); @@ -543,7 +543,7 @@ webkit_glue::ResourceLoaderBridge* ResourceDispatcher::CreateBridge( int origin_pid, ResourceType::Type resource_type, uint32 request_context, - int app_cache_context_id, + int appcache_host_id, int route_id) { return new webkit_glue::IPCResourceLoaderBridge(this, method, url, first_party_for_cookies, @@ -552,7 +552,7 @@ webkit_glue::ResourceLoaderBridge* ResourceDispatcher::CreateBridge( flags, origin_pid, resource_type, request_context, - app_cache_context_id, + appcache_host_id, route_id); } diff --git a/chrome/common/resource_dispatcher.h b/chrome/common/resource_dispatcher.h index a8a9a65..c7a3fa8 100644 --- a/chrome/common/resource_dispatcher.h +++ b/chrome/common/resource_dispatcher.h @@ -45,7 +45,7 @@ class ResourceDispatcher { int origin_pid, ResourceType::Type resource_type, uint32 request_context /* used for plugin->browser requests */, - int app_cache_context_id, + int appcache_host_id, int routing_id); // Adds a request from the pending_requests_ list, returning the new diff --git a/chrome/common/resource_dispatcher_unittest.cc b/chrome/common/resource_dispatcher_unittest.cc index b879670..a270be3 100644 --- a/chrome/common/resource_dispatcher_unittest.cc +++ b/chrome/common/resource_dispatcher_unittest.cc @@ -11,7 +11,7 @@ #include "chrome/common/render_messages.h" #include "chrome/common/resource_dispatcher.h" #include "testing/gtest/include/gtest/gtest.h" -#include "webkit/glue/webappcachecontext.h" +#include "webkit/appcache/appcache_interfaces.h" using webkit_glue::ResourceLoaderBridge; @@ -156,7 +156,7 @@ TEST_F(ResourceDispatcherTest, RoundTrip) { dispatcher_->CreateBridge("GET", GURL(test_page_url), GURL(test_page_url), GURL(), "null", "null", std::string(), 0, 0, ResourceType::SUB_RESOURCE, 0, - WebAppCacheContext::kNoAppCacheContextId, + appcache::kNoHostId, MSG_ROUTING_CONTROL); bridge->Start(&callback); diff --git a/chrome/plugin/chrome_plugin_host.cc b/chrome/plugin/chrome_plugin_host.cc index a5c7dfa..b724ca0 100644 --- a/chrome/plugin/chrome_plugin_host.cc +++ b/chrome/plugin/chrome_plugin_host.cc @@ -21,10 +21,10 @@ #include "net/base/io_buffer.h" #include "net/base/upload_data.h" #include "net/http/http_response_headers.h" +#include "webkit/appcache/appcache_interfaces.h" #include "webkit/glue/plugins/plugin_instance.h" #include "webkit/glue/resource_loader_bridge.h" #include "webkit/glue/resource_type.h" -#include "webkit/glue/webappcachecontext.h" #include "webkit/glue/webkit_glue.h" namespace { @@ -160,7 +160,7 @@ class PluginRequestHandlerProxy base::GetCurrentProcId(), ResourceType::OBJECT, cprequest_->context, - WebAppCacheContext::kNoAppCacheContextId, + appcache::kNoHostId, MSG_ROUTING_CONTROL)); if (!bridge_.get()) return CPERR_FAILURE; diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc index ecddc2de2..b160bed 100644 --- a/chrome/renderer/render_thread.cc +++ b/chrome/renderer/render_thread.cc @@ -12,8 +12,7 @@ #include "base/shared_memory.h" #include "base/stats_table.h" #include "base/thread_local.h" -#include "chrome/common/app_cache/app_cache_context_impl.h" -#include "chrome/common/app_cache/app_cache_dispatcher.h" +#include "chrome/common/appcache/appcache_dispatcher.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/db_message_filter.h" #include "chrome/common/render_messages.h" @@ -61,9 +60,6 @@ namespace { static const unsigned int kCacheStatsDelayMS = 2000 /* milliseconds */; static base::LazyInstance<base::ThreadLocalPointer<RenderThread> > lazy_tls( base::LINKER_INITIALIZED); -static WebAppCacheContext* CreateAppCacheContextForRenderer() { - return new AppCacheContextImpl(RenderThread::current()); -} #if defined(OS_POSIX) class SuicideOnChannelErrorFilter : public IPC::ChannelProxy::MessageFilter { @@ -116,8 +112,7 @@ void RenderThread::Init() { user_script_slave_.reset(new UserScriptSlave()); dns_master_.reset(new RenderDnsMaster()); histogram_snapshots_.reset(new RendererHistogramSnapshots()); - app_cache_dispatcher_.reset(new AppCacheDispatcher()); - WebAppCacheContext::SetFactory(CreateAppCacheContextForRenderer); + appcache_dispatcher_.reset(new AppCacheDispatcher(this)); devtools_agent_filter_ = new DevToolsAgentFilter(); AddFilter(devtools_agent_filter_.get()); db_message_filter_ = new DBMessageFilter(); @@ -134,7 +129,6 @@ RenderThread::~RenderThread() { RemoveFilter(devtools_agent_filter_.get()); RemoveFilter(db_message_filter_.get()); db_message_filter_ = NULL; - WebAppCacheContext::SetFactory(NULL); if (webkit_client_.get()) WebKit::shutdown(); @@ -210,7 +204,7 @@ void RenderThread::OnExtensionSetPermissions( void RenderThread::OnControlMessageReceived(const IPC::Message& msg) { // App cache messages are handled by a delegate. - if (app_cache_dispatcher_->OnMessageReceived(msg)) + if (appcache_dispatcher_->OnMessageReceived(msg)) return; IPC_BEGIN_MESSAGE_MAP(RenderThread, msg) diff --git a/chrome/renderer/render_thread.h b/chrome/renderer/render_thread.h index f90a6a9..4df083f 100644 --- a/chrome/renderer/render_thread.h +++ b/chrome/renderer/render_thread.h @@ -95,6 +95,10 @@ class RenderThread : public RenderThreadBase, return user_script_slave_.get(); } + AppCacheDispatcher* appcache_dispatcher() const { + return appcache_dispatcher_.get(); + } + bool plugin_refresh_allowed() const { return plugin_refresh_allowed_; } // Do DNS prefetch resolution of a hostname. @@ -161,7 +165,7 @@ class RenderThread : public RenderThreadBase, scoped_ptr<VisitedLinkSlave> visited_link_slave_; scoped_ptr<UserScriptSlave> user_script_slave_; scoped_ptr<RenderDnsMaster> dns_master_; - scoped_ptr<AppCacheDispatcher> app_cache_dispatcher_; + scoped_ptr<AppCacheDispatcher> appcache_dispatcher_; scoped_refptr<DevToolsAgentFilter> devtools_agent_filter_; scoped_ptr<RendererHistogramSnapshots> histogram_snapshots_; scoped_ptr<RendererWebKitClientImpl> webkit_client_; diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 5bd7c24..23c916b 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -71,6 +71,7 @@ #include "webkit/api/public/WebURLRequest.h" #include "webkit/api/public/WebURLResponse.h" #include "webkit/api/public/WebVector.h" +#include "webkit/appcache/appcache_interfaces.h" #include "webkit/default_plugin/default_plugin_shared.h" #include "webkit/glue/glue_serialize.h" #include "webkit/glue/dom_operations.h" @@ -1983,7 +1984,7 @@ WebKit::WebMediaPlayer* RenderView::CreateWebMediaPlayer( "null", // frame origin "null", // main_frame_origin base::GetCurrentProcId(), - WebAppCacheContext::kNoAppCacheContextId, + appcache::kNoHostId, routing_id()); if (!cmd_line->HasSwitch(switches::kSimpleDataSource)) { diff --git a/chrome/renderer/renderer_glue.cc b/chrome/renderer/renderer_glue.cc index affb348..c42e8a6 100644 --- a/chrome/renderer/renderer_glue.cc +++ b/chrome/renderer/renderer_glue.cc @@ -220,13 +220,13 @@ ResourceLoaderBridge* ResourceLoaderBridge::Create( int load_flags, int origin_pid, ResourceType::Type resource_type, - int app_cache_context_id, + int appcache_host_id, int routing_id) { ResourceDispatcher* dispatch = ChildThread::current()->resource_dispatcher(); return dispatch->CreateBridge(method, url, first_party_for_cookies, referrer, frame_origin, main_frame_origin, headers, load_flags, origin_pid, resource_type, 0, - app_cache_context_id, routing_id); + appcache_host_id, routing_id); } void NotifyCacheStats() { diff --git a/chrome/renderer/renderer_webkitclient_impl.cc b/chrome/renderer/renderer_webkitclient_impl.cc index a9bbc43..4ae32a34 100644 --- a/chrome/renderer/renderer_webkitclient_impl.cc +++ b/chrome/renderer/renderer_webkitclient_impl.cc @@ -7,6 +7,7 @@ #include "base/command_line.h" #include "base/file_path.h" #include "base/platform_file.h" +#include "chrome/common/appcache/appcache_dispatcher.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/db_message_filter.h" #include "chrome/common/render_messages.h" @@ -18,6 +19,7 @@ #include "chrome/renderer/visitedlink_slave.h" #include "webkit/api/public/WebString.h" #include "webkit/api/public/WebURL.h" +#include "webkit/appcache/web_application_cache_host_impl.h" #include "webkit/glue/glue_util.h" #include "webkit/glue/webkit_glue.h" @@ -25,6 +27,8 @@ #include "chrome/renderer/renderer_sandbox_support_linux.h" #endif +using WebKit::WebApplicationCacheHost; +using WebKit::WebApplicationCacheHostClient; using WebKit::WebStorageArea; using WebKit::WebStorageNamespace; using WebKit::WebString; @@ -137,6 +141,12 @@ WebStorageNamespace* RendererWebKitClientImpl::createSessionStorageNamespace() { return new RendererWebStorageNamespaceImpl(false); } +WebApplicationCacheHost* RendererWebKitClientImpl::createApplicationCacheHost( + WebApplicationCacheHostClient* client) { + return new appcache::WebApplicationCacheHostImpl(client, + RenderThread::current()->appcache_dispatcher()->backend_proxy()); +} + //------------------------------------------------------------------------------ WebString RendererWebKitClientImpl::MimeRegistry::mimeTypeForExtension( diff --git a/chrome/renderer/renderer_webkitclient_impl.h b/chrome/renderer/renderer_webkitclient_impl.h index c9bd464..633f3cd 100644 --- a/chrome/renderer/renderer_webkitclient_impl.h +++ b/chrome/renderer/renderer_webkitclient_impl.h @@ -48,6 +48,8 @@ class RendererWebKitClientImpl : public webkit_glue::WebKitClientImpl { virtual bool databaseDeleteFile(const WebKit::WebString& file_name); virtual long databaseGetFileAttributes(const WebKit::WebString& file_name); virtual long long databaseGetFileSize(const WebKit::WebString& file_name); + virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost( + WebKit::WebApplicationCacheHostClient*); private: class MimeRegistry : public webkit_glue::SimpleWebMimeRegistryImpl { diff --git a/webkit/appcache/appcache_backend_impl.cc b/webkit/appcache/appcache_backend_impl.cc new file mode 100644 index 0000000..c59fc6d --- /dev/null +++ b/webkit/appcache/appcache_backend_impl.cc @@ -0,0 +1,63 @@ +// Copyright (c) 2006-2008 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 "webkit/appcache/appcache_backend_impl.h" + +#include "base/logging.h" +#include "webkit/appcache/web_application_cache_host_impl.h" + +namespace appcache { + +AppCacheBackendImpl::~AppCacheBackendImpl() { + // TODO(michaeln): if (service_) service_->UnregisterFrontend(frontend_); +} + +void AppCacheBackendImpl::Initialize(AppCacheService* service, + AppCacheFrontend* frontend) { + DCHECK(!service_ && !frontend_ && frontend); // DCHECK(service) + service_ = service; + frontend_ = frontend; + // TODO(michaeln): service_->RegisterFrontend(frontend_); +} + +void AppCacheBackendImpl::RegisterHost(int host_id) { + // TODO(michaeln): plumb to service +} + +void AppCacheBackendImpl::UnregisterHost(int host_id) { + // TODO(michaeln): plumb to service +} + +void AppCacheBackendImpl::SelectCache( + int host_id, + const GURL& document_url, + const int64 cache_document_was_loaded_from, + const GURL& manifest_url) { + // TODO(michaeln): plumb to service + frontend_->OnCacheSelected(host_id, kNoCacheId, UNCACHED); +} + +void AppCacheBackendImpl::MarkAsForeignEntry( + int host_id, + const GURL& document_url, + int64 cache_document_was_loaded_from) { + // TODO(michaeln): plumb to service +} + +Status AppCacheBackendImpl::GetStatus(int host_id) { + // TODO(michaeln): plumb to service + return UNCACHED; +} + +bool AppCacheBackendImpl::StartUpdate(int host_id) { + // TODO(michaeln): plumb to service + return false; +} + +bool AppCacheBackendImpl::SwapCache(int host_id) { + // TODO(michaeln): plumb to service + return false; +} + +} // namespace appcache
\ No newline at end of file diff --git a/webkit/appcache/appcache_backend_impl.h b/webkit/appcache/appcache_backend_impl.h new file mode 100644 index 0000000..93a7083 --- /dev/null +++ b/webkit/appcache/appcache_backend_impl.h @@ -0,0 +1,41 @@ +// Copyright (c) 2006-2008 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 WEBKIT_APPCACHE_APPCACHE_BACKEND_IMPL_H_ +#define WEBKIT_APPCACHE_APPCACHE_BACKEND_IMPL_H_ + +#include "webkit/appcache/appcache_interfaces.h" + +namespace appcache { + +class AppCacheService; + +class AppCacheBackendImpl : public AppCacheBackend { + public: + AppCacheBackendImpl() : service_(NULL), frontend_(NULL) {} + ~AppCacheBackendImpl(); + + void Initialize(AppCacheService* service, + AppCacheFrontend* frontend); + + virtual void RegisterHost(int host_id); + virtual void UnregisterHost(int host_id); + virtual void SelectCache(int host_id, + const GURL& document_url, + const int64 cache_document_was_loaded_from, + const GURL& manifest_url); + virtual void MarkAsForeignEntry(int host_id, const GURL& document_url, + int64 cache_document_was_loaded_from); + virtual Status GetStatus(int host_id); + virtual bool StartUpdate(int host_id); + virtual bool SwapCache(int host_id); + + private: + AppCacheService* service_; + AppCacheFrontend* frontend_; +}; + +} // namespace + +#endif // WEBKIT_APPCACHE_APPCACHE_BACKEND_IMPL_H_ diff --git a/webkit/appcache/appcache_frontend_impl.cc b/webkit/appcache/appcache_frontend_impl.cc new file mode 100644 index 0000000..a0ef05e --- /dev/null +++ b/webkit/appcache/appcache_frontend_impl.cc @@ -0,0 +1,42 @@ +// Copyright (c) 2006-2008 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 "webkit/appcache/appcache_frontend_impl.h" +#include "webkit/appcache/web_application_cache_host_impl.h" + +namespace appcache { + +// Inline helper to keep the lines shorter and unwrapped. +inline WebApplicationCacheHostImpl* GetHost(int id) { + return WebApplicationCacheHostImpl::FromId(id); +} + +void AppCacheFrontendImpl::OnCacheSelected(int host_id, int64 cache_id , + Status status) { + WebApplicationCacheHostImpl* host = GetHost(host_id); + if (host) + host->OnCacheSelected(cache_id, status); +} + +void AppCacheFrontendImpl::OnStatusChanged(const std::vector<int>& host_ids, + Status status) { + for (std::vector<int>::const_iterator i = host_ids.begin(); + i != host_ids.end(); ++i) { + WebApplicationCacheHostImpl* host = GetHost(*i); + if (host) + host->OnStatusChanged(status); + } +} + +void AppCacheFrontendImpl::OnEventRaised(const std::vector<int>& host_ids, + EventID event_id) { + for (std::vector<int>::const_iterator i = host_ids.begin(); + i != host_ids.end(); ++i) { + WebApplicationCacheHostImpl* host = GetHost(*i); + if (host) + host->OnEventRaised(event_id); + } +} + +} // namespace appcache diff --git a/webkit/appcache/appcache_frontend_impl.h b/webkit/appcache/appcache_frontend_impl.h new file mode 100644 index 0000000..e4ed922 --- /dev/null +++ b/webkit/appcache/appcache_frontend_impl.h @@ -0,0 +1,25 @@ +// Copyright (c) 2006-2008 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 WEBKIT_APPCACHE_APPCACHE_FRONTEND_IMPL_H_ +#define WEBKIT_APPCACHE_APPCACHE_FRONTEND_IMPL_H_ + +#include <vector> +#include "webkit/appcache/appcache_interfaces.h" + +namespace appcache { + +class AppCacheFrontendImpl : public AppCacheFrontend { + public: + virtual void OnCacheSelected(int host_id, int64 cache_id , + Status status); + virtual void OnStatusChanged(const std::vector<int>& host_ids, + Status status); + virtual void OnEventRaised(const std::vector<int>& host_ids, + EventID event_id); +}; + +} // namespace + +#endif // WEBKIT_APPCACHE_APPCACHE_FRONTEND_IMPL_H_ diff --git a/webkit/appcache/appcache_interfaces.cc b/webkit/appcache/appcache_interfaces.cc new file mode 100644 index 0000000..bd73879 --- /dev/null +++ b/webkit/appcache/appcache_interfaces.cc @@ -0,0 +1,44 @@ +// Copyright (c) 2006-2008 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 "webkit/appcache/appcache_interfaces.h" +#include "webkit/api/public/WebApplicationCacheHost.h" + +using WebKit::WebApplicationCacheHost; + +namespace appcache { + +// Ensure that enum values never get out of sync with the +// ones declared for use within the WebKit api + +COMPILE_ASSERT((int)WebApplicationCacheHost::Uncached == + (int)UNCACHED, Uncached); +COMPILE_ASSERT((int)WebApplicationCacheHost::Idle == + (int)IDLE, Idle); +COMPILE_ASSERT((int)WebApplicationCacheHost::Checking == + (int)CHECKING, Checking); +COMPILE_ASSERT((int)WebApplicationCacheHost::Downloading == + (int)DOWNLOADING, Downloading); +COMPILE_ASSERT((int)WebApplicationCacheHost::UpdateReady == + (int)UPDATE_READY, UpdateReady); +COMPILE_ASSERT((int)WebApplicationCacheHost::Obsolete == + (int)OBSOLETE, Obsolete); +COMPILE_ASSERT((int)WebApplicationCacheHost::CheckingEvent == + (int)CHECKING_EVENT, CheckingEvent); +COMPILE_ASSERT((int)WebApplicationCacheHost::ErrorEvent == + (int)ERROR_EVENT, ErrorEvent); +COMPILE_ASSERT((int)WebApplicationCacheHost::NoUpdateEvent == + (int)NO_UPDATE_EVENT, NoUpdateEvent); +COMPILE_ASSERT((int)WebApplicationCacheHost::DownloadingEvent == + (int)DOWNLOADING_EVENT, DownloadingEvent); +COMPILE_ASSERT((int)WebApplicationCacheHost::ProgressEvent == + (int)PROGRESS_EVENT, ProgressEvent); +COMPILE_ASSERT((int)WebApplicationCacheHost::UpdateReadyEvent == + (int)UPDATE_READY_EVENT, UpdateReadyEvent); +COMPILE_ASSERT((int)WebApplicationCacheHost::CachedEvent == + (int)CACHED_EVENT, CachedEvent); +COMPILE_ASSERT((int)WebApplicationCacheHost::ObsoleteEvent == + (int)OBSOLETE_EVENT, ObsoleteEvent); + +} // namespace diff --git a/webkit/appcache/appcache_interfaces.h b/webkit/appcache/appcache_interfaces.h new file mode 100644 index 0000000..ee63633 --- /dev/null +++ b/webkit/appcache/appcache_interfaces.h @@ -0,0 +1,75 @@ +// Copyright (c) 2006-2008 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 WEBKIT_APPCACHE_APPCACHE_INTERFACES_H_ +#define WEBKIT_APPCACHE_APPCACHE_INTERFACES_H_ + +#include <vector> +#include "base/basictypes.h" + +class GURL; + +namespace appcache { + +// Defines constants, types, and abstract classes used in the main +// process and in child processes. + +static const int kNoHostId = 0; +static const int64 kNoCacheId = 0; +static const int64 kUnknownCacheId = -1; + +enum Status { + UNCACHED, + IDLE, + CHECKING, + DOWNLOADING, + UPDATE_READY, + OBSOLETE +}; + +enum EventID { + CHECKING_EVENT, + ERROR_EVENT, + NO_UPDATE_EVENT, + DOWNLOADING_EVENT, + PROGRESS_EVENT, + UPDATE_READY_EVENT, + CACHED_EVENT, + OBSOLETE_EVENT +}; + +// Interface used by backend to talk to frontend. +class AppCacheFrontend { + public: + virtual void OnCacheSelected(int host_id, int64 cache_id , + Status status) = 0; + virtual void OnStatusChanged(const std::vector<int>& host_ids, + Status status) = 0; + virtual void OnEventRaised(const std::vector<int>& host_ids, + EventID event_id) = 0; + + virtual ~AppCacheFrontend() {} +}; + +// Interface used by frontend to talk to backend. +class AppCacheBackend { + public: + virtual void RegisterHost(int host_id) = 0; + virtual void UnregisterHost(int host_id) = 0; + virtual void SelectCache(int host_id, + const GURL& document_url, + const int64 cache_document_was_loaded_from, + const GURL& manifest_url) = 0; + virtual void MarkAsForeignEntry(int host_id, const GURL& document_url, + int64 cache_document_was_loaded_from) = 0; + virtual Status GetStatus(int host_id) = 0; + virtual bool StartUpdate(int host_id) = 0; + virtual bool SwapCache(int host_id) = 0; + + virtual ~AppCacheBackend() {} +}; + +} // namespace + +#endif // WEBKIT_APPCACHE_APPCACHE_INTERFACES_H_ diff --git a/webkit/appcache/web_application_cache_host_impl.cc b/webkit/appcache/web_application_cache_host_impl.cc new file mode 100644 index 0000000..02a698f --- /dev/null +++ b/webkit/appcache/web_application_cache_host_impl.cc @@ -0,0 +1,172 @@ +// Copyright (c) 2006-2008 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 "webkit/appcache/web_application_cache_host_impl.h" + +#include "base/compiler_specific.h" +#include "base/id_map.h" +#include "webkit/api/public/WebURL.h" +#include "webkit/api/public/WebURLRequest.h" +#include "webkit/api/public/WebURLResponse.h" + +using WebKit::WebApplicationCacheHost; +using WebKit::WebApplicationCacheHostClient; +using WebKit::WebURLRequest; +using WebKit::WebURL; +using WebKit::WebURLResponse; + +namespace appcache { + +static IDMap<WebApplicationCacheHostImpl> all_hosts; + +WebApplicationCacheHostImpl* WebApplicationCacheHostImpl::FromId(int id) { + return all_hosts.Lookup(id); +} + +WebApplicationCacheHostImpl::WebApplicationCacheHostImpl( + WebApplicationCacheHostClient* client, + AppCacheBackend* backend) + : client_(client), + backend_(backend), + ALLOW_THIS_IN_INITIALIZER_LIST(host_id_(all_hosts.Add(this))), + has_status_(false), + status_(UNCACHED), + has_cached_status_(false), + cached_status_(UNCACHED), + is_in_http_family_(false), + should_capture_main_response_(MAYBE) { + DCHECK(client && backend && (host_id_ != kNoHostId)); + + backend_->RegisterHost(host_id_); +} + +WebApplicationCacheHostImpl::~WebApplicationCacheHostImpl() { + backend_->UnregisterHost(host_id_); +} + +void WebApplicationCacheHostImpl::OnCacheSelected(int64 selected_cache_id, + appcache::Status status) { + status_ = status; + has_status_ = true; +} + +void WebApplicationCacheHostImpl::OnStatusChanged(appcache::Status status) { + if (has_status_) + status_ = status; +} + +void WebApplicationCacheHostImpl::OnEventRaised(appcache::EventID event_id) { + client_->notifyEventListener(static_cast<EventID>(event_id)); +} + +void WebApplicationCacheHostImpl::willStartMainResourceRequest( + WebURLRequest& request) { + request.setAppCacheContextID(host_id_); +} + +void WebApplicationCacheHostImpl::willStartSubResourceRequest( + WebURLRequest& request) { + request.setAppCacheContextID(host_id_); +} + +void WebApplicationCacheHostImpl::selectCacheWithoutManifest() { + // Reset any previous status values we've received from the backend + // since we're now selecting a new cache. + has_status_ = false; + has_cached_status_ = false; + should_capture_main_response_ = NO; + backend_->SelectCache(host_id_, main_response_url_, + main_response_.appCacheID(), + GURL()); +} + +bool WebApplicationCacheHostImpl::selectCacheWithManifest( + const WebURL& manifest_url) { + // Reset any previous status values we've received from the backend + // since we're now selecting a new cache. + has_status_ = false; + has_cached_status_ = false; + + // Check for new 'master' entries. + if (main_response_.appCacheID() == kNoCacheId) { + should_capture_main_response_ = is_in_http_family_ ? YES : NO; + backend_->SelectCache(host_id_, main_response_url_, + kNoCacheId, manifest_url); + return true; + } + + // Check for 'foreign' entries. + // TODO(michaeln): add manifestUrl() accessor to WebURLResponse, + // for now we don't really detect 'foreign' entries. + // TODO(michaeln): put an == operator on WebURL? + GURL manifest_gurl(manifest_url); + GURL main_response_manifest_gurl(manifest_url); // = mainResp.manifestUrl() + if (main_response_manifest_gurl != manifest_gurl) { + backend_->MarkAsForeignEntry(host_id_, main_response_url_, + main_response_.appCacheID()); + selectCacheWithoutManifest(); + return false; // the navigation will be restarted + } + + // Its a 'master' entry thats already in the cache. + backend_->SelectCache(host_id_, main_response_url_, + main_response_.appCacheID(), + manifest_gurl); + return true; +} + +void WebApplicationCacheHostImpl::didReceiveResponseForMainResource( + const WebURLResponse& response) { + main_response_ = response; + main_response_url_ = main_response_.url(); + is_in_http_family_ = main_response_url_.SchemeIs("http") || + main_response_url_.SchemeIs("https"); + if ((main_response_.appCacheID() != kNoCacheId) || !is_in_http_family_) + should_capture_main_response_ = NO; +} + +void WebApplicationCacheHostImpl::didReceiveDataForMainResource( + const char* data, int len) { + // TODO(michaeln): write me +} + +void WebApplicationCacheHostImpl::didFinishLoadingMainResource(bool success) { + // TODO(michaeln): write me +} + +WebApplicationCacheHost::Status WebApplicationCacheHostImpl::status() { + // We're careful about the status value to avoid race conditions. + // + // Generally the webappcachehost sends an async stream of messages to the + // backend, and receives an asyncronous stream of events from the backend. + // In the backend, all operations are serialized and as state changes + // 'events' are streamed out to relevant parties. In particular the + // 'SelectCache' message is async. Regular page loading and navigation + // involves two non-blocking ipc calls: RegisterHost + SelectCache. + // + // However, the page can call the scriptable API in advance of a cache + // selection being complete (and/or in advance of the webappcachehost having + // received the event about completion). In that case, we force an end-to-end + // fetch of the 'status' value, and cache that value seperately from the + // value we receive via the async event stream. We'll use that cached value + // until cache selection is complete. + if (has_status_) + return static_cast<WebApplicationCacheHost::Status>(status_); + + if (!has_cached_status_) { + cached_status_ = backend_->GetStatus(host_id_); + has_cached_status_ = true; + } + return static_cast<WebApplicationCacheHost::Status>(cached_status_); +} + +bool WebApplicationCacheHostImpl::startUpdate() { + return backend_->StartUpdate(host_id_); +} + +bool WebApplicationCacheHostImpl::swapCache() { + return backend_->SwapCache(host_id_); +} + +} // appcache namespace diff --git a/webkit/appcache/web_application_cache_host_impl.h b/webkit/appcache/web_application_cache_host_impl.h new file mode 100644 index 0000000..dbc00f1 --- /dev/null +++ b/webkit/appcache/web_application_cache_host_impl.h @@ -0,0 +1,64 @@ +// Copyright (c) 2006-2008 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 WEBKIT_APPCACHE_WEB_APPLICATION_CACHE_HOST_IMPL_H_ +#define WEBKIT_APPCACHE_WEB_APPLICATION_CACHE_HOST_IMPL_H_ + +#include "googleurl/src/gurl.h" +#include "webkit/api/public/WebApplicationCacheHostClient.h" +#include "webkit/api/public/WebURLResponse.h" +#include "webkit/appcache/appcache_interfaces.h" + +namespace appcache { + +class WebApplicationCacheHostImpl : public WebKit::WebApplicationCacheHost { + public: + // Returns the host having given id or NULL if there is no such host. + static WebApplicationCacheHostImpl* FromId(int id); + + WebApplicationCacheHostImpl(WebKit::WebApplicationCacheHostClient* client, + AppCacheBackend* backend); + virtual ~WebApplicationCacheHostImpl(); + + int host_id() const { return host_id_; } + + void OnCacheSelected(int64 selected_cache_id, appcache::Status status); + void OnStatusChanged(appcache::Status); + void OnEventRaised(appcache::EventID); + + // WebApplicationCacheHost methods + virtual void willStartMainResourceRequest(WebKit::WebURLRequest&); + virtual void willStartSubResourceRequest(WebKit::WebURLRequest&); + virtual void selectCacheWithoutManifest(); + virtual bool selectCacheWithManifest(const WebKit::WebURL& manifestURL); + virtual void didReceiveResponseForMainResource(const WebKit::WebURLResponse&); + virtual void didReceiveDataForMainResource(const char* data, int len); + virtual void didFinishLoadingMainResource(bool success); + virtual WebKit::WebApplicationCacheHost::Status status(); + virtual bool startUpdate(); + virtual bool swapCache(); + + private: + enum ShouldCaptureMainResponse { + MAYBE, + YES, + NO + }; + + WebKit::WebApplicationCacheHostClient* client_; + AppCacheBackend* backend_; + int host_id_; + bool has_status_; + appcache::Status status_; + bool has_cached_status_; + appcache::Status cached_status_; + WebKit::WebURLResponse main_response_; + GURL main_response_url_; + bool is_in_http_family_; + ShouldCaptureMainResponse should_capture_main_response_; +}; + +} // namespace + +#endif // WEBKIT_APPCACHE_WEB_APPLICATION_CACHE_HOST_IMPL_H_ diff --git a/webkit/glue/media/buffered_data_source.cc b/webkit/glue/media/buffered_data_source.cc index 5f739ba..5b6ef7e 100644 --- a/webkit/glue/media/buffered_data_source.cc +++ b/webkit/glue/media/buffered_data_source.cc @@ -13,7 +13,6 @@ #include "net/base/net_errors.h" #include "net/http/http_response_headers.h" #include "webkit/glue/media/buffered_data_source.h" -#include "webkit/glue/webappcachecontext.h" namespace { diff --git a/webkit/glue/media/media_resource_loader_bridge_factory.cc b/webkit/glue/media/media_resource_loader_bridge_factory.cc index 6e239a4..03684c8 100644 --- a/webkit/glue/media/media_resource_loader_bridge_factory.cc +++ b/webkit/glue/media/media_resource_loader_bridge_factory.cc @@ -19,13 +19,13 @@ MediaResourceLoaderBridgeFactory::MediaResourceLoaderBridgeFactory( const std::string& frame_origin, const std::string& main_frame_origin, int origin_pid, - int app_cache_context_id, + int appcache_host_id, int32 routing_id) : referrer_(referrer), frame_origin_(frame_origin), main_frame_origin_(main_frame_origin), origin_pid_(origin_pid), - app_cache_context_id_(app_cache_context_id), + appcache_host_id_(appcache_host_id), routing_id_(routing_id) { } @@ -45,7 +45,7 @@ ResourceLoaderBridge* MediaResourceLoaderBridgeFactory::CreateBridge( load_flags, origin_pid_, ResourceType::MEDIA, - app_cache_context_id_, + appcache_host_id_, routing_id_); } diff --git a/webkit/glue/media/media_resource_loader_bridge_factory.h b/webkit/glue/media/media_resource_loader_bridge_factory.h index 453f655..6408949 100644 --- a/webkit/glue/media/media_resource_loader_bridge_factory.h +++ b/webkit/glue/media/media_resource_loader_bridge_factory.h @@ -21,7 +21,7 @@ class MediaResourceLoaderBridgeFactory { const std::string& frame_origin, const std::string& main_frame_origin, int origin_pid, - int app_cache_context_id, + int appcache_host_id, int32 routing_id); virtual ~MediaResourceLoaderBridgeFactory() {} @@ -67,7 +67,7 @@ class MediaResourceLoaderBridgeFactory { std::string main_frame_origin_; std::string headers_; int origin_pid_; - int app_cache_context_id_; + int appcache_host_id_; int32 routing_id_; }; diff --git a/webkit/glue/media/simple_data_source.cc b/webkit/glue/media/simple_data_source.cc index 639aa5f..fd3be2f 100644 --- a/webkit/glue/media/simple_data_source.cc +++ b/webkit/glue/media/simple_data_source.cc @@ -10,7 +10,6 @@ #include "net/url_request/url_request_status.h" #include "webkit/glue/media/simple_data_source.h" #include "webkit/glue/resource_loader_bridge.h" -#include "webkit/glue/webappcachecontext.h" namespace { diff --git a/webkit/glue/resource_loader_bridge.cc b/webkit/glue/resource_loader_bridge.cc index 2d26f2a..fd8eee3 100644 --- a/webkit/glue/resource_loader_bridge.cc +++ b/webkit/glue/resource_loader_bridge.cc @@ -3,15 +3,15 @@ // found in the LICENSE file. #include "webkit/glue/resource_loader_bridge.h" -#include "webkit/glue/webappcachecontext.h" +#include "webkit/appcache/appcache_interfaces.h" #include "net/http/http_response_headers.h" namespace webkit_glue { ResourceLoaderBridge::ResponseInfo::ResponseInfo() { content_length = -1; - app_cache_id = WebAppCacheContext::kNoAppCacheId; + appcache_id = appcache::kNoCacheId; } ResourceLoaderBridge::ResponseInfo::~ResponseInfo() { diff --git a/webkit/glue/resource_loader_bridge.h b/webkit/glue/resource_loader_bridge.h index 07245fd..302a1be 100644 --- a/webkit/glue/resource_loader_bridge.h +++ b/webkit/glue/resource_loader_bridge.h @@ -67,8 +67,12 @@ class ResourceLoaderBridge { // Content length if available. -1 if not available int64 content_length; - // The appcache this response was loaded from, or kNoAppCacheId. - int64 app_cache_id; + // The appcache this response was loaded from, or kNoCacheId. + int64 appcache_id; + + // The manifest url of the appcache this response was loaded from. + // Note: this value is only populated for main resource requests. + GURL appcache_manifest_url; }; // See the SyncLoad method declared below. (The name of this struct is not @@ -157,7 +161,7 @@ class ResourceLoaderBridge { // request_type indicates if the current request is the main frame load, a // sub-frame load, or a sub objects load. // - // app_cache_context_id identifies that app cache context this request is + // appcache_host_id identifies that appcache host this request is // associated with. // // routing_id passed to this function allows it to be associated with a @@ -172,7 +176,7 @@ class ResourceLoaderBridge { int load_flags, int requestor_pid, ResourceType::Type request_type, - int app_cache_context_id, + int appcache_host_id, int routing_id); // Call this method before calling Start() to append a chunk of binary data diff --git a/webkit/glue/unittest_test_server.h b/webkit/glue/unittest_test_server.h index 583abf9..1033b1c 100644 --- a/webkit/glue/unittest_test_server.h +++ b/webkit/glue/unittest_test_server.h @@ -5,8 +5,8 @@ #ifndef WEBKIT_GLUE_UNITTEST_TEST_SERVER_H__ #define WEBKIT_GLUE_UNITTEST_TEST_SERVER_H__ +#include "webkit/appcache/appcache_interfaces.h" #include "webkit/glue/resource_loader_bridge.h" -#include "webkit/glue/webappcachecontext.h" #include "net/base/load_flags.h" #include "net/url_request/url_request_unittest.h" @@ -49,7 +49,7 @@ class UnittestTestServer : public HTTPTestServer { net::LOAD_NORMAL, 0, ResourceType::SUB_RESOURCE, - WebAppCacheContext::kNoAppCacheContextId, + appcache::kNoHostId, 0)); EXPECT_TRUE(loader.get()); diff --git a/webkit/glue/webappcachecontext.cc b/webkit/glue/webappcachecontext.cc deleted file mode 100644 index 6092a26..0000000 --- a/webkit/glue/webappcachecontext.cc +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2009 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 "webkit/glue/webappcachecontext.h" - -namespace { - -WebAppCacheContext::WebAppCacheFactoryProc factory_proc = NULL; - -class NoopWebAppCacheContext : public WebAppCacheContext { - public: - virtual int GetContextID() { return kNoAppCacheContextId; } - virtual int64 GetAppCacheID() { return kNoAppCacheId; } - virtual void Initialize(ContextType context_type, - WebAppCacheContext* opt_parent) {} - virtual void SelectAppCacheWithoutManifest( - const GURL& document_url, - int64 cache_document_was_loaded_from) {} - virtual void SelectAppCacheWithManifest( - const GURL& document_url, - int64 cache_document_was_loaded_from, - const GURL& manifest_url) {} - -}; - -} // namespace - -const int WebAppCacheContext::kNoAppCacheContextId = 0; -const int64 WebAppCacheContext::kNoAppCacheId = 0; -const int64 WebAppCacheContext::kUnknownAppCacheId = -1; - -WebAppCacheContext* WebAppCacheContext::Create() { - if (factory_proc) - return factory_proc(); - return new NoopWebAppCacheContext(); -} - -void WebAppCacheContext::SetFactory(WebAppCacheFactoryProc proc) { - factory_proc = proc; -} diff --git a/webkit/glue/webappcachecontext.h b/webkit/glue/webappcachecontext.h deleted file mode 100644 index 5d2fc53..0000000 --- a/webkit/glue/webappcachecontext.h +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (c) 2009 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 WEBKIT_GLUE_WEBAPPCACHECONTEXT_H_ -#define WEBKIT_GLUE_WEBAPPCACHECONTEXT_H_ - -#include "base/basictypes.h" - -class GURL; - -// This class is used in child processes, renderers and workers. -// -// An AppCacheContext corresponds with what html5 refers to as a -// "browsing context". Conceptually, each frame or worker represents -// a unique context. This class is used in child processes (renderers -// and workers) to inform the browser process of new frames and workers, and -// to keep track of which appcache is selected for each context. Resource -// requests contain the context id so the browser process can identify -// which context a request came from. As new documents are committed into a -// frame, the cache selection algorithm is initiated by calling one of the -// SelectAppCache methods. -// -// Each WebAppCacheContext is assigned a unique id within its child process. -// These ids are made globally unique by pairing them with a child process -// id within the browser process. -// -// WebFrameImpl has a scoped ptr to one of these as a data member. -// TODO(michaeln): integrate with WebWorkers -class WebAppCacheContext { - public: - enum ContextType { - MAIN_FRAME = 0, - CHILD_FRAME, - DEDICATED_WORKER - }; - - static const int kNoAppCacheContextId; // = 0; - static const int64 kNoAppCacheId; // = 0; - static const int64 kUnknownAppCacheId; // = -1; - - // Factory method called internally by webkit_glue to create a concrete - // instance of this class. If SetFactory has been called, the factory - // function provided there is used to create a new instance, otherwise - // a noop implementation is returned. - static WebAppCacheContext* Create(); - - typedef WebAppCacheContext* (*WebAppCacheFactoryProc)(void); - static void SetFactory(WebAppCacheFactoryProc factory_proc); - - // Unique id within the child process housing this context - virtual int GetContextID() = 0; - - // Which appcache is associated with the context. There are windows of - // time where the appcache is not yet known, the return value is - // kUnknownAppCacheId in that case. - virtual int64 GetAppCacheID() = 0; - - // The following methods result in async messages being sent to the - // browser process. The initialize method tells the browser process about - // the existance of this context, its type and its id. The select methods - // tell the browser process to initiate the cache selection algorithm for - // the context. - virtual void Initialize(ContextType context_type, - WebAppCacheContext* opt_parent) = 0; - virtual void SelectAppCacheWithoutManifest( - const GURL& document_url, - int64 cache_document_was_loaded_from) = 0; - virtual void SelectAppCacheWithManifest( - const GURL& document_url, - int64 cache_document_was_loaded_from, - const GURL& manifest_url) = 0; - - virtual ~WebAppCacheContext() {} -}; - -#endif // WEBKIT_GLUE_WEBAPPCACHECONTEXT_H_ diff --git a/webkit/glue/weburlloader_impl.cc b/webkit/glue/weburlloader_impl.cc index 706e957..fd1f34e 100644 --- a/webkit/glue/weburlloader_impl.cc +++ b/webkit/glue/weburlloader_impl.cc @@ -150,7 +150,9 @@ void PopulateURLResponse( response->setTextEncodingName(StdStringToWebString(info.charset)); response->setExpectedContentLength(info.content_length); response->setSecurityInfo(info.security_info); - response->setAppCacheID(info.app_cache_id); + response->setAppCacheID(info.appcache_id); + // TODO(michaeln): + // response->setAppCacheManifestUrl(info.appcache_manifest_url); const net::HttpResponseHeaders* headers = info.headers; if (!headers) diff --git a/webkit/tools/test_shell/simple_appcache_system.h b/webkit/tools/test_shell/simple_appcache_system.h new file mode 100644 index 0000000..6f53524 --- /dev/null +++ b/webkit/tools/test_shell/simple_appcache_system.h @@ -0,0 +1,25 @@ +// Copyright (c) 2009 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 WEBKIT_TOOLS_TEST_SHELL_SIMPLE_APPCACHE_SYSTEM_H_ +#define WEBKIT_TOOLS_TEST_SHELL_SIMPLE_APPCACHE_SYSTEM_H_ + +#include "webkit/appcache/appcache_backend_impl.h" +#include "webkit/appcache/appcache_frontend_impl.h" + +class SimpleAppCacheSystem { + public: + void Initialize() { + backend_impl_.Initialize(NULL, &frontend_impl_); + } + + appcache::AppCacheBackend* backend() { return &backend_impl_; } + appcache::AppCacheFrontend* frontend() { return &frontend_impl_; } + + private: + appcache::AppCacheBackendImpl backend_impl_; + appcache::AppCacheFrontendImpl frontend_impl_; +}; + +#endif // WEBKIT_TOOLS_TEST_SHELL_SIMPLE_APPCACHE_SYSTEM_H_ diff --git a/webkit/tools/test_shell/simple_resource_loader_bridge.cc b/webkit/tools/test_shell/simple_resource_loader_bridge.cc index e1137f8..c27f061 100644 --- a/webkit/tools/test_shell/simple_resource_loader_bridge.cc +++ b/webkit/tools/test_shell/simple_resource_loader_bridge.cc @@ -46,8 +46,8 @@ #include "net/http/http_response_headers.h" #include "net/proxy/proxy_service.h" #include "net/url_request/url_request.h" +#include "webkit/appcache/appcache_interfaces.h" #include "webkit/glue/resource_loader_bridge.h" -#include "webkit/glue/webappcachecontext.h" #include "webkit/tools/test_shell/test_shell_request_context.h" using webkit_glue::ResourceLoaderBridge; @@ -101,7 +101,7 @@ struct RequestParams { GURL referrer; std::string headers; int load_flags; - int app_cache_context_id; + int appcache_host_id; scoped_refptr<net::UploadData> upload; }; @@ -376,7 +376,8 @@ class RequestProxy : public URLRequest::Delegate, info->request_time = request->request_time(); info->response_time = request->response_time(); info->headers = request->response_headers(); - info->app_cache_id = WebAppCacheContext::kNoAppCacheId; + info->appcache_id = appcache::kNoCacheId; + // TODO(michaeln): info->appcache_manifest_url = GURL(); request->GetMimeType(&info->mime_type); request->GetCharset(&info->charset); info->content_length = request->GetExpectedContentSize(); @@ -468,7 +469,7 @@ class ResourceLoaderBridgeImpl : public ResourceLoaderBridge { const GURL& referrer, const std::string& headers, int load_flags, - int app_cache_context_id) + int appcache_host_id) : params_(new RequestParams), proxy_(NULL) { params_->method = method; @@ -477,7 +478,7 @@ class ResourceLoaderBridgeImpl : public ResourceLoaderBridge { params_->referrer = referrer; params_->headers = headers; params_->load_flags = load_flags; - params_->app_cache_context_id = app_cache_context_id; + params_->appcache_host_id = appcache_host_id; } virtual ~ResourceLoaderBridgeImpl() { @@ -611,11 +612,11 @@ ResourceLoaderBridge* ResourceLoaderBridge::Create( int load_flags, int requestor_pid, ResourceType::Type request_type, - int app_cache_context_id, + int appcache_host_id, int routing_id) { return new ResourceLoaderBridgeImpl(method, url, first_party_for_cookies, referrer, headers, load_flags, - app_cache_context_id); + appcache_host_id); } // Issue the proxy resolve request on the io thread, and wait diff --git a/webkit/tools/test_shell/test_shell.gyp b/webkit/tools/test_shell/test_shell.gyp index eadd0b0..ef688dc 100644 --- a/webkit/tools/test_shell/test_shell.gyp +++ b/webkit/tools/test_shell/test_shell.gyp @@ -63,6 +63,7 @@ 'mock_webclipboard_impl.cc', 'mock_webclipboard_impl.h', 'resource.h', + 'simple_appcache_system.h', 'simple_clipboard_impl.cc', 'simple_resource_loader_bridge.cc', 'simple_resource_loader_bridge.h', diff --git a/webkit/tools/test_shell/test_shell_webkit_init.h b/webkit/tools/test_shell/test_shell_webkit_init.h index 9c758c7..2727d6b 100644 --- a/webkit/tools/test_shell/test_shell_webkit_init.h +++ b/webkit/tools/test_shell/test_shell_webkit_init.h @@ -16,6 +16,7 @@ #include "webkit/api/public/WebStorageNamespace.h" #include "webkit/api/public/WebString.h" #include "webkit/api/public/WebURL.h" +#include "webkit/appcache/web_application_cache_host_impl.h" #include "webkit/glue/simple_webmimeregistry_impl.h" #include "webkit/glue/webclipboard_impl.h" #include "webkit/glue/webkit_glue.h" @@ -23,6 +24,7 @@ #include "webkit/extensions/v8/gears_extension.h" #include "webkit/extensions/v8/interval_extension.h" #include "webkit/tools/test_shell/mock_webclipboard_impl.h" +#include "webkit/tools/test_shell/simple_appcache_system.h" #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" #include "v8/include/v8.h" @@ -40,6 +42,7 @@ class TestShellWebKitInit : public webkit_glue::WebKitClientImpl { WebKit::enableV8SingleThreadMode(); WebKit::registerExtension(extensions_v8::GearsExtension::Get()); WebKit::registerExtension(extensions_v8::IntervalExtension::Get()); + appcache_system_.Initialize(); // Load libraries for media and enable the media player. FilePath module_path; @@ -144,10 +147,17 @@ class TestShellWebKitInit : public webkit_glue::WebKitClientImpl { return WebKit::WebStorageNamespace::createSessionStorageNamespace(); } + virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost( + WebKit::WebApplicationCacheHostClient* client) { + return new appcache::WebApplicationCacheHostImpl( + client, appcache_system_.backend()); + } + private: webkit_glue::SimpleWebMimeRegistryImpl mime_registry_; MockWebClipboardImpl mock_clipboard_; webkit_glue::WebClipboardImpl real_clipboard_; + SimpleAppCacheSystem appcache_system_; }; #endif // WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_WEBKIT_INIT_H_ diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc index 279949a..74916a1 100644 --- a/webkit/tools/test_shell/test_webview_delegate.cc +++ b/webkit/tools/test_shell/test_webview_delegate.cc @@ -32,11 +32,11 @@ #include "webkit/api/public/WebURLError.h" #include "webkit/api/public/WebURLRequest.h" #include "webkit/api/public/WebURLResponse.h" +#include "webkit/appcache/appcache_interfaces.h" #include "webkit/glue/glue_serialize.h" #include "webkit/glue/media/buffered_data_source.h" #include "webkit/glue/media/media_resource_loader_bridge_factory.h" #include "webkit/glue/media/simple_data_source.h" -#include "webkit/glue/webappcachecontext.h" #include "webkit/glue/webdropdata.h" #include "webkit/glue/webpreferences.h" #include "webkit/glue/webkit_glue.h" @@ -197,7 +197,7 @@ WebKit::WebMediaPlayer* TestWebViewDelegate::CreateWebMediaPlayer( "null", // frame origin "null", // main_frame_origin base::GetCurrentProcId(), - WebAppCacheContext::kNoAppCacheContextId, + appcache::kNoHostId, 0); factory->AddFactory(webkit_glue::BufferedDataSource::CreateFactory( MessageLoop::current(), bridge_factory)); diff --git a/webkit/tools/test_shell/test_worker/test_worker_main.cc b/webkit/tools/test_shell/test_worker/test_worker_main.cc index aefbccb..02eaf32 100644 --- a/webkit/tools/test_shell/test_worker/test_worker_main.cc +++ b/webkit/tools/test_shell/test_worker/test_worker_main.cc @@ -157,7 +157,7 @@ ResourceLoaderBridge* ResourceLoaderBridge::Create( int load_flags, int requestor_pid, ResourceType::Type request_type, - int app_cache_context_id, + int appcache_host_id, int routing_id) { return NULL; } diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp index 3204dcc..c228e47 100644 --- a/webkit/webkit.gyp +++ b/webkit/webkit.gyp @@ -1232,11 +1232,20 @@ 'msvs_guid': '0B945915-31A7-4A07-A5B5-568D737A39B1', 'dependencies': [ '../build/temp_gyp/googleurl.gyp:googleurl', + 'webkit', ], 'sources': [ # This list contains all .h and .cc in appcache except for test code. + 'appcache/appcache_backend_impl.cc', + 'appcache/appcache_backend_impl.h', + 'appcache/appcache_frontend_impl.cc', + 'appcache/appcache_frontend_impl.h', + 'appcache/appcache_interfaces.cc', + 'appcache/appcache_interfaces.h', 'appcache/manifest_parser.cc', 'appcache/manifest_parser.h', + 'appcache/web_application_cache_host_impl.cc', + 'appcache/web_application_cache_host_impl.h', ], }, { @@ -1399,8 +1408,6 @@ 'glue/webaccessibilitymanager.h', 'glue/webaccessibilitymanager_impl.cc', 'glue/webaccessibilitymanager_impl.h', - 'glue/webappcachecontext.cc', - 'glue/webappcachecontext.h', 'glue/webclipboard_impl.cc', 'glue/webclipboard_impl.h', 'glue/webcursor.cc', |