From e16b8af74c13f79282c608042d92fc1000fb5e62 Mon Sep 17 00:00:00 2001 From: "michaeln@google.com" Date: Mon, 21 Mar 2011 22:11:42 +0000 Subject: 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 --- webkit/appcache/appcache_backend_impl.cc | 13 ++++++++++++- webkit/appcache/appcache_backend_impl.h | 3 ++- webkit/appcache/appcache_interfaces.h | 3 ++- webkit/appcache/web_application_cache_host_impl.cc | 11 +++++++++-- webkit/appcache/web_application_cache_host_impl.h | 5 +++-- 5 files changed, 28 insertions(+), 7 deletions(-) (limited to 'webkit/appcache') 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); -- cgit v1.1