summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormichaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-07 17:45:54 +0000
committermichaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-07 17:45:54 +0000
commit1edc16b82bd98eb06188a94e62c668d439035e6e (patch)
tree3edaea7ad20c2981febbc5e081bb2d499d97e671
parent7d769c36ccaf6663c49e3c89d959a47b9449f68a (diff)
downloadchromium_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
-rw-r--r--chrome/browser/renderer_host/resource_dispatcher_host.cc2
-rw-r--r--chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc2
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.cc8
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.h4
-rw-r--r--chrome/chrome.gyp6
-rw-r--r--chrome/common/app_cache/app_cache_context_impl.cc84
-rw-r--r--chrome/common/app_cache/app_cache_context_impl.h48
-rw-r--r--chrome/common/app_cache/app_cache_dispatcher.cc26
-rw-r--r--chrome/common/app_cache/app_cache_dispatcher.h26
-rw-r--r--chrome/common/app_cache/app_cache_dispatcher_host.cc60
-rw-r--r--chrome/common/app_cache/app_cache_dispatcher_host.h43
-rw-r--r--chrome/common/common.vcproj28
-rw-r--r--chrome/common/render_messages.h49
-rw-r--r--chrome/common/render_messages_internal.h37
-rw-r--r--chrome/common/resource_dispatcher.cc8
-rw-r--r--chrome/common/resource_dispatcher.h3
-rw-r--r--chrome/common/resource_dispatcher_unittest.cc3
-rw-r--r--chrome/plugin/chrome_plugin_host.cc2
-rw-r--r--chrome/renderer/media/data_source_impl.cc5
-rw-r--r--chrome/renderer/render_thread.cc17
-rw-r--r--chrome/renderer/render_thread.h3
-rw-r--r--chrome/renderer/renderer_glue.cc4
-rw-r--r--chrome/test/worker/test_worker_main.cc1
-rw-r--r--webkit/glue/glue.vcproj8
-rw-r--r--webkit/glue/resource_handle_impl.cc2
-rw-r--r--webkit/glue/resource_loader_bridge.h7
-rw-r--r--webkit/glue/unittest_test_server.h2
-rw-r--r--webkit/glue/webappcachecontext.cc41
-rw-r--r--webkit/glue/webappcachecontext.h77
-rw-r--r--webkit/glue/webframe.h9
-rw-r--r--webkit/glue/webframe_impl.cc38
-rw-r--r--webkit/glue/webframe_impl.h9
-rw-r--r--webkit/glue/webframeloaderclient_impl.cc6
-rw-r--r--webkit/glue/webresponse.h3
-rw-r--r--webkit/glue/webresponse_impl.h10
-rw-r--r--webkit/tools/test_shell/simple_resource_loader_bridge.cc11
-rw-r--r--webkit/webkit.gyp2
37 files changed, 680 insertions, 14 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;
}
diff --git a/webkit/glue/glue.vcproj b/webkit/glue/glue.vcproj
index e66e415..8ba8ddc 100644
--- a/webkit/glue/glue.vcproj
+++ b/webkit/glue/glue.vcproj
@@ -186,6 +186,14 @@
>
</File>
<File
+ RelativePath=".\webappcachecontext.cc"
+ >
+ </File>
+ <File
+ RelativePath=".\webappcachecontext.h"
+ >
+ </File>
+ <File
RelativePath=".\webdatasource.h"
>
</File>
diff --git a/webkit/glue/resource_handle_impl.cc b/webkit/glue/resource_handle_impl.cc
index 7b1e6a3..a4484ed 100644
--- a/webkit/glue/resource_handle_impl.cc
+++ b/webkit/glue/resource_handle_impl.cc
@@ -192,6 +192,7 @@ static ResourceResponse MakeResourceResponse(
response.setHTTPStatusCode(status_code);
response.setHTTPStatusText(status_text);
response.setSecurityInfo(webkit_glue::StdStringToCString(info.security_info));
+ response.setAppCacheID(info.app_cache_id);
// WebKit doesn't provide a way for us to set expected content length after
// calling the constructor, so we parse the headers first and then swap in
@@ -431,6 +432,7 @@ bool ResourceHandleInternal::Start(
load_flags_,
requestor_pid,
FromTargetType(request_.targetType()),
+ request_.appCacheContextID(),
request_.requestorID()));
if (!bridge_.get())
return false;
diff --git a/webkit/glue/resource_loader_bridge.h b/webkit/glue/resource_loader_bridge.h
index f006974..b371dfa 100644
--- a/webkit/glue/resource_loader_bridge.h
+++ b/webkit/glue/resource_loader_bridge.h
@@ -68,6 +68,9 @@ 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;
+
// A platform specific handle for a file that carries response data. This
// entry is used if the resource request is of type ResourceType::MEDIA and
// the underlying cache layer keeps the response data in a standalone file.
@@ -172,6 +175,9 @@ 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
+ // associated with.
+ //
// routing_id passed to this function allows it to be associated with a
// frame's network context.
static ResourceLoaderBridge* Create(const std::string& method,
@@ -185,6 +191,7 @@ class ResourceLoaderBridge {
int load_flags,
int requestor_pid,
ResourceType::Type request_type,
+ int app_cache_context_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 54e8b79..07f4b83 100644
--- a/webkit/glue/unittest_test_server.h
+++ b/webkit/glue/unittest_test_server.h
@@ -6,6 +6,7 @@
#define WEBKIT_GLUE_UNITTEST_TEST_SERVER_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,6 +50,7 @@ class UnittestTestServer : public HTTPTestServer {
net::LOAD_NORMAL,
0,
ResourceType::SUB_RESOURCE,
+ WebAppCacheContext::kNoAppCacheContextId,
0));
EXPECT_TRUE(loader.get());
diff --git a/webkit/glue/webappcachecontext.cc b/webkit/glue/webappcachecontext.cc
new file mode 100644
index 0000000..0194ded
--- /dev/null
+++ b/webkit/glue/webappcachecontext.cc
@@ -0,0 +1,41 @@
+// 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 context_id() { return kNoAppCacheContextId; }
+ virtual int64 app_cache_id() { 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
new file mode 100644
index 0000000..84d167c
--- /dev/null
+++ b/webkit/glue/webappcachecontext.h
@@ -0,0 +1,77 @@
+// 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 context_id() = 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 app_cache_id() = 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/webframe.h b/webkit/glue/webframe.h
index 23b12c5..9c36c95 100644
--- a/webkit/glue/webframe.h
+++ b/webkit/glue/webframe.h
@@ -11,6 +11,7 @@
#include "skia/ext/platform_canvas.h"
#include "webkit/glue/feed.h"
+class WebAppCacheContext;
class WebDataSource;
class WebError;
class WebRequest;
@@ -380,6 +381,14 @@ class WebFrame {
// mode.
virtual float PrintPage(int page, skia::PlatformCanvas* canvas) = 0;
+ // Initiates app cache selection for the context with the resource currently
+ // committed in the webframe.
+ virtual void SelectAppCacheWithoutManifest() = 0;
+ virtual void SelectAppCacheWithManifest(const GURL& manifest_url) = 0;
+
+ // Returns a pointer to the WebAppCacheContext for this frame.
+ virtual WebAppCacheContext* GetAppCacheContext() const = 0;
+
// Reformats the web frame for screen display.
virtual void EndPrint() = 0;
diff --git a/webkit/glue/webframe_impl.cc b/webkit/glue/webframe_impl.cc
index b1bfff8..ceca109 100644
--- a/webkit/glue/webframe_impl.cc
+++ b/webkit/glue/webframe_impl.cc
@@ -144,6 +144,7 @@ MSVC_POP_WARNING();
#include "webkit/glue/feed.h"
#include "webkit/glue/glue_serialize.h"
#include "webkit/glue/glue_util.h"
+#include "webkit/glue/webappcachecontext.h"
#include "webkit/glue/webdatasource_impl.h"
#include "webkit/glue/weberror_impl.h"
#include "webkit/glue/webframe_impl.h"
@@ -355,7 +356,8 @@ MSVC_POP_WARNING()
total_matchcount_(-1),
frames_scoping_count_(-1),
scoping_complete_(false),
- next_invalidate_after_(0) {
+ next_invalidate_after_(0),
+ app_cache_context_(WebAppCacheContext::Create()) {
StatsCounter(kWebFrameActiveCount).Increment();
live_object_count_++;
}
@@ -384,6 +386,9 @@ void WebFrameImpl::InitMainFrame(WebViewImpl* webview_impl) {
// We must call init() after frame_ is assigned because it is referenced
// during init().
frame_->init();
+
+ // Inform the browser process of this top-level frame
+ app_cache_context_->Initialize(WebAppCacheContext::MAIN_FRAME, NULL);
}
void WebFrameImpl::LoadRequest(WebRequest* request) {
@@ -1806,10 +1811,15 @@ PassRefPtr<Frame> WebFrameImpl::CreateChildFrame(
if (!child_frame->tree()->parent())
return NULL;
+ // Inform the browser process of this child frame
+ webframe->app_cache_context_->Initialize(WebAppCacheContext::CHILD_FRAME,
+ app_cache_context_.get());
+
frame_->loader()->loadURLIntoChildFrame(
request.resourceRequest().url(),
request.resourceRequest().httpReferrer(),
child_frame.get());
+
// A synchronous navigation (about:blank) would have already processed
// onload, so it is possible for the frame to have already been destroyed by
// script in the page.
@@ -1915,6 +1925,32 @@ float WebFrameImpl::PrintPage(int page, skia::PlatformCanvas* canvas) {
return print_context_->spoolPage(spool, page);
}
+void WebFrameImpl::SelectAppCacheWithoutManifest() {
+ WebDataSource* ds = GetDataSource();
+ DCHECK(ds);
+ if (ds->HasUnreachableURL()) {
+ app_cache_context_->SelectAppCacheWithoutManifest(
+ ds->GetUnreachableURL(),
+ WebAppCacheContext::kNoAppCacheId);
+ } else {
+ const WebResponse& response = ds->GetResponse();
+ app_cache_context_->SelectAppCacheWithoutManifest(
+ GetURL(),
+ response.GetAppCacheID());
+ }
+}
+
+void WebFrameImpl::SelectAppCacheWithManifest(const GURL &manifest_url) {
+ WebDataSource* ds = GetDataSource();
+ DCHECK(ds);
+ DCHECK(!ds->HasUnreachableURL());
+ const WebResponse& response = ds->GetResponse();
+ app_cache_context_->SelectAppCacheWithManifest(
+ GetURL(),
+ response.GetAppCacheID(),
+ manifest_url);
+}
+
void WebFrameImpl::EndPrint() {
DCHECK(print_context_.get());
if (print_context_.get())
diff --git a/webkit/glue/webframe_impl.h b/webkit/glue/webframe_impl.h
index 81a5f7f..942c000 100644
--- a/webkit/glue/webframe_impl.h
+++ b/webkit/glue/webframe_impl.h
@@ -181,6 +181,12 @@ class WebFrameImpl : public WebFrame, public base::RefCounted<WebFrameImpl> {
virtual float PrintPage(int page, skia::PlatformCanvas* canvas);
virtual void EndPrint();
+ virtual void SelectAppCacheWithoutManifest();
+ virtual void SelectAppCacheWithManifest(const GURL& manifest_url);
+ virtual WebAppCacheContext* GetAppCacheContext() const {
+ return app_cache_context_.get();
+ }
+
PassRefPtr<WebCore::Frame> CreateChildFrame(
const WebCore::FrameLoadRequest&,
WebCore::HTMLFrameOwnerElement* owner_element);
@@ -412,6 +418,9 @@ class WebFrameImpl : public WebFrame, public base::RefCounted<WebFrameImpl> {
// information. Is used by PrintPage().
scoped_ptr<ChromePrintContext> print_context_;
+ // The app cache context for this frame.
+ scoped_ptr<WebAppCacheContext> app_cache_context_;
+
// The input fields that are interested in edit events and their associated
// listeners.
typedef HashMap<RefPtr<WebCore::HTMLInputElement>,
diff --git a/webkit/glue/webframeloaderclient_impl.cc b/webkit/glue/webframeloaderclient_impl.cc
index 34f1763..29407d9 100644
--- a/webkit/glue/webframeloaderclient_impl.cc
+++ b/webkit/glue/webframeloaderclient_impl.cc
@@ -50,6 +50,7 @@ MSVC_POP_WARNING();
#include "webkit/glue/password_form_dom_manager.h"
#include "webkit/glue/plugins/plugin_list.h"
#include "webkit/glue/searchable_form_data.h"
+#include "webkit/glue/webappcachecontext.h"
#include "webkit/glue/webdatasource_impl.h"
#include "webkit/glue/webdevtoolsagent_impl.h"
#include "webkit/glue/weberror_impl.h"
@@ -234,6 +235,8 @@ void WebFrameLoaderClient::dispatchWillSendRequest(
if (net_agent) {
net_agent->WillSendRequest(loader, identifier, request);
}
+
+ request.setAppCacheContextID(webframe_->GetAppCacheContext()->context_id());
}
bool WebFrameLoaderClient::shouldUseCredentialStorage(DocumentLoader*,
@@ -785,8 +788,9 @@ void WebFrameLoaderClient::dispatchDidReceiveTitle(const String& title) {
}
void WebFrameLoaderClient::dispatchDidCommitLoad() {
- WebViewImpl* webview = webframe_->webview_impl();
+ webframe_->SelectAppCacheWithoutManifest();
+ WebViewImpl* webview = webframe_->webview_impl();
bool is_new_navigation;
webview->DidCommitLoad(&is_new_navigation);
WebViewDelegate* d = webview->delegate();
diff --git a/webkit/glue/webresponse.h b/webkit/glue/webresponse.h
index 1fdf97d..3ee4ed5 100644
--- a/webkit/glue/webresponse.h
+++ b/webkit/glue/webresponse.h
@@ -31,6 +31,9 @@ class WebResponse {
// security reasons).
virtual bool IsContentFiltered() const = 0;
+ // Returns the appcacheId this response was loaded from, or kNoAppCacheId.
+ virtual int64 GetAppCacheID() const = 0;
+
virtual ~WebResponse() {}
};
diff --git a/webkit/glue/webresponse_impl.h b/webkit/glue/webresponse_impl.h
index d21bcab82..47f097c 100644
--- a/webkit/glue/webresponse_impl.h
+++ b/webkit/glue/webresponse_impl.h
@@ -40,9 +40,13 @@ class WebResponseImpl : public WebResponse {
response_ = response;
}
- virtual bool IsContentFiltered() const {
- return response_.isContentFiltered();
- }
+ virtual bool IsContentFiltered() const {
+ return response_.isContentFiltered();
+ }
+
+ virtual int64 GetAppCacheID() const {
+ return response_.getAppCacheID();
+ }
private:
WebCore::ResourceResponse response_;
diff --git a/webkit/tools/test_shell/simple_resource_loader_bridge.cc b/webkit/tools/test_shell/simple_resource_loader_bridge.cc
index fd409a0..bc1d96a 100644
--- a/webkit/tools/test_shell/simple_resource_loader_bridge.cc
+++ b/webkit/tools/test_shell/simple_resource_loader_bridge.cc
@@ -46,6 +46,7 @@
#include "net/proxy/proxy_service.h"
#include "net/url_request/url_request.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;
@@ -99,6 +100,7 @@ struct RequestParams {
GURL referrer;
std::string headers;
int load_flags;
+ int app_cache_context_id;
scoped_refptr<net::UploadData> upload;
};
@@ -287,6 +289,7 @@ 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;
request->GetMimeType(&info.mime_type);
request->GetCharset(&info.charset);
info.content_length = request->GetExpectedContentSize();
@@ -427,7 +430,8 @@ class ResourceLoaderBridgeImpl : public ResourceLoaderBridge {
const GURL& policy_url,
const GURL& referrer,
const std::string& headers,
- int load_flags)
+ int load_flags,
+ int app_cache_context_id)
: params_(new RequestParams),
proxy_(NULL) {
params_->method = method;
@@ -436,6 +440,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;
}
virtual ~ResourceLoaderBridgeImpl() {
@@ -570,9 +575,11 @@ ResourceLoaderBridge* ResourceLoaderBridge::Create(
int load_flags,
int requestor_pid,
ResourceType::Type request_type,
+ int app_cache_context_id,
int routing_id) {
return new ResourceLoaderBridgeImpl(method, url, policy_url,
- referrer, headers, load_flags);
+ referrer, headers, load_flags,
+ app_cache_context_id);
}
// Issue the proxy resolve request on the io thread, and wait
diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp
index 3663ce7..c1b926c 100644
--- a/webkit/webkit.gyp
+++ b/webkit/webkit.gyp
@@ -4372,6 +4372,8 @@
'glue/simple_webmimeregistry_impl.h',
'glue/stacking_order_iterator.cc',
'glue/stacking_order_iterator.h',
+ 'glue/webappcachecontext.cc',
+ 'glue/webappcachecontext.h',
'glue/webclipboard_impl.cc',
'glue/webclipboard_impl.h',
'glue/webcursor.cc',