Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: chrome/browser/ui/search/search_tab_helper.cc

Issue 112453004: InstantExtended: record Instant NTP load times. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/search/search_tab_helper.h" 5 #include "chrome/browser/ui/search/search_tab_helper.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 11 matching lines...) Expand all
22 #include "chrome/browser/ui/app_list/app_list_util.h" 22 #include "chrome/browser/ui/app_list/app_list_util.h"
23 #include "chrome/browser/ui/browser.h" 23 #include "chrome/browser/ui/browser.h"
24 #include "chrome/browser/ui/browser_finder.h" 24 #include "chrome/browser/ui/browser_finder.h"
25 #include "chrome/browser/ui/browser_navigator.h" 25 #include "chrome/browser/ui/browser_navigator.h"
26 #include "chrome/browser/ui/browser_window.h" 26 #include "chrome/browser/ui/browser_window.h"
27 #include "chrome/browser/ui/omnibox/location_bar.h" 27 #include "chrome/browser/ui/omnibox/location_bar.h"
28 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" 28 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h"
29 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" 29 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h"
30 #include "chrome/browser/ui/omnibox/omnibox_view.h" 30 #include "chrome/browser/ui/omnibox/omnibox_view.h"
31 #include "chrome/browser/ui/search/search_ipc_router_policy_impl.h" 31 #include "chrome/browser/ui/search/search_ipc_router_policy_impl.h"
32 #include "chrome/browser/ui/tab_contents/core_tab_helper.h"
32 #include "chrome/browser/ui/tabs/tab_strip_model.h" 33 #include "chrome/browser/ui/tabs/tab_strip_model.h"
33 #include "chrome/browser/ui/tabs/tab_strip_model_utils.h" 34 #include "chrome/browser/ui/tabs/tab_strip_model_utils.h"
34 #include "chrome/browser/ui/webui/ntp/ntp_user_data_logger.h" 35 #include "chrome/browser/ui/webui/ntp/ntp_user_data_logger.h"
35 #include "chrome/common/url_constants.h" 36 #include "chrome/common/url_constants.h"
36 #include "content/public/browser/navigation_controller.h" 37 #include "content/public/browser/navigation_controller.h"
37 #include "content/public/browser/navigation_details.h" 38 #include "content/public/browser/navigation_details.h"
38 #include "content/public/browser/navigation_entry.h" 39 #include "content/public/browser/navigation_entry.h"
39 #include "content/public/browser/navigation_type.h" 40 #include "content/public/browser/navigation_type.h"
40 #include "content/public/browser/render_process_host.h" 41 #include "content/public/browser/render_process_host.h"
41 #include "content/public/browser/user_metrics.h" 42 #include "content/public/browser/user_metrics.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 if (!contents) 117 if (!contents)
117 return; 118 return;
118 119
119 Browser* browser = chrome::FindBrowserWithWebContents(contents); 120 Browser* browser = chrome::FindBrowserWithWebContents(contents);
120 if (!browser) 121 if (!browser)
121 return; 122 return;
122 browser->OnWebContentsInstantSupportDisabled(contents); 123 browser->OnWebContentsInstantSupportDisabled(contents);
123 #endif 124 #endif
124 } 125 }
125 126
127 // Called when an NTP finishes loading. If the load start time was noted,
128 // calculates and logs the total load time.
129 void RecordNewTabLoadTime(content::WebContents* contents) {
130 CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(contents);
131 if (core_tab_helper->new_tab_start_time().is_null())
132 return;
133
134 base::TimeDelta duration =
135 base::TimeTicks::Now() - core_tab_helper->new_tab_start_time();
136 UMA_HISTOGRAM_TIMES("Tab.NewTabOnload", duration);
137 core_tab_helper->set_new_tab_start_time(base::TimeTicks());
Jered 2014/01/02 20:12:41 Why are you resetting the start time here?
samarth 2014/01/04 01:22:38 This is because not all code paths that open the N
138 }
139
126 } // namespace 140 } // namespace
127 141
128 SearchTabHelper::SearchTabHelper(content::WebContents* web_contents) 142 SearchTabHelper::SearchTabHelper(content::WebContents* web_contents)
129 : WebContentsObserver(web_contents), 143 : WebContentsObserver(web_contents),
130 is_search_enabled_(chrome::IsInstantExtendedAPIEnabled()), 144 is_search_enabled_(chrome::IsInstantExtendedAPIEnabled()),
131 user_input_in_progress_(false), 145 user_input_in_progress_(false),
132 web_contents_(web_contents), 146 web_contents_(web_contents),
133 ipc_router_(web_contents, this, 147 ipc_router_(web_contents, this,
134 make_scoped_ptr(new SearchIPCRouterPolicyImpl(web_contents)) 148 make_scoped_ptr(new SearchIPCRouterPolicyImpl(web_contents))
135 .PassAs<SearchIPCRouter::Policy>()), 149 .PassAs<SearchIPCRouter::Policy>()),
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 RedirectToLocalNTP(); 297 RedirectToLocalNTP();
284 RecordCacheableNTPLoadHistogram(false); 298 RecordCacheableNTPLoadHistogram(false);
285 } 299 }
286 } 300 }
287 301
288 void SearchTabHelper::DidFinishLoad( 302 void SearchTabHelper::DidFinishLoad(
289 int64 /* frame_id */, 303 int64 /* frame_id */,
290 const GURL& /* validated_url */, 304 const GURL& /* validated_url */,
291 bool is_main_frame, 305 bool is_main_frame,
292 content::RenderViewHost* /* render_view_host */) { 306 content::RenderViewHost* /* render_view_host */) {
293 if (is_main_frame) 307 if (is_main_frame) {
308 if (chrome::IsInstantNTP(web_contents_))
309 RecordNewTabLoadTime(web_contents_);
310
294 DetermineIfPageSupportsInstant(); 311 DetermineIfPageSupportsInstant();
312 }
295 } 313 }
296 314
297 void SearchTabHelper::NavigationEntryCommitted( 315 void SearchTabHelper::NavigationEntryCommitted(
298 const content::LoadCommittedDetails& load_details) { 316 const content::LoadCommittedDetails& load_details) {
299 if (!is_search_enabled_) 317 if (!is_search_enabled_)
300 return; 318 return;
301 319
302 if (!load_details.is_main_frame) 320 if (!load_details.is_main_frame)
303 return; 321 return;
304 322
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 void SearchTabHelper::RedirectToLocalNTP() { 586 void SearchTabHelper::RedirectToLocalNTP() {
569 // Extra parentheses to declare a variable. 587 // Extra parentheses to declare a variable.
570 content::NavigationController::LoadURLParams load_params( 588 content::NavigationController::LoadURLParams load_params(
571 (GURL(chrome::kChromeSearchLocalNtpUrl))); 589 (GURL(chrome::kChromeSearchLocalNtpUrl)));
572 load_params.referrer = content::Referrer(); 590 load_params.referrer = content::Referrer();
573 load_params.transition_type = content::PAGE_TRANSITION_SERVER_REDIRECT; 591 load_params.transition_type = content::PAGE_TRANSITION_SERVER_REDIRECT;
574 // Don't push a history entry. 592 // Don't push a history entry.
575 load_params.should_replace_current_entry = true; 593 load_params.should_replace_current_entry = true;
576 web_contents_->GetController().LoadURLWithParams(load_params); 594 web_contents_->GetController().LoadURLWithParams(load_params);
577 } 595 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698