diff options
author | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-21 22:11:42 +0000 |
---|---|---|
committer | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-21 22:11:42 +0000 |
commit | e16b8af74c13f79282c608042d92fc1000fb5e62 (patch) | |
tree | 98d6594941193b24caaf66bd956fc1ea9eef0b58 | |
parent | 778574e9b16cb9438b5edb364e45bd88b02b2483 (diff) | |
download | chromium_src-e16b8af74c13f79282c608042d92fc1000fb5e62.zip chromium_src-e16b8af74c13f79282c608042d92fc1000fb5e62.tar.gz chromium_src-e16b8af74c13f79282c608042d92fc1000fb5e62.tar.bz2 |
Plumbing to support loading from the "most appropriate" appcache.
BUG=68479
Review URL: http://codereview.chromium.org/6667057
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78934 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | content/browser/appcache/appcache_dispatcher_host.cc | 9 | ||||
-rw-r--r-- | content/browser/appcache/appcache_dispatcher_host.h | 1 | ||||
-rw-r--r-- | content/common/appcache/appcache_backend_proxy.cc | 6 | ||||
-rw-r--r-- | content/common/appcache/appcache_backend_proxy.h | 1 | ||||
-rw-r--r-- | content/common/appcache_messages.h | 8 | ||||
-rw-r--r-- | content/worker/worker_webapplicationcachehost_impl.cc | 21 | ||||
-rw-r--r-- | content/worker/worker_webapplicationcachehost_impl.h | 15 | ||||
-rw-r--r-- | webkit/appcache/appcache_backend_impl.cc | 13 | ||||
-rw-r--r-- | webkit/appcache/appcache_backend_impl.h | 3 | ||||
-rw-r--r-- | webkit/appcache/appcache_interfaces.h | 3 | ||||
-rw-r--r-- | webkit/appcache/web_application_cache_host_impl.cc | 11 | ||||
-rw-r--r-- | webkit/appcache/web_application_cache_host_impl.h | 5 | ||||
-rw-r--r-- | webkit/tools/test_shell/simple_appcache_system.cc | 14 |
13 files changed, 95 insertions, 15 deletions
diff --git a/content/browser/appcache/appcache_dispatcher_host.cc b/content/browser/appcache/appcache_dispatcher_host.cc index e3f4430..7fefe39 100644 --- a/content/browser/appcache/appcache_dispatcher_host.cc +++ b/content/browser/appcache/appcache_dispatcher_host.cc @@ -63,6 +63,7 @@ bool AppCacheDispatcherHost::OnMessageReceived(const IPC::Message& message, IPC_BEGIN_MESSAGE_MAP_EX(AppCacheDispatcherHost, message, *message_was_ok) IPC_MESSAGE_HANDLER(AppCacheHostMsg_RegisterHost, OnRegisterHost) IPC_MESSAGE_HANDLER(AppCacheHostMsg_UnregisterHost, OnUnregisterHost) + IPC_MESSAGE_HANDLER(AppCacheHostMsg_SetSpawningHostId, OnSetSpawningHostId) IPC_MESSAGE_HANDLER(AppCacheHostMsg_GetResourceList, OnGetResourceList) IPC_MESSAGE_HANDLER(AppCacheHostMsg_SelectCache, OnSelectCache) IPC_MESSAGE_HANDLER(AppCacheHostMsg_SelectCacheForWorker, @@ -101,6 +102,14 @@ void AppCacheDispatcherHost::OnUnregisterHost(int host_id) { } } +void AppCacheDispatcherHost::OnSetSpawningHostId( + int host_id, int spawning_host_id) { + if (appcache_service_.get()) { + if (!backend_impl_.SetSpawningHostId(host_id, spawning_host_id)) + BadMessageReceived(); + } +} + void AppCacheDispatcherHost::OnSelectCache( int host_id, const GURL& document_url, int64 cache_document_was_loaded_from, diff --git a/content/browser/appcache/appcache_dispatcher_host.h b/content/browser/appcache/appcache_dispatcher_host.h index e6b9f34..010dad5 100644 --- a/content/browser/appcache/appcache_dispatcher_host.h +++ b/content/browser/appcache/appcache_dispatcher_host.h @@ -51,6 +51,7 @@ class AppCacheDispatcherHost : public BrowserMessageFilter { // IPC message handlers void OnRegisterHost(int host_id); void OnUnregisterHost(int host_id); + void OnSetSpawningHostId(int host_id, int spawning_host_id); void OnSelectCache(int host_id, const GURL& document_url, int64 cache_document_was_loaded_from, const GURL& opt_manifest_url); diff --git a/content/common/appcache/appcache_backend_proxy.cc b/content/common/appcache/appcache_backend_proxy.cc index be54b76..688b221 100644 --- a/content/common/appcache/appcache_backend_proxy.cc +++ b/content/common/appcache/appcache_backend_proxy.cc @@ -14,6 +14,12 @@ void AppCacheBackendProxy::UnregisterHost(int host_id) { sender_->Send(new AppCacheHostMsg_UnregisterHost(host_id)); } +void AppCacheBackendProxy::SetSpawningHostId(int host_id, + int spawning_host_id) { + sender_->Send(new AppCacheHostMsg_SetSpawningHostId( + host_id, spawning_host_id)); +} + void AppCacheBackendProxy::SelectCache( int host_id, const GURL& document_url, diff --git a/content/common/appcache/appcache_backend_proxy.h b/content/common/appcache/appcache_backend_proxy.h index b05115e..af09abf 100644 --- a/content/common/appcache/appcache_backend_proxy.h +++ b/content/common/appcache/appcache_backend_proxy.h @@ -20,6 +20,7 @@ class AppCacheBackendProxy : public appcache::AppCacheBackend { // AppCacheBackend methods virtual void RegisterHost(int host_id); virtual void UnregisterHost(int host_id); + virtual void SetSpawningHostId(int host_id, int spawning_host_id); virtual void SelectCache(int host_id, const GURL& document_url, const int64 cache_document_was_loaded_from, diff --git a/content/common/appcache_messages.h b/content/common/appcache_messages.h index d14ffa8..d755e99 100644 --- a/content/common/appcache_messages.h +++ b/content/common/appcache_messages.h @@ -43,6 +43,14 @@ IPC_MESSAGE_CONTROL1(AppCacheHostMsg_RegisterHost, IPC_MESSAGE_CONTROL1(AppCacheHostMsg_UnregisterHost, int /* host_id */) +// Informs the browser of which host caused another to be created. +// This can influence which appcache should be utilized for the main +// resource load into the newly created host, so it should be sent +// prior to the main resource request being initiated. +IPC_MESSAGE_CONTROL2(AppCacheHostMsg_SetSpawningHostId, + int /* host_id */, + int /* spawning_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. diff --git a/content/worker/worker_webapplicationcachehost_impl.cc b/content/worker/worker_webapplicationcachehost_impl.cc index 45c75ed..734302c 100644 --- a/content/worker/worker_webapplicationcachehost_impl.cc +++ b/content/worker/worker_webapplicationcachehost_impl.cc @@ -21,7 +21,26 @@ WorkerWebApplicationCacheHostImpl::WorkerWebApplicationCacheHostImpl( init_info.parent_appcache_host_id); } +void WorkerWebApplicationCacheHostImpl::willStartMainResourceRequest( + WebKit::WebURLRequest&, const WebKit::WebFrame*) { +} + +void WorkerWebApplicationCacheHostImpl::didReceiveResponseForMainResource( + const WebKit::WebURLResponse&) { +} + +void WorkerWebApplicationCacheHostImpl::didReceiveDataForMainResource( + const char*, int) { +} + +void WorkerWebApplicationCacheHostImpl::didFinishLoadingMainResource( + bool) { +} + +void WorkerWebApplicationCacheHostImpl::selectCacheWithoutManifest() { +} + bool WorkerWebApplicationCacheHostImpl::selectCacheWithManifest( - const WebKit::WebURL& manifestURL) { + const WebKit::WebURL&) { return true; } diff --git a/content/worker/worker_webapplicationcachehost_impl.h b/content/worker/worker_webapplicationcachehost_impl.h index db6dc8a..e356583 100644 --- a/content/worker/worker_webapplicationcachehost_impl.h +++ b/content/worker/worker_webapplicationcachehost_impl.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -36,15 +36,18 @@ class WorkerWebApplicationCacheHostImpl // Main resource loading is different for workers. The resource is // loaded by the creator of the worker rather than the worker itself. - virtual void willStartMainResourceRequest(WebKit::WebURLRequest&) {} + // These overrides are stubbed out. + virtual void willStartMainResourceRequest( + WebKit::WebURLRequest&, const WebKit::WebFrame*); virtual void didReceiveResponseForMainResource( - const WebKit::WebURLResponse&) {} - virtual void didReceiveDataForMainResource(const char* data, int len) {} - virtual void didFinishLoadingMainResource(bool success) {} + const WebKit::WebURLResponse&); + virtual void didReceiveDataForMainResource(const char* data, int len); + virtual void didFinishLoadingMainResource(bool success); // Cache selection is also different for workers. We know at construction // time what cache to select and do so then. - virtual void selectCacheWithoutManifest() {} + // These overrides are stubbed out. + virtual void selectCacheWithoutManifest(); virtual bool selectCacheWithManifest(const WebKit::WebURL& manifestURL); }; diff --git a/webkit/appcache/appcache_backend_impl.cc b/webkit/appcache/appcache_backend_impl.cc index a9349fa..8ada332 100644 --- a/webkit/appcache/appcache_backend_impl.cc +++ b/webkit/appcache/appcache_backend_impl.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -53,6 +53,17 @@ bool AppCacheBackendImpl::UnregisterHost(int id) { return true; } +bool AppCacheBackendImpl::SetSpawningHostId( + int host_id, + int spawning_host_id) { + AppCacheHost* host = GetHost(host_id); + if (!host) + return false; + // TODO(michaeln): Write me, see the bug for details. + // http://code.google.com/p/chromium/issues/detail?id=68479 + return true; +} + bool AppCacheBackendImpl::SelectCache( int host_id, const GURL& document_url, diff --git a/webkit/appcache/appcache_backend_impl.h b/webkit/appcache/appcache_backend_impl.h index ac563ff..9a0e1ae 100644 --- a/webkit/appcache/appcache_backend_impl.h +++ b/webkit/appcache/appcache_backend_impl.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -28,6 +28,7 @@ class AppCacheBackendImpl { // by the backend impl. bool RegisterHost(int host_id); bool UnregisterHost(int host_id); + bool SetSpawningHostId(int host_id, int spawning_host_id); bool SelectCache(int host_id, const GURL& document_url, const int64 cache_document_was_loaded_from, diff --git a/webkit/appcache/appcache_interfaces.h b/webkit/appcache/appcache_interfaces.h index d29acd6..a251e21 100644 --- a/webkit/appcache/appcache_interfaces.h +++ b/webkit/appcache/appcache_interfaces.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -110,6 +110,7 @@ class AppCacheBackend { public: virtual void RegisterHost(int host_id) = 0; virtual void UnregisterHost(int host_id) = 0; + virtual void SetSpawningHostId(int host_id, int spawning_host_id) = 0; virtual void SelectCache(int host_id, const GURL& document_url, const int64 cache_document_was_loaded_from, diff --git a/webkit/appcache/web_application_cache_host_impl.cc b/webkit/appcache/web_application_cache_host_impl.cc index 0bdc11f..981894d 100644 --- a/webkit/appcache/web_application_cache_host_impl.cc +++ b/webkit/appcache/web_application_cache_host_impl.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -156,7 +156,7 @@ void WebApplicationCacheHostImpl::OnErrorEventRaised( } void WebApplicationCacheHostImpl::willStartMainResourceRequest( - WebURLRequest& request) { + WebURLRequest& request, const WebFrame* frame) { request.setAppCacheHostID(host_id_); original_main_resource_url_ = ClearUrlRef(request.url()); @@ -164,6 +164,13 @@ void WebApplicationCacheHostImpl::willStartMainResourceRequest( std::string method = request.httpMethod().utf8(); is_get_method_ = (method == kHttpGETMethod); DCHECK(method == StringToUpperASCII(method)); + + if (frame) { + if (WebApplicationCacheHostImpl* parent = FromFrame(frame->parent())) + backend_->SetSpawningHostId(host_id_, parent->host_id()); + else if (WebApplicationCacheHostImpl* opener = FromFrame(frame->opener())) + backend_->SetSpawningHostId(host_id_, opener->host_id()); + } } void WebApplicationCacheHostImpl::willStartSubResourceRequest( diff --git a/webkit/appcache/web_application_cache_host_impl.h b/webkit/appcache/web_application_cache_host_impl.h index c7af54a..03020f0 100644 --- a/webkit/appcache/web_application_cache_host_impl.h +++ b/webkit/appcache/web_application_cache_host_impl.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -44,7 +44,8 @@ class WebApplicationCacheHostImpl : public WebKit::WebApplicationCacheHost { virtual void OnContentBlocked(const GURL& manifest_url) {} // WebApplicationCacheHost methods - virtual void willStartMainResourceRequest(WebKit::WebURLRequest&); + virtual void willStartMainResourceRequest(WebKit::WebURLRequest&, + const WebKit::WebFrame*); virtual void willStartSubResourceRequest(WebKit::WebURLRequest&); virtual void selectCacheWithoutManifest(); virtual bool selectCacheWithManifest(const WebKit::WebURL& manifestURL); diff --git a/webkit/tools/test_shell/simple_appcache_system.cc b/webkit/tools/test_shell/simple_appcache_system.cc index c126849..af6242d 100644 --- a/webkit/tools/test_shell/simple_appcache_system.cc +++ b/webkit/tools/test_shell/simple_appcache_system.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -199,6 +199,18 @@ class SimpleBackendProxy } } + virtual void SetSpawningHostId(int host_id, int spawning_host_id) { + if (system_->is_ui_thread()) { + system_->io_message_loop()->PostTask(FROM_HERE, NewRunnableMethod( + this, &SimpleBackendProxy::SetSpawningHostId, + host_id, spawning_host_id)); + } else if (system_->is_io_thread()) { + system_->backend_impl_->SetSpawningHostId(host_id, spawning_host_id); + } else { + NOTREACHED(); + } + } + virtual void SelectCache(int host_id, const GURL& document_url, const int64 cache_document_was_loaded_from, |