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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 /* 5 /*
6 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 6 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * 10 *
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 pending_entry_index_(-1), 219 pending_entry_index_(-1),
220 transient_entry_index_(-1), 220 transient_entry_index_(-1),
221 delegate_(delegate), 221 delegate_(delegate),
222 max_restored_page_id_(-1), 222 max_restored_page_id_(-1),
223 ssl_manager_(this), 223 ssl_manager_(this),
224 needs_reload_(false), 224 needs_reload_(false),
225 is_initial_navigation_(true), 225 is_initial_navigation_(true),
226 in_navigate_to_pending_entry_(false), 226 in_navigate_to_pending_entry_(false),
227 pending_reload_(ReloadType::NONE), 227 pending_reload_(ReloadType::NONE),
228 get_timestamp_callback_(base::Bind(&base::Time::Now)), 228 get_timestamp_callback_(base::Bind(&base::Time::Now)),
229 screenshot_manager_(new NavigationEntryScreenshotManager(this)) { 229 screenshot_manager_(new NavigationEntryScreenshotManager(this)),
230 last_committed_reload_type_(ReloadType::NONE) {
230 DCHECK(browser_context_); 231 DCHECK(browser_context_);
231 } 232 }
232 233
233 NavigationControllerImpl::~NavigationControllerImpl() { 234 NavigationControllerImpl::~NavigationControllerImpl() {
234 DiscardNonCommittedEntriesInternal(); 235 DiscardNonCommittedEntriesInternal();
235 } 236 }
236 237
237 WebContents* NavigationControllerImpl::GetWebContents() const { 238 WebContents* NavigationControllerImpl::GetWebContents() const {
238 return delegate_->GetWebContents(); 239 return delegate_->GetWebContents();
239 } 240 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 if (current_index != -1) { 323 if (current_index != -1) {
323 entry = GetEntryAtIndex(current_index); 324 entry = GetEntryAtIndex(current_index);
324 } 325 }
325 } 326 }
326 327
327 // If we are no where, then we can't reload. TODO(darin): We should add a 328 // If we are no where, then we can't reload. TODO(darin): We should add a
328 // CanReload method. 329 // CanReload method.
329 if (!entry) 330 if (!entry)
330 return; 331 return;
331 332
333 // 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.
334 if (last_committed_reload_type_ != ReloadType::NONE) {
335 base::Time now =
336 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
337 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.
338 UMA_HISTOGRAM_MEDIUM_TIMES("Navigation.Reload.ReloadToReloadDuration",
339 delta);
340 if (last_committed_reload_type_ == ReloadType::MAIN_RESOURCE) {
341 UMA_HISTOGRAM_MEDIUM_TIMES(
342 "Navigation.Reload.ReloadMainResourceToReloadDuration", delta);
343 }
344 }
345
346 // Set ReloadType for |entry| in order to check it at commit time.
347 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
348
332 if (g_check_for_repost && check_for_repost && 349 if (g_check_for_repost && check_for_repost &&
333 entry->GetHasPostData()) { 350 entry->GetHasPostData()) {
334 // The user is asking to reload a page with POST data. Prompt to make sure 351 // The user is asking to reload a page with POST data. Prompt to make sure
335 // they really want to do this. If they do, the dialog will call us back 352 // they really want to do this. If they do, the dialog will call us back
336 // with check_for_repost = false. 353 // with check_for_repost = false.
337 delegate_->NotifyBeforeFormRepostWarningShow(); 354 delegate_->NotifyBeforeFormRepostWarningShow();
338 355
339 pending_reload_ = reload_type; 356 pending_reload_ = reload_type;
340 delegate_->ActivateAndShowRepostFormWarningDialog(); 357 delegate_->ActivateAndShowRepostFormWarningDialog();
341 } else { 358 } else {
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 // The renderer tells us whether the navigation replaces the current entry. 812 // The renderer tells us whether the navigation replaces the current entry.
796 details->did_replace_entry = params.should_replace_current_entry; 813 details->did_replace_entry = params.should_replace_current_entry;
797 814
798 // Do navigation-type specific actions. These will make and commit an entry. 815 // Do navigation-type specific actions. These will make and commit an entry.
799 details->type = ClassifyNavigation(rfh, params); 816 details->type = ClassifyNavigation(rfh, params);
800 817
801 // is_in_page must be computed before the entry gets committed. 818 // is_in_page must be computed before the entry gets committed.
802 details->is_in_page = IsURLInPageNavigation(params.url, params.origin, 819 details->is_in_page = IsURLInPageNavigation(params.url, params.origin,
803 params.was_within_same_page, rfh); 820 params.was_within_same_page, rfh);
804 821
822 // Update reload information to track user initiated reload operations for the
823 // same content.
824 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.
825 // If navigation was initiated by |pending_entry_|, save reload type and
826 // timestamp to check when the next reload is requested.
827 last_committed_reload_type_ = pending_entry_->reload_type();
828 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.
829 } else if ((details->type == NAVIGATION_TYPE_EXISTING_PAGE &&
830 params.gesture == NavigationGestureUser) ||
831 (details->type != NAVIGATION_TYPE_EXISTING_PAGE &&
832 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.
833 // Same page navigation initiated by user action, e.g. clicking an anchor to
834 // the same URL, should reset the reload information as we do for other
835 // user initiated navigation to a different page.
836 // But we do not reset if the same page navigation was initiated without any
837 // user action. For instance, location.reload() should not reset it.
838 // We also ignore subframe navigations automatically performed inside the
839 // page.
840 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.
841 }
842
805 switch (details->type) { 843 switch (details->type) {
806 case NAVIGATION_TYPE_NEW_PAGE: 844 case NAVIGATION_TYPE_NEW_PAGE:
807 RendererDidNavigateToNewPage(rfh, params, details->is_in_page, 845 RendererDidNavigateToNewPage(rfh, params, details->is_in_page,
808 details->did_replace_entry); 846 details->did_replace_entry);
809 break; 847 break;
810 case NAVIGATION_TYPE_EXISTING_PAGE: 848 case NAVIGATION_TYPE_EXISTING_PAGE:
811 details->did_replace_entry = details->is_in_page; 849 details->did_replace_entry = details->is_in_page;
812 RendererDidNavigateToExistingPage(rfh, params, details->is_in_page); 850 RendererDidNavigateToExistingPage(rfh, params, details->is_in_page);
813 break; 851 break;
814 case NAVIGATION_TYPE_SAME_PAGE: 852 case NAVIGATION_TYPE_SAME_PAGE:
(...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after
2101 } 2139 }
2102 } 2140 }
2103 } 2141 }
2104 2142
2105 void NavigationControllerImpl::SetGetTimestampCallbackForTest( 2143 void NavigationControllerImpl::SetGetTimestampCallbackForTest(
2106 const base::Callback<base::Time()>& get_timestamp_callback) { 2144 const base::Callback<base::Time()>& get_timestamp_callback) {
2107 get_timestamp_callback_ = get_timestamp_callback; 2145 get_timestamp_callback_ = get_timestamp_callback;
2108 } 2146 }
2109 2147
2110 } // namespace content 2148 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698