diff options
Diffstat (limited to 'webkit/glue')
-rw-r--r-- | webkit/glue/glue.vcproj | 8 | ||||
-rw-r--r-- | webkit/glue/resource_handle_impl.cc | 2 | ||||
-rw-r--r-- | webkit/glue/resource_loader_bridge.h | 7 | ||||
-rw-r--r-- | webkit/glue/unittest_test_server.h | 2 | ||||
-rw-r--r-- | webkit/glue/webappcachecontext.cc | 41 | ||||
-rw-r--r-- | webkit/glue/webappcachecontext.h | 77 | ||||
-rw-r--r-- | webkit/glue/webframe.h | 9 | ||||
-rw-r--r-- | webkit/glue/webframe_impl.cc | 38 | ||||
-rw-r--r-- | webkit/glue/webframe_impl.h | 9 | ||||
-rw-r--r-- | webkit/glue/webframeloaderclient_impl.cc | 6 | ||||
-rw-r--r-- | webkit/glue/webresponse.h | 3 | ||||
-rw-r--r-- | webkit/glue/webresponse_impl.h | 10 |
12 files changed, 207 insertions, 5 deletions
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_; |