summaryrefslogtreecommitdiffstats
path: root/webkit/glue/webframeloaderclient_impl.cc
diff options
context:
space:
mode:
authordavemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-03 21:39:26 +0000
committerdavemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-03 21:39:26 +0000
commitc20210e6a0c40bce1781a42abf81b44ba627f2a9 (patch)
treee658b8111109145bc450603ac69cb0de3dd47eb2 /webkit/glue/webframeloaderclient_impl.cc
parent601b54022e6232875c8b24501e425b450f071217 (diff)
downloadchromium_src-c20210e6a0c40bce1781a42abf81b44ba627f2a9.zip
chromium_src-c20210e6a0c40bce1781a42abf81b44ba627f2a9.tar.gz
chromium_src-c20210e6a0c40bce1781a42abf81b44ba627f2a9.tar.bz2
- Added support for keeping track of load times.
For each document loaded we record the time the page was requested by the user (or as close as we can get to that), the time the load process started, the time the document and it's dependent resources (scripts) have been loaded (before onload()) and the time all the document's resources have been loaded. We use this data for two things: 1) We histogram the deltas between the time marks 2) We expose the times to javascript running on the page which was loaded Review URL: http://codereview.chromium.org/42527 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13116 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/webframeloaderclient_impl.cc')
-rw-r--r--webkit/glue/webframeloaderclient_impl.cc51
1 files changed, 30 insertions, 21 deletions
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);