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

Unified Diff: content/browser/frame_host/navigation_controller_impl.cc

Issue 2174293002: NonValidatingReload: Monitor reload operations in NavigationControllerImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: [rebase] Created 4 years, 3 months 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 side-by-side diff with in-line comments
Download patch
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 4466dab2ceac18a10488eb60bcbf483eef58544b..aadc9ace33a52082e4fd496f85ce0976c324d47a 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(
// is_in_page must be computed before the entry gets committed.
details->is_in_page = is_navigation_within_page;
+ // 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,

Powered by Google App Engine
This is Rietveld 408576698