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

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: cleanup 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 4b1ba60e089679a1a873c195644e4dc35bdfdf7c..8ed3ece31beadd32b3809b05a7ca8b1b0de8a149 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,22 @@ void NavigationControllerImpl::ReloadInternal(bool check_for_repost,
if (!entry)
return;
+ // Check if previous navigation was reload to track reload operations.
Charlie Reis 2016/09/19 22:23:51 nit: was a reload, to track consecutive reload ope
Takashi Toyoshima 2016/09/26 12:23:34 Done.
+ if (last_committed_reload_type_ != ReloadType::NONE) {
+ base::Time now =
+ time_smoother_.GetSmoothedTime(get_timestamp_callback_.Run());
Charlie Reis 2016/09/19 22:23:51 nit: Wrong indent. git cl format can take care of
Takashi Toyoshima 2016/09/26 12:23:34 Oops. Sorry, I forgot to run it for this patch set
+ base::TimeDelta delta = now - last_committed_reload_time_;
Charlie Reis 2016/09/19 22:23:51 Maybe include a sanity check that last_committed_r
Takashi Toyoshima 2016/09/26 12:23:34 Done.
+ 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);
Charlie Reis 2016/09/19 22:23:51 Side note: While debugging I discovered (much to m
Takashi Toyoshima 2016/09/26 12:23:34 Yeah, I noticed this problem too. I think it's fin
+
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 +819,27 @@ bool NavigationControllerImpl::RendererDidNavigate(
details->is_in_page = IsURLInPageNavigation(params.url, params.origin,
params.was_within_same_page, rfh);
+ // Update reload information to track user initiated reload operations for the
+ // same content.
+ if (pending_entry_ && pending_entry_->GetUniqueID() == params.nav_entry_id) {
Charlie Reis 2016/09/19 22:23:51 I would suggest using PendingEntryMatchesHandle in
Takashi Toyoshima 2016/09/26 12:23:34 Done. Is my fix correct? I use rfh->navigation_han
Charlie Reis 2016/09/26 23:34:39 Yes, that looks right to me, thanks.
+ // If navigation was initiated by |pending_entry_|, save reload type and
+ // timestamp to check when the next reload is requested.
+ last_committed_reload_type_ = pending_entry_->reload_type();
+ last_committed_reload_time_ = pending_entry_->GetTimestamp();
Charlie Reis 2016/09/19 22:23:51 This won't be the right timestamp, because it does
Takashi Toyoshima 2016/09/26 12:23:34 Done.
+ } else if ((details->type == NAVIGATION_TYPE_EXISTING_PAGE &&
+ params.gesture == NavigationGestureUser) ||
+ (details->type != NAVIGATION_TYPE_EXISTING_PAGE &&
+ details->type != NAVIGATION_TYPE_AUTO_SUBFRAME)) {
Charlie Reis 2016/09/19 22:23:51 This doesn't look like the right condition. We wa
Takashi Toyoshima 2016/09/26 12:23:34 Done.
+ // Same page navigation initiated by user action, e.g. clicking an anchor to
+ // the same URL, should reset the reload information as we do for other
+ // user initiated navigation to a different page.
+ // But we do not reset if the same page navigation was initiated without any
+ // user action. For instance, location.reload() should not reset it.
+ // We also ignore subframe navigations automatically performed inside the
+ // page.
+ last_committed_reload_type_ = ReloadType::NONE;
Charlie Reis 2016/09/19 22:23:51 Also clear the timestamp, to avoid having old data
Takashi Toyoshima 2016/09/26 12:23:33 Done.
+ }
+
switch (details->type) {
case NAVIGATION_TYPE_NEW_PAGE:
RendererDidNavigateToNewPage(rfh, params, details->is_in_page,

Powered by Google App Engine
This is Rietveld 408576698