diff options
Diffstat (limited to 'webkit/glue')
-rw-r--r-- | webkit/glue/webdatasource.h | 38 | ||||
-rw-r--r-- | webkit/glue/webdatasource_impl.cc | 51 | ||||
-rw-r--r-- | webkit/glue/webdatasource_impl.h | 34 | ||||
-rw-r--r-- | webkit/glue/webframe_impl.cc | 1 | ||||
-rw-r--r-- | webkit/glue/webframeloaderclient_impl.cc | 51 | ||||
-rw-r--r-- | webkit/glue/webframeloaderclient_impl.h | 3 | ||||
-rw-r--r-- | webkit/glue/webview_delegate.h | 10 |
7 files changed, 154 insertions, 34 deletions
diff --git a/webkit/glue/webdatasource.h b/webkit/glue/webdatasource.h index 3bd29d1..70c4283 100644 --- a/webkit/glue/webdatasource.h +++ b/webkit/glue/webdatasource.h @@ -14,8 +14,22 @@ class SearchableFormData; class WebFrame; class WebRequest; class WebResponse; + +namespace base { +class Time; +} + struct PasswordForm; +enum WebNavigationType { + WebNavigationTypeLinkClicked, + WebNavigationTypeFormSubmitted, + WebNavigationTypeBackForward, + WebNavigationTypeReload, + WebNavigationTypeFormResubmitted, + WebNavigationTypeOther +}; + class WebDataSource { public: virtual ~WebDataSource() {} @@ -81,6 +95,30 @@ class WebDataSource { // Returns the page title. virtual string16 GetPageTitle() const = 0; + + // Returns the time the document was request by the user. + virtual base::Time GetRequestTime() const = 0; + + // Sets the request time. This is used to override the default behavior + // if the client knows more about the origination of the request than the + // underlying mechanism could. + virtual void SetRequestTime(base::Time time) = 0; + + // Returns the time we started loading the page. This corresponds to + // the DidStartProvisionalLoadForFrame delegate notification. + virtual base::Time GetStartLoadTime() const = 0; + + // Returns the time the document itself was finished loading. This corresponds + // to the DidFinishDocumentLoadForFrame delegate notification. + virtual base::Time GetFinishDocumentLoadTime() const = 0; + + // Returns the time all dependent resources have been loaded and onload() + // has been called. This corresponds to the DidFinishLoadForFrame delegate + // notification. + virtual base::Time GetFinishLoadTime() const = 0; + + // Returns the reason the document was loaded. + virtual WebNavigationType GetNavigationType() const = 0; }; #endif // #ifndef WEBKIT_GLUE_WEBDATASOURCE_H_ diff --git a/webkit/glue/webdatasource_impl.cc b/webkit/glue/webdatasource_impl.cc index d3517d8..9d31b0f 100644 --- a/webkit/glue/webdatasource_impl.cc +++ b/webkit/glue/webdatasource_impl.cc @@ -5,17 +5,23 @@ #include "config.h" #include "webkit/glue/webdatasource_impl.h" -#include "KURL.h" +#include "FrameLoaderTypes.h" #include "FrameLoadRequest.h" +#include "KURL.h" #include "ResourceRequest.h" #undef LOG +#include "base/histogram.h" #include "base/string_util.h" #include "webkit/glue/glue_util.h" #include "webkit/glue/password_form.h" #include "webkit/glue/webdatasource_impl.h" #include "webkit/glue/webframe_impl.h" #include "webkit/glue/weburlrequest_impl.h" +#include "webkit/glue/webview_delegate.h" + +using base::TimeDelta; +using base::Time; // static PassRefPtr<WebDataSourceImpl> WebDataSourceImpl::Create( @@ -99,3 +105,46 @@ bool WebDataSourceImpl::IsFormSubmit() const { string16 WebDataSourceImpl::GetPageTitle() const { return webkit_glue::StringToString16(title()); } + +base::Time WebDataSourceImpl::GetRequestTime() const { + return request_time_; +} + +void WebDataSourceImpl::SetRequestTime(base::Time time) { + request_time_ = time; +} + +base::Time WebDataSourceImpl::GetStartLoadTime() const { + return start_load_time_; +} + +base::Time WebDataSourceImpl::GetFinishDocumentLoadTime() const { + return finish_document_load_time_; +} + +base::Time WebDataSourceImpl::GetFinishLoadTime() const { + return finish_load_time_; +} + +WebNavigationType WebDataSourceImpl::GetNavigationType() const { + return NavigationTypeToWebNavigationType(triggeringAction().type()); +} + +WebNavigationType WebDataSourceImpl::NavigationTypeToWebNavigationType( + WebCore::NavigationType type) { + switch (type) { + case WebCore::NavigationTypeLinkClicked: + return WebNavigationTypeLinkClicked; + case WebCore::NavigationTypeFormSubmitted: + return WebNavigationTypeFormSubmitted; + case WebCore::NavigationTypeBackForward: + return WebNavigationTypeBackForward; + case WebCore::NavigationTypeReload: + return WebNavigationTypeReload; + case WebCore::NavigationTypeFormResubmitted: + return WebNavigationTypeFormResubmitted; + case WebCore::NavigationTypeOther: + default: + return WebNavigationTypeOther; + } +} diff --git a/webkit/glue/webdatasource_impl.h b/webkit/glue/webdatasource_impl.h index 4585a65..90f8313 100644 --- a/webkit/glue/webdatasource_impl.h +++ b/webkit/glue/webdatasource_impl.h @@ -8,6 +8,7 @@ #include "DocumentLoader.h" #include "base/scoped_ptr.h" +#include "base/time.h" #include "webkit/glue/searchable_form_data.h" #include "webkit/glue/webdatasource.h" #include "webkit/glue/webresponse_impl.h" @@ -20,7 +21,7 @@ class WebDataSourceImpl : public WebCore::DocumentLoader, public WebDataSource { public: static PassRefPtr<WebDataSourceImpl> Create(const WebCore::ResourceRequest&, const WebCore::SubstituteData&); - + static WebDataSourceImpl* FromLoader(WebCore::DocumentLoader* loader) { return static_cast<WebDataSourceImpl*>(loader); } @@ -37,6 +38,15 @@ class WebDataSourceImpl : public WebCore::DocumentLoader, public WebDataSource { virtual const PasswordForm* GetPasswordFormData() const; virtual bool IsFormSubmit() const; virtual string16 GetPageTitle() const; + virtual base::Time GetRequestTime() const; + virtual void SetRequestTime(base::Time time); + virtual base::Time GetStartLoadTime() const; + virtual base::Time GetFinishDocumentLoadTime() const; + virtual base::Time GetFinishLoadTime() const; + virtual WebNavigationType GetNavigationType() const; + + static WebNavigationType NavigationTypeToWebNavigationType( + WebCore::NavigationType type); // Called after creating a new data source if there is request info // available. Since we store copies of the WebRequests, the original @@ -77,6 +87,22 @@ class WebDataSourceImpl : public WebCore::DocumentLoader, public WebDataSource { return form_submit_; } + void set_request_time(base::Time request_time) { + request_time_ = request_time; + } + + void set_start_load_time(base::Time start_load_time) { + start_load_time_ = start_load_time; + } + + void set_finish_document_load_time(base::Time finish_document_load_time) { + finish_document_load_time_ = finish_document_load_time; + } + + void set_finish_load_time(base::Time finish_load_time) { + finish_load_time_ = finish_load_time; + } + private: WebDataSourceImpl(const WebCore::ResourceRequest&, const WebCore::SubstituteData&); @@ -99,6 +125,12 @@ class WebDataSourceImpl : public WebCore::DocumentLoader, public WebDataSource { bool form_submit_; + // See webdatasource.h for a description of these time stamps. + base::Time request_time_; + base::Time start_load_time_; + base::Time finish_document_load_time_; + base::Time finish_load_time_; + DISALLOW_COPY_AND_ASSIGN(WebDataSourceImpl); }; diff --git a/webkit/glue/webframe_impl.cc b/webkit/glue/webframe_impl.cc index 6a29ded..f647a72 100644 --- a/webkit/glue/webframe_impl.cc +++ b/webkit/glue/webframe_impl.cc @@ -131,7 +131,6 @@ MSVC_POP_WARNING(); #include "base/message_loop.h" #include "base/stats_counters.h" #include "base/string_util.h" -#include "base/time.h" #include "net/base/net_errors.h" #include "skia/ext/bitmap_platform_device.h" #include "skia/ext/platform_canvas.h" diff --git a/webkit/glue/webframeloaderclient_impl.cc b/webkit/glue/webframeloaderclient_impl.cc index 469fb02..e66157d 100644 --- a/webkit/glue/webframeloaderclient_impl.cc +++ b/webkit/glue/webframeloaderclient_impl.cc @@ -29,6 +29,7 @@ MSVC_PUSH_WARNING_LEVEL(0); #include "PlatformString.h" #include "PluginData.h" #include "RefPtr.h" +#include "StringExtras.h" #include "WindowFeatures.h" MSVC_POP_WARNING(); @@ -60,8 +61,11 @@ MSVC_POP_WARNING(); #include "webkit/glue/webview_delegate.h" #include "webkit/glue/webview_impl.h" #include "webkit/glue/weburlrequest.h" +#include "webkit/glue/weburlrequest_impl.h" using namespace WebCore; +using base::Time; +using base::TimeDelta; // Domain for internal error codes. static const char kInternalErrorDomain[] = "webkit_glue"; @@ -383,6 +387,10 @@ void WebFrameLoaderClient::dispatchDidFailLoading(DocumentLoader* loader, void WebFrameLoaderClient::dispatchDidFinishDocumentLoad() { WebViewImpl* webview = webframe_->webview_impl(); WebViewDelegate* d = webview->delegate(); + DocumentLoader* documentLoader = + webframe_->frame()->loader()->activeDocumentLoader(); + WebDataSourceImpl* data_source = + WebDataSourceImpl::FromLoader(documentLoader); // A frame may be reused. This call ensures we don't hold on to our password // listeners and their associated HTMLInputElements. @@ -419,6 +427,7 @@ void WebFrameLoaderClient::dispatchDidFinishDocumentLoad() { d->OnPasswordFormsSeen(webview, passwordForms); if (d) d->DidFinishDocumentLoadForFrame(webview, webframe_); + data_source->set_finish_document_load_time(base::Time::Now()); } bool WebFrameLoaderClient::dispatchDidLoadResourceFromMemoryCache( @@ -731,6 +740,21 @@ void WebFrameLoaderClient::dispatchDidStartProvisionalLoad() { // about the client redirect the load is responsible for completing. d->DidStartProvisionalLoadForFrame(webview, webframe_, NavigationGestureForLastLoad()); + DocumentLoader* documentLoader = + webframe_->frame()->loader()->activeDocumentLoader(); + WebDataSourceImpl* dataSource = + WebDataSourceImpl::FromLoader(documentLoader); + if (dataSource->GetRequestTime().ToInternalValue() == 0) { + const Event *event = documentLoader->triggeringAction().event(); + if (event) { + // If the request was generated by a click, we have to use the time + // from the event. Unfortunately this isn't tracked all the way from + // the platform event, but it will have to do + double eventTime = event->timeStamp() / 1000.0; + dataSource->set_request_time(Time::FromDoubleT(eventTime)); + } + } + dataSource->set_start_load_time(base::Time::Now()); if (completing_client_redirect) d->DidCompleteClientRedirect(webview, webframe_, expected_client_redirect_src_); @@ -803,8 +827,13 @@ void WebFrameLoaderClient::dispatchDidFailLoad(const ResourceError& error) { } void WebFrameLoaderClient::dispatchDidFinishLoad() { + DocumentLoader* documentLoader = + webframe_->frame()->loader()->activeDocumentLoader(); + WebDataSourceImpl* dataSource = + WebDataSourceImpl::FromLoader(documentLoader); WebViewImpl* webview = webframe_->webview_impl(); WebViewDelegate* d = webview->delegate(); + dataSource->set_finish_load_time(base::Time::Now()); if (d) d->DidFinishLoadForFrame(webview, webframe_); WebPluginDelegate* plg_delegate = webframe_->plugin_delegate(); @@ -939,26 +968,6 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction( (webframe_->frame()->loader()->*function)(policy_action); } -// Conversion. -static WebNavigationType NavigationTypeToWebNavigationType( - WebCore::NavigationType t) { - switch (t) { - case WebCore::NavigationTypeLinkClicked: - return WebNavigationTypeLinkClicked; - case WebCore::NavigationTypeFormSubmitted: - return WebNavigationTypeFormSubmitted; - case WebCore::NavigationTypeBackForward: - return WebNavigationTypeBackForward; - case WebCore::NavigationTypeReload: - return WebNavigationTypeReload; - case WebCore::NavigationTypeFormResubmitted: - return WebNavigationTypeFormResubmitted; - default: - case WebCore::NavigationTypeOther: - return WebNavigationTypeOther; - } -} - void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction( WebCore::FramePolicyFunction function, const WebCore::NavigationAction& action, @@ -985,7 +994,7 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction( bool is_redirect = !ds->GetRedirectChain().empty(); WebNavigationType webnav_type = - NavigationTypeToWebNavigationType(action.type()); + WebDataSourceImpl::NavigationTypeToWebNavigationType(action.type()); disposition = d->DispositionForNavigationAction( wv, webframe_, &ds->GetRequest(), webnav_type, disposition, is_redirect); diff --git a/webkit/glue/webframeloaderclient_impl.h b/webkit/glue/webframeloaderclient_impl.h index f712980..c15bfb1 100644 --- a/webkit/glue/webframeloaderclient_impl.h +++ b/webkit/glue/webframeloaderclient_impl.h @@ -15,10 +15,10 @@ MSVC_POP_WARNING(); #include "build/build_config.h" #include "base/scoped_ptr.h" +#include "base/time.h" #include "googleurl/src/gurl.h" #include "webkit/glue/webview_delegate.h" #include "webkit/glue/window_open_disposition.h" - namespace WebCore { class Frame; class HTMLFormElement; @@ -30,6 +30,7 @@ class NetAgentImpl; class WebFrameImpl; class WebPluginContainer; + class WebFrameLoaderClient : public WebCore::FrameLoaderClient { public: WebFrameLoaderClient(WebFrameImpl* webframe); diff --git a/webkit/glue/webview_delegate.h b/webkit/glue/webview_delegate.h index cf6abaf0..482a24b 100644 --- a/webkit/glue/webview_delegate.h +++ b/webkit/glue/webview_delegate.h @@ -29,6 +29,7 @@ #include <vector> #include "webkit/glue/context_menu.h" +#include "webkit/glue/webdatasource.h" #include "webkit/glue/webwidget_delegate.h" namespace gfx { @@ -58,15 +59,6 @@ class WebWidget; class WebWorker; class WebWorkerClient; -enum WebNavigationType { - WebNavigationTypeLinkClicked, - WebNavigationTypeFormSubmitted, - WebNavigationTypeBackForward, - WebNavigationTypeReload, - WebNavigationTypeFormResubmitted, - WebNavigationTypeOther -}; - enum NavigationGesture { NavigationGestureUser, // User initiated navigation/load. This is not // currently used due to the untrustworthy nature |