summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-16 19:50:56 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-16 19:50:56 +0000
commited3fb034eb4b7da69bbc4f3e3da47093dabc481e (patch)
treed08b2837ab8b05b98fef6990edd26a9d00465589 /chrome/renderer
parent5eb55c2f42f70fe544a04d200cdd059377d310f7 (diff)
downloadchromium_src-ed3fb034eb4b7da69bbc4f3e3da47093dabc481e.zip
chromium_src-ed3fb034eb4b7da69bbc4f3e3da47093dabc481e.tar.gz
chromium_src-ed3fb034eb4b7da69bbc4f3e3da47093dabc481e.tar.bz2
Extract load times from WebDataSource. Move them to NavigationState.
Move PasswordForm into the webkit_glue namespace. TEST=none BUG=10041 R=brettw Review URL: http://codereview.chromium.org/126190 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18515 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r--chrome/renderer/loadtimes_extension_bindings.cc19
-rw-r--r--chrome/renderer/navigation_state.h138
-rw-r--r--chrome/renderer/render_view.cc129
-rw-r--r--chrome/renderer/render_view.h4
4 files changed, 180 insertions, 110 deletions
diff --git a/chrome/renderer/loadtimes_extension_bindings.cc b/chrome/renderer/loadtimes_extension_bindings.cc
index 6acbbe6..d3ed834 100644
--- a/chrome/renderer/loadtimes_extension_bindings.cc
+++ b/chrome/renderer/loadtimes_extension_bindings.cc
@@ -6,6 +6,7 @@
#include "base/time.h"
#include "v8/include/v8.h"
+#include "chrome/renderer/navigation_state.h"
#include "webkit/glue/webframe.h"
#include "webkit/glue/webdatasource.h"
@@ -55,27 +56,29 @@ class LoadTimesExtensionWrapper : public v8::Extension {
}
static v8::Handle<v8::Value> GetLoadTimes(const v8::Arguments& args) {
- WebFrame* win_frame = WebFrame::RetrieveFrameForEnteredContext();
- if (win_frame) {
- WebDataSource* data_source = win_frame->GetDataSource();
+ WebFrame* frame = WebFrame::RetrieveFrameForEnteredContext();
+ if (frame) {
+ WebDataSource* data_source = frame->GetDataSource();
+ NavigationState* navigation_state =
+ NavigationState::FromDataSource(data_source);
if (data_source) {
v8::Local<v8::Object> load_times = v8::Object::New();
load_times->Set(
v8::String::New("requestTime"),
- v8::Number::New(data_source->GetRequestTime().ToDoubleT()));
+ v8::Number::New(navigation_state->request_time().ToDoubleT()));
load_times->Set(
v8::String::New("startLoadTime"),
- v8::Number::New(data_source->GetStartLoadTime().ToDoubleT()));
+ v8::Number::New(navigation_state->start_load_time().ToDoubleT()));
load_times->Set(
v8::String::New("finishDocumentLoadTime"),
v8::Number::New(
- data_source->GetFinishDocumentLoadTime().ToDoubleT()));
+ navigation_state->finish_document_load_time().ToDoubleT()));
load_times->Set(
v8::String::New("finishLoadTime"),
- v8::Number::New(data_source->GetFinishLoadTime().ToDoubleT()));
+ v8::Number::New(navigation_state->finish_load_time().ToDoubleT()));
load_times->Set(
v8::String::New("firstLayoutTime"),
- v8::Number::New(data_source->GetFirstLayoutTime().ToDoubleT()));
+ v8::Number::New(navigation_state->first_layout_time().ToDoubleT()));
load_times->Set(
v8::String::New("navigationType"),
v8::String::New(
diff --git a/chrome/renderer/navigation_state.h b/chrome/renderer/navigation_state.h
new file mode 100644
index 0000000..eabe25f6
--- /dev/null
+++ b/chrome/renderer/navigation_state.h
@@ -0,0 +1,138 @@
+// 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 CHROME_RENDERER_NAVIGATION_STATE_H_
+#define CHROME_RENDERER_NAVIGATION_STATE_H_
+
+#include "base/scoped_ptr.h"
+#include "base/time.h"
+#include "chrome/common/page_transition_types.h"
+#include "webkit/glue/password_form.h"
+#include "webkit/glue/searchable_form_data.h"
+#include "webkit/glue/webdatasource.h"
+
+// The RenderView stores an instance of this class in the "extra data" of each
+// WebDataSource (see RenderView::DidCreateDataSource).
+class NavigationState : public WebDataSource::ExtraData {
+ public:
+ static NavigationState* CreateBrowserInitiated(
+ int32 pending_page_id,
+ PageTransition::Type transition_type,
+ base::Time request_time) {
+ return new NavigationState(transition_type, request_time, false,
+ pending_page_id);
+ }
+
+ static NavigationState* CreateContentInitiated() {
+ // We assume navigations initiated by content are link clicks.
+ return new NavigationState(PageTransition::LINK, base::Time(), true, -1);
+ }
+
+ static NavigationState* FromDataSource(WebDataSource* ds) {
+ return static_cast<NavigationState*>(ds->GetExtraData());
+ }
+
+ // Contains the page_id for this navigation or -1 if there is none yet.
+ int32 pending_page_id() const { return pending_page_id_; }
+
+ // Is this a new navigation?
+ bool is_new_navigation() const { return pending_page_id_ == -1; }
+
+ // Contains the transition type that the browser specified when it
+ // initiated the load.
+ PageTransition::Type transition_type() const { return transition_type_; }
+ void set_transition_type(PageTransition::Type type) {
+ transition_type_ = type;
+ }
+
+ // The time that this navigation was requested.
+ const base::Time& request_time() const {
+ return request_time_;
+ }
+ void set_request_time(const base::Time& value) {
+ request_time_ = value;
+ }
+
+ // The time that this navigation actually started.
+ const base::Time& start_load_time() const {
+ return start_load_time_;
+ }
+ void set_start_load_time(const base::Time& value) {
+ start_load_time_ = value;
+ }
+
+ // The time that the document finished loading.
+ const base::Time& finish_document_load_time() const {
+ return finish_document_load_time_;
+ }
+ void set_finish_document_load_time(const base::Time& value) {
+ finish_document_load_time_ = value;
+ }
+
+ // The time that the document and all subresources finished loading.
+ const base::Time& finish_load_time() const {
+ return finish_load_time_;
+ }
+ void set_finish_load_time(const base::Time& value) {
+ finish_load_time_ = value;
+ }
+
+ // The time that layout first ran after a new navigation.
+ const base::Time& first_layout_time() const {
+ return first_layout_time_;
+ }
+ void set_first_layout_time(const base::Time& value) {
+ first_layout_time_ = value;
+ }
+
+ // True if we have already processed the "DidCommitLoad" event for this
+ // request. Used by session history.
+ bool request_committed() const { return request_committed_; }
+ void set_request_committed(bool value) { request_committed_ = value; }
+
+ // True if this navigation was not initiated via WebFrame::LoadRequest.
+ bool is_content_initiated() const { return is_content_initiated_; }
+
+ webkit_glue::SearchableFormData* searchable_form_data() const {
+ return searchable_form_data_.get();
+ }
+ void set_searchable_form_data(webkit_glue::SearchableFormData* data) {
+ searchable_form_data_.reset(data);
+ }
+
+ webkit_glue::PasswordForm* password_form_data() const {
+ return password_form_data_.get();
+ }
+ void set_password_form_data(webkit_glue::PasswordForm* data) {
+ password_form_data_.reset(data);
+ }
+
+ private:
+ NavigationState(PageTransition::Type transition_type,
+ const base::Time& request_time,
+ bool is_content_initiated,
+ int32 pending_page_id)
+ : transition_type_(transition_type),
+ request_time_(request_time),
+ request_committed_(false),
+ is_content_initiated_(is_content_initiated),
+ pending_page_id_(pending_page_id) {
+ }
+
+ PageTransition::Type transition_type_;
+ base::Time request_time_;
+ base::Time start_load_time_;
+ base::Time finish_document_load_time_;
+ base::Time finish_load_time_;
+ base::Time first_layout_time_;
+ bool request_committed_;
+ bool is_content_initiated_;
+ int32 pending_page_id_;
+ scoped_ptr<webkit_glue::SearchableFormData> searchable_form_data_;
+ scoped_ptr<webkit_glue::PasswordForm> password_form_data_;
+
+ DISALLOW_COPY_AND_ASSIGN(NavigationState);
+};
+
+#endif // CHROME_RENDERER_NAVIGATION_STATE_H_
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 7c2bbf1..b6d29a2 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -39,6 +39,7 @@
#include "chrome/renderer/localized_error.h"
#include "chrome/renderer/media/audio_renderer_impl.h"
#include "chrome/renderer/media/buffered_data_source.h"
+#include "chrome/renderer/navigation_state.h"
#include "chrome/renderer/print_web_view_helper.h"
#include "chrome/renderer/render_process.h"
#include "chrome/renderer/renderer_logging.h"
@@ -90,6 +91,7 @@
using base::Time;
using base::TimeDelta;
using webkit_glue::AutofillForm;
+using webkit_glue::PasswordForm;
using webkit_glue::PasswordFormDomManager;
using webkit_glue::SearchableFormData;
using WebKit::WebConsoleMessage;
@@ -141,87 +143,6 @@ static const char* const kUnreachableWebDataURL =
static const char* const kBackForwardNavigationScheme = "history";
-// Associated with browser-initiated navigations to hold tracking data.
-class RenderView::NavigationState : public WebDataSource::ExtraData {
- public:
- static NavigationState* CreateBrowserInitiated(
- int32 pending_page_id,
- PageTransition::Type transition_type,
- Time request_time) {
- return new NavigationState(transition_type, request_time, false,
- pending_page_id);
- }
-
- static NavigationState* CreateContentInitiated() {
- // We assume navigations initiated by content are link clicks.
- return new NavigationState(PageTransition::LINK, Time(), true, -1);
- }
-
- static NavigationState* FromDataSource(WebDataSource* ds) {
- return static_cast<NavigationState*>(ds->GetExtraData());
- }
-
- // Contains the page_id for this navigation or -1 if there is none yet.
- int32 pending_page_id() const { return pending_page_id_; }
-
- // Is this a new navigation?
- bool is_new_navigation() const { return pending_page_id_ == -1; }
-
- // Contains the transition type that the browser specified when it
- // initiated the load.
- PageTransition::Type transition_type() const { return transition_type_; }
- void set_transition_type(PageTransition::Type type) {
- transition_type_ = type;
- }
-
- // The time that this navigation was requested.
- const Time& request_time() const { return request_time_; }
-
- // True if we have already processed the "DidCommitLoad" event for this
- // request. Used by session history.
- bool request_committed() const { return request_committed_; }
- void set_request_committed(bool value) { request_committed_ = value; }
-
- // True if this navigation was not initiated via WebFrame::LoadRequest.
- bool is_content_initiated() const { return is_content_initiated_; }
-
- SearchableFormData* searchable_form_data() const {
- return searchable_form_data_.get();
- }
- void set_searchable_form_data(SearchableFormData* data) {
- searchable_form_data_.reset(data);
- }
-
- PasswordForm* password_form_data() const {
- return password_form_data_.get();
- }
- void set_password_form_data(PasswordForm* data) {
- password_form_data_.reset(data);
- }
-
- private:
- NavigationState(PageTransition::Type transition_type,
- const Time& request_time,
- bool is_content_initiated,
- int32 pending_page_id)
- : transition_type_(transition_type),
- request_time_(request_time),
- request_committed_(false),
- is_content_initiated_(is_content_initiated),
- pending_page_id_(pending_page_id) {
- }
-
- PageTransition::Type transition_type_;
- Time request_time_;
- bool request_committed_;
- bool is_content_initiated_;
- int32 pending_page_id_;
- scoped_ptr<SearchableFormData> searchable_form_data_;
- scoped_ptr<PasswordForm> password_form_data_;
-
- DISALLOW_COPY_AND_ASSIGN(NavigationState);
-};
-
///////////////////////////////////////////////////////////////////////////////
RenderView::RenderView(RenderThreadBase* render_thread)
@@ -1119,24 +1040,28 @@ void RenderView::DidStartProvisionalLoadForFrame(
WebView* webview,
WebFrame* frame,
NavigationGesture gesture) {
- if (webview->GetMainFrame() == frame) {
+ WebDataSource* ds = frame->GetProvisionalDataSource();
+ NavigationState* navigation_state = NavigationState::FromDataSource(ds);
+
+ navigation_state->set_start_load_time(Time::Now());
+
+ // Update the request time if WebKit has better knowledge of it.
+ if (navigation_state->request_time().is_null()) {
+ double event_time = ds->GetTriggeringEventTime();
+ if (event_time != 0.0)
+ navigation_state->set_request_time(Time::FromDoubleT(event_time));
+ }
+
+ bool is_top_most = !frame->GetParent();
+ if (is_top_most) {
navigation_gesture_ = gesture;
// Make sure redirect tracking state is clear for the new load.
completed_client_redirect_src_ = GURL();
}
- // We may have better knowledge of when this navigation was requested.
- WebDataSource* ds = frame->GetProvisionalDataSource();
- if (ds) {
- NavigationState* navigation_state = NavigationState::FromDataSource(ds);
- if (!navigation_state->request_time().is_null())
- ds->SetRequestTime(navigation_state->request_time());
- }
-
Send(new ViewHostMsg_DidStartProvisionalLoadForFrame(
- routing_id_, webview->GetMainFrame() == frame,
- frame->GetProvisionalDataSource()->GetRequest().GetURL()));
+ routing_id_, is_top_most, ds->GetRequest().GetURL()));
}
bool RenderView::DidLoadResourceFromMemoryCache(WebView* webview,
@@ -2834,12 +2759,16 @@ void RenderView::OnExtensionResponse(int request_id,
// so firstLayout can be 0.
void RenderView::DumpLoadHistograms() const {
WebFrame* main_frame = webview()->GetMainFrame();
- WebDataSource* ds = main_frame->GetDataSource();
- Time request_time = ds->GetRequestTime();
- Time start_load_time = ds->GetStartLoadTime();
- Time finish_document_load_time = ds->GetFinishDocumentLoadTime();
- Time finish_load_time = ds->GetFinishLoadTime();
- Time first_layout_time = ds->GetFirstLayoutTime();
+ NavigationState* navigation_state =
+ NavigationState::FromDataSource(main_frame->GetDataSource());
+
+ Time request_time = navigation_state->request_time();
+ Time start_load_time = navigation_state->start_load_time();
+ Time finish_document_load_time =
+ navigation_state->finish_document_load_time();
+ Time finish_load_time = navigation_state->finish_load_time();
+ Time first_layout_time = navigation_state->first_layout_time();
+
TimeDelta request_to_start = start_load_time - request_time;
TimeDelta start_to_finish_doc = finish_document_load_time - start_load_time;
TimeDelta finish_doc_to_finish =
@@ -2854,8 +2783,8 @@ void RenderView::DumpLoadHistograms() const {
UMA_HISTOGRAM_MEDIUM_TIMES("Renderer2.RequestToStart", request_to_start);
UMA_HISTOGRAM_CLIPPED_TIMES(
FieldTrial::MakeName("Renderer2.RequestToFinish_L", "DnsImpact").data(),
- request_to_finish, base::TimeDelta::FromMilliseconds(10),
- base::TimeDelta::FromMinutes(10), 100);
+ request_to_finish, TimeDelta::FromMilliseconds(10),
+ TimeDelta::FromMinutes(10), 100);
if (request_to_first_layout.ToInternalValue() >= 0) {
UMA_HISTOGRAM_MEDIUM_TIMES("Renderer2.RequestToFirstLayout",
request_to_first_layout);
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index f1108eb..3a710d7 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -47,8 +47,9 @@ class DebugMessageHandler;
class DevToolsAgent;
class DevToolsClient;
class FilePath;
-class PrintWebViewHelper;
class GURL;
+class NavigationState;
+class PrintWebViewHelper;
class RenderThread;
class ResourceDispatcher;
class WebError;
@@ -788,7 +789,6 @@ class RenderView : public RenderWidget,
// the WebDataSource::ExtraData attribute. We use pending_navigation_state_
// as a temporary holder for the state until the WebDataSource corresponding
// to the new navigation is created. See DidCreateDataSource.
- class NavigationState;
scoped_ptr<NavigationState> pending_navigation_state_;
// Need for printing