diff options
author | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-07 17:45:54 +0000 |
---|---|---|
committer | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-07 17:45:54 +0000 |
commit | 1edc16b82bd98eb06188a94e62c668d439035e6e (patch) | |
tree | 3edaea7ad20c2981febbc5e081bb2d499d97e671 /chrome | |
parent | 7d769c36ccaf6663c49e3c89d959a47b9449f68a (diff) | |
download | chromium_src-1edc16b82bd98eb06188a94e62c668d439035e6e.zip chromium_src-1edc16b82bd98eb06188a94e62c668d439035e6e.tar.gz chromium_src-1edc16b82bd98eb06188a94e62c668d439035e6e.tar.bz2 |
Adds new messages and widens some existing messages between the renderer and browser processes to support an implementation of the HTML5AppCache spec with most of the logic running in the browser process. The gist of most of the changes are to indicate which frame each resource request is coming from, and to indicate which appcache each response was retrieved from (if any).See https://docs.google.com/a/google.com/Doc?docid=agv6ghfsqr_15f749cgt3&hl=en
Review URL: http://codereview.chromium.org/9712
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13258 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
23 files changed, 462 insertions, 7 deletions
diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.cc b/chrome/browser/renderer_host/resource_dispatcher_host.cc index 1a73ca5..2cb0431 100644 --- a/chrome/browser/renderer_host/resource_dispatcher_host.cc +++ b/chrome/browser/renderer_host/resource_dispatcher_host.cc @@ -42,6 +42,7 @@ #include "net/base/mime_util.h" #include "net/base/net_errors.h" #include "net/url_request/url_request.h" +#include "webkit/glue/webappcachecontext.h" // TODO(port): Move these includes to the above section when porting is done. #if defined(OS_POSIX) @@ -909,6 +910,7 @@ bool ResourceDispatcherHost::CompleteResponseStarted(URLRequest* request) { request->GetCharset(&response->response_head.charset); response->response_head.filter_policy = info->filter_policy; response->response_head.content_length = request->GetExpectedContentSize(); + response->response_head.app_cache_id = WebAppCacheContext::kNoAppCacheId; request->GetMimeType(&response->response_head.mime_type); // Make sure we don't get a file handle if LOAD_ENABLE_FILE is not set. diff --git a/chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc b/chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc index bfd2d2c..1e2b458 100644 --- a/chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc +++ b/chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc @@ -15,6 +15,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" static int RequestIDForMessage(const IPC::Message& msg) { int request_id = -1; @@ -43,6 +44,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; return request; } diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc index 549fc6a..1bffc6a 100644 --- a/chrome/browser/renderer_host/resource_message_filter.cc +++ b/chrome/browser/renderer_host/resource_message_filter.cc @@ -20,6 +20,7 @@ #include "chrome/browser/renderer_host/render_widget_helper.h" #include "chrome/browser/spellchecker.h" #include "chrome/browser/worker_host/worker_service.h" +#include "chrome/common/app_cache/app_cache_dispatcher_host.h" #include "chrome/common/chrome_plugin_lib.h" #include "chrome/common/chrome_plugin_util.h" #include "chrome/common/clipboard_service.h" @@ -128,6 +129,7 @@ ResourceMessageFilter::ResourceMessageFilter( profile_(profile), render_widget_helper_(render_widget_helper), audio_renderer_host_(audio_renderer_host), + app_cache_dispatcher_host_(new AppCacheDispatcherHost), off_the_record_(profile->IsOffTheRecord()) { DCHECK(request_context_.get()); DCHECK(request_context_->cookie_store()); @@ -155,7 +157,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); ExtensionMessageService::GetInstance()->RendererReady(this); } @@ -199,7 +201,9 @@ void ResourceMessageFilter::OnChannelClosing() { bool ResourceMessageFilter::OnMessageReceived(const IPC::Message& message) { bool msg_is_ok = true; bool handled = resource_dispatcher_host_->OnMessageReceived( - message, this, &msg_is_ok); + message, this, &msg_is_ok) || + app_cache_dispatcher_host_->OnMessageReceived( + message, &msg_is_ok); if (!handled) { handled = true; IPC_BEGIN_MESSAGE_MAP_EX(ResourceMessageFilter, message, msg_is_ok) diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h index db7c60b..d801583 100644 --- a/chrome/browser/renderer_host/resource_message_filter.h +++ b/chrome/browser/renderer_host/resource_message_filter.h @@ -32,6 +32,7 @@ #include "chrome/common/temp_scaffolding_stubs.h" #endif +class AppCacheDispatcherHost; class AudioRendererHost; class ClipboardService; class Profile; @@ -269,6 +270,9 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter, // Object that should take care of audio related resource requests. scoped_refptr<AudioRendererHost> audio_renderer_host_; + // Handles appcache related messages + scoped_ptr<AppCacheDispatcherHost> app_cache_dispatcher_host_; + // Whether this process is used for off the record tabs. bool off_the_record_; diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index da52d1c..ad067fe 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -131,6 +131,12 @@ 'common/net/url_request_intercept_job.h', 'common/animation.cc', 'common/animation.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/bindings_policy.h', 'common/child_process.cc', 'common/child_process.h', diff --git a/chrome/common/app_cache/app_cache_context_impl.cc b/chrome/common/app_cache/app_cache_context_impl.cc new file mode 100644 index 0000000..d50b467 --- /dev/null +++ b/chrome/common/app_cache/app_cache_context_impl.cc @@ -0,0 +1,84 @@ +// 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->context_id() + : 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 new file mode 100644 index 0000000..7ca7ee3 --- /dev/null +++ b/chrome/common/app_cache/app_cache_context_impl.h @@ -0,0 +1,48 @@ +// 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 "chrome/common/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 context_id() { return context_id_; } + virtual int64 app_cache_id() { 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 new file mode 100644 index 0000000..ba81243 --- /dev/null +++ b/chrome/common/app_cache/app_cache_dispatcher.cc @@ -0,0 +1,26 @@ +// 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 new file mode 100644 index 0000000..c8baf28 --- /dev/null +++ b/chrome/common/app_cache/app_cache_dispatcher.h @@ -0,0 +1,26 @@ +// 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 "chrome/common/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 new file mode 100644 index 0000000..98c774d --- /dev/null +++ b/chrome/common/app_cache/app_cache_dispatcher_host.cc @@ -0,0 +1,60 @@ +// 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 new file mode 100644 index 0000000..e84a7fd --- /dev/null +++ b/chrome/common/app_cache/app_cache_dispatcher_host.h @@ -0,0 +1,43 @@ +// 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 "chrome/common/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/common.vcproj b/chrome/common/common.vcproj index 19dc26a..a5ec901 100644 --- a/chrome/common/common.vcproj +++ b/chrome/common/common.vcproj @@ -329,6 +329,34 @@ > </File> </Filter> + <Filter + Name="app_cache" + > + <File + RelativePath=".\app_cache\app_cache_context_impl.cc" + > + </File> + <File + RelativePath=".\app_cache\app_cache_context_impl.h" + > + </File> + <File + RelativePath=".\app_cache\app_cache_dispatcher.cc" + > + </File> + <File + RelativePath=".\app_cache\app_cache_dispatcher.h" + > + </File> + <File + RelativePath=".\app_cache\app_cache_dispatcher_host.cc" + > + </File> + <File + RelativePath=".\app_cache\app_cache_dispatcher_host.h" + > + </File> + </Filter> <File RelativePath=".\animation.cc" > diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index 0d5404a..32f8f57 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -33,6 +33,7 @@ #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/webplugin.h" #include "webkit/glue/webpreferences.h" @@ -275,6 +276,10 @@ struct ViewHostMsg_Resource_Request { // Used by plugin->browser requests to get the correct URLRequestContext. uint32 request_context; + // Indicates which frame (or worker context) the request is being loaded into, + // or kNoAppCacheContextId. + int32 app_cache_context_id; + // Optional upload data (may be null). scoped_refptr<net::UploadData> upload_data; }; @@ -1222,6 +1227,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.upload_data); } static bool Read(const Message* m, void** iter, param_type* r) { @@ -1238,6 +1244,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->upload_data); } static void Log(const param_type& p, std::wstring* l) { @@ -1261,6 +1268,8 @@ struct ParamTraits<ViewHostMsg_Resource_Request> { LogParam(p.resource_type, l); l->append(L", "); LogParam(p.request_context, l); + l->append(L", "); + LogParam(p.app_cache_context_id, l); l->append(L")"); } }; @@ -1352,6 +1361,7 @@ 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.response_data_file); } static bool Read(const Message* m, void** iter, param_type* r) { @@ -1363,6 +1373,7 @@ 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->response_data_file); } static void Log(const param_type& p, std::wstring* l) { @@ -1378,6 +1389,10 @@ struct ParamTraits<webkit_glue::ResourceLoaderBridge::ResponseInfo> { LogParam(p.charset, l); l->append(L", "); LogParam(p.security_info, l); + l->append(L", "); + LogParam(p.content_length, l); + l->append(L", "); + LogParam(p.app_cache_id, l); l->append(L")"); } }; @@ -1779,6 +1794,40 @@ struct ParamTraits<AudioOutputStream::State> { } }; +template <> +struct ParamTraits<WebAppCacheContext::ContextType> { + typedef WebAppCacheContext::ContextType 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 WebAppCacheContext::MAIN_FRAME: + state = L"MAIN_FRAME"; + break; + case WebAppCacheContext::CHILD_FRAME: + state = L"CHILD_FRAME"; + break; + case WebAppCacheContext::DEDICATED_WORKER: + state = L"DECICATED_WORKER"; + break; + default: + state = L"UNKNOWN"; + break; + } + + LogParam(state, l); + } +}; + } // namespace IPC diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index a39dca8..cec72e5 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -20,6 +20,7 @@ #include "chrome/common/transport_dib.h" #include "skia/include/SkBitmap.h" #include "webkit/glue/dom_operations.h" +#include "webkit/glue/webappcachecontext.h" #include "webkit/glue/webcursor.h" #include "webkit/glue/webplugin.h" @@ -484,6 +485,14 @@ 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 */) + // Reply to the ViewHostMsg_QueryFormFieldAutofill message with the autofill // suggestions. IPC_MESSAGE_ROUTED4(ViewMsg_AutofillSuggestions, @@ -1196,6 +1205,34 @@ 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 + // '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 */, + GURL /* document_url */, + int64 /* cache_document_was_loaded_from */, + GURL /* opt_manifest_url */) + // 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 c507510..c5712ea 100644 --- a/chrome/common/resource_dispatcher.cc +++ b/chrome/common/resource_dispatcher.cc @@ -56,6 +56,7 @@ class IPCResourceLoaderBridge : public ResourceLoaderBridge { int origin_pid, ResourceType::Type resource_type, uint32 request_context, + int app_cache_context_id, int route_id); virtual ~IPCResourceLoaderBridge(); @@ -110,6 +111,7 @@ IPCResourceLoaderBridge::IPCResourceLoaderBridge( int origin_pid, ResourceType::Type resource_type, uint32 request_context, + int app_cache_context_id, int route_id) : peer_(NULL), dispatcher_(dispatcher), @@ -128,6 +130,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; #ifdef LOG_RESOURCE_REQUESTS url_ = url.possibly_invalid_spec(); @@ -531,6 +534,7 @@ webkit_glue::ResourceLoaderBridge* ResourceDispatcher::CreateBridge( int origin_pid, ResourceType::Type resource_type, uint32 request_context, + int app_cache_context_id, int route_id) { return new webkit_glue::IPCResourceLoaderBridge(this, method, url, policy_url, referrer, frame_origin, @@ -538,7 +542,9 @@ webkit_glue::ResourceLoaderBridge* ResourceDispatcher::CreateBridge( default_mime_type, flags, origin_pid, resource_type, - request_context, route_id); + request_context, + app_cache_context_id, + route_id); } bool ResourceDispatcher::IsResourceDispatcherMessage( diff --git a/chrome/common/resource_dispatcher.h b/chrome/common/resource_dispatcher.h index 73d0a8b3..bc511e94 100644 --- a/chrome/common/resource_dispatcher.h +++ b/chrome/common/resource_dispatcher.h @@ -32,7 +32,7 @@ class ResourceDispatcher { // handled, else false. bool OnMessageReceived(const IPC::Message& message); - // creates a ResourceLoaderBridge for this type of dispatcher, this is so + // Creates a ResourceLoaderBridge for this type of dispatcher, this is so // this can be tested regardless of the ResourceLoaderBridge::Create // implementation. webkit_glue::ResourceLoaderBridge* CreateBridge(const std::string& method, @@ -47,6 +47,7 @@ class ResourceDispatcher { int origin_pid, ResourceType::Type resource_type, uint32 request_context /* used for plugin->browser requests */, + int app_cache_context_id, int route_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 00a5f4d..e079364 100644 --- a/chrome/common/resource_dispatcher_unittest.cc +++ b/chrome/common/resource_dispatcher_unittest.cc @@ -10,8 +10,8 @@ #include "chrome/common/filter_policy.h" #include "chrome/common/render_messages.h" #include "chrome/common/resource_dispatcher.h" - #include "testing/gtest/include/gtest/gtest.h" +#include "webkit/glue/webappcachecontext.h" using webkit_glue::ResourceLoaderBridge; @@ -157,6 +157,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, MSG_ROUTING_CONTROL); bridge->Start(&callback); diff --git a/chrome/plugin/chrome_plugin_host.cc b/chrome/plugin/chrome_plugin_host.cc index 0f0e240..c63ef76 100644 --- a/chrome/plugin/chrome_plugin_host.cc +++ b/chrome/plugin/chrome_plugin_host.cc @@ -22,6 +22,7 @@ #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 { @@ -153,6 +154,7 @@ class PluginRequestHandlerProxy GetCurrentProcessId(), ResourceType::OBJECT, cprequest_->context, + WebAppCacheContext::kNoAppCacheContextId, MSG_ROUTING_CONTROL)); if (!bridge_.get()) return CPERR_FAILURE; diff --git a/chrome/renderer/media/data_source_impl.cc b/chrome/renderer/media/data_source_impl.cc index 9ee3331..20aee22 100644 --- a/chrome/renderer/media/data_source_impl.cc +++ b/chrome/renderer/media/data_source_impl.cc @@ -13,6 +13,7 @@ #include "media/base/pipeline.h" #include "net/base/load_flags.h" #include "net/base/net_errors.h" +#include "webkit/glue/webappcachecontext.h" DataSourceImpl::DataSourceImpl(WebMediaPlayerDelegateImpl* delegate) : delegate_(delegate), @@ -215,6 +216,10 @@ void DataSourceImpl::OnInitialize(std::string uri) { base::GetCurrentProcId(), ResourceType::MEDIA, 0, + // TODO(michaeln): delegate->mediaplayer->frame-> + // app_cache_context()->context_id() + // For now don't service media resource requests from the appcache. + WebAppCacheContext::kNoAppCacheContextId, delegate_->view()->routing_id()); // Start the resource loading. resource_loader_bridge_->Start(this); diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc index 8eb1c21..330c754 100644 --- a/chrome/renderer/render_thread.cc +++ b/chrome/renderer/render_thread.cc @@ -10,6 +10,8 @@ #include "base/command_line.h" #include "base/shared_memory.h" #include "base/stats_table.h" +#include "chrome/common/app_cache/app_cache_context_impl.h" +#include "chrome/common/app_cache/app_cache_dispatcher.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/render_messages.h" #include "chrome/common/notification_service.h" @@ -91,8 +93,13 @@ void RenderThread::SendHistograms() { return histogram_snapshots_->SendHistograms(); } +static WebAppCacheContext* CreateAppCacheContextForRenderer() { + return new AppCacheContextImpl(RenderThread::current()); +} + void RenderThread::Init() { - // TODO(darin): Why do we need COM here? This is probably bogus. + // TODO(darin): Why do we need COM here? This is probably bogus. Perhaps + // this is for InProcessPlugin support? #if defined(OS_WIN) // The renderer thread should wind-up COM. CoInitialize(0); @@ -107,11 +114,15 @@ 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); } void RenderThread::CleanUp() { // Shutdown in reverse of the initialization order. + WebAppCacheContext::SetFactory(NULL); + app_cache_dispatcher_.reset(); histogram_snapshots_.reset(); dns_master_.reset(); user_script_slave_.reset(); @@ -154,6 +165,10 @@ void RenderThread::OnSetExtensionFunctionNames( } void RenderThread::OnControlMessageReceived(const IPC::Message& msg) { + // App cache messages are handled by a delegate. + if (app_cache_dispatcher_->OnMessageReceived(msg)) + return; + IPC_BEGIN_MESSAGE_MAP(RenderThread, msg) IPC_MESSAGE_HANDLER(ViewMsg_VisitedLink_NewTable, OnUpdateVisitedLinks) IPC_MESSAGE_HANDLER(ViewMsg_SetNextPageID, OnSetNextPageID) diff --git a/chrome/renderer/render_thread.h b/chrome/renderer/render_thread.h index 5340b0e..0d5da09 100644 --- a/chrome/renderer/render_thread.h +++ b/chrome/renderer/render_thread.h @@ -14,6 +14,7 @@ #include "chrome/common/child_thread.h" #include "chrome/renderer/renderer_histogram_snapshots.h" +class AppCacheDispatcher; class FilePath; class NotificationService; class RenderDnsMaster; @@ -148,6 +149,8 @@ class RenderThread : public RenderThreadBase, scoped_ptr<RendererWebKitClientImpl> webkit_client_; + scoped_ptr<AppCacheDispatcher> app_cache_dispatcher_; + DISALLOW_COPY_AND_ASSIGN(RenderThread); }; diff --git a/chrome/renderer/renderer_glue.cc b/chrome/renderer/renderer_glue.cc index 09f6676..c907c23 100644 --- a/chrome/renderer/renderer_glue.cc +++ b/chrome/renderer/renderer_glue.cc @@ -232,12 +232,14 @@ ResourceLoaderBridge* ResourceLoaderBridge::Create( int load_flags, int origin_pid, ResourceType::Type resource_type, + int app_cache_context_id, int routing_id) { ResourceDispatcher* dispatch = RenderThread::current()->resource_dispatcher(); return dispatch->CreateBridge(method, url, policy_url, referrer, frame_origin, main_frame_origin, headers, default_mime_type, load_flags, origin_pid, - resource_type, 0, routing_id); + resource_type, 0, + app_cache_context_id, routing_id); } void NotifyCacheStats() { diff --git a/chrome/test/worker/test_worker_main.cc b/chrome/test/worker/test_worker_main.cc index f1e7817..e14d9a4 100644 --- a/chrome/test/worker/test_worker_main.cc +++ b/chrome/test/worker/test_worker_main.cc @@ -57,6 +57,7 @@ ResourceLoaderBridge* ResourceLoaderBridge::Create( int load_flags, int requestor_pid, ResourceType::Type request_type, + int app_cache_context_id, int routing_id) { return NULL; } |