Index: content/browser/frame_host/navigation_controller_impl.cc |
diff --git a/content/browser/frame_host/navigation_controller_impl.cc b/content/browser/frame_host/navigation_controller_impl.cc |
index c0ddb1b926e0af03b8758c235c8e8a4026164be5..011466ace48a9eec6b67e29b0eb2a4d73f5a259f 100644 |
--- a/content/browser/frame_host/navigation_controller_impl.cc |
+++ b/content/browser/frame_host/navigation_controller_impl.cc |
@@ -226,7 +226,8 @@ NavigationControllerImpl::NavigationControllerImpl( |
in_navigate_to_pending_entry_(false), |
pending_reload_(ReloadType::NONE), |
get_timestamp_callback_(base::Bind(&base::Time::Now)), |
- screenshot_manager_(new NavigationEntryScreenshotManager(this)) { |
+ screenshot_manager_(new NavigationEntryScreenshotManager(this)), |
+ last_committed_reload_type_(ReloadType::NONE) { |
DCHECK(browser_context_); |
} |
@@ -329,6 +330,28 @@ void NavigationControllerImpl::ReloadInternal(bool check_for_repost, |
if (!entry) |
return; |
+ // Check if previous navigation was a reload to track consecutive reload |
+ // operations. |
+ if (last_committed_reload_type_ != ReloadType::NONE) { |
+ DCHECK(!last_committed_reload_time_.is_null()); |
+ base::Time now = |
+ time_smoother_.GetSmoothedTime(get_timestamp_callback_.Run()); |
+ DCHECK_GT(now, last_committed_reload_time_); |
+ if (!last_committed_reload_time_.is_null() && |
+ now > last_committed_reload_time_) { |
+ base::TimeDelta delta = now - last_committed_reload_time_; |
+ UMA_HISTOGRAM_MEDIUM_TIMES("Navigation.Reload.ReloadToReloadDuration", |
+ delta); |
+ if (last_committed_reload_type_ == ReloadType::MAIN_RESOURCE) { |
+ UMA_HISTOGRAM_MEDIUM_TIMES( |
+ "Navigation.Reload.ReloadMainResourceToReloadDuration", delta); |
+ } |
+ } |
+ } |
+ |
+ // Set ReloadType for |entry| in order to check it at commit time. |
+ entry->set_reload_type(reload_type); |
+ |
if (g_check_for_repost && check_for_repost && |
entry->GetHasPostData()) { |
// The user is asking to reload a page with POST data. Prompt to make sure |
@@ -802,6 +825,20 @@ bool NavigationControllerImpl::RendererDidNavigate( |
details->is_in_page = IsURLInPageNavigation(params.url, params.origin, |
params.was_within_same_page, rfh); |
+ // Save reload type and timestamp for a reload navigation to detect |
+ // consecutive reloads when the next reload is requested. |
+ if (PendingEntryMatchesHandle(rfh->navigation_handle())) { |
+ if (pending_entry_->reload_type() != ReloadType::NONE) { |
+ last_committed_reload_type_ = pending_entry_->reload_type(); |
+ last_committed_reload_time_ = |
+ time_smoother_.GetSmoothedTime(get_timestamp_callback_.Run()); |
+ } else if (!pending_entry_->is_renderer_initiated() || |
+ params.gesture == NavigationGestureUser) { |
+ last_committed_reload_type_ = ReloadType::NONE; |
+ last_committed_reload_time_ = base::Time(); |
+ } |
+ } |
+ |
switch (details->type) { |
case NAVIGATION_TYPE_NEW_PAGE: |
RendererDidNavigateToNewPage(rfh, params, details->is_in_page, |