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

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: use NavigationEntryImpl to keep ReloadType Created 4 years, 4 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 pending_entry_index_(-1), 234 pending_entry_index_(-1),
235 transient_entry_index_(-1), 235 transient_entry_index_(-1),
236 delegate_(delegate), 236 delegate_(delegate),
237 max_restored_page_id_(-1), 237 max_restored_page_id_(-1),
238 ssl_manager_(this), 238 ssl_manager_(this),
239 needs_reload_(false), 239 needs_reload_(false),
240 is_initial_navigation_(true), 240 is_initial_navigation_(true),
241 in_navigate_to_pending_entry_(false), 241 in_navigate_to_pending_entry_(false),
242 pending_reload_(NO_RELOAD), 242 pending_reload_(NO_RELOAD),
243 get_timestamp_callback_(base::Bind(&base::Time::Now)), 243 get_timestamp_callback_(base::Bind(&base::Time::Now)),
244 screenshot_manager_(new NavigationEntryScreenshotManager(this)) { 244 screenshot_manager_(new NavigationEntryScreenshotManager(this)),
245 is_last_navigation_reload_(false),
246 last_reload_type_(NO_RELOAD) {
245 DCHECK(browser_context_); 247 DCHECK(browser_context_);
246 } 248 }
247 249
248 NavigationControllerImpl::~NavigationControllerImpl() { 250 NavigationControllerImpl::~NavigationControllerImpl() {
249 DiscardNonCommittedEntriesInternal(); 251 DiscardNonCommittedEntriesInternal();
250 } 252 }
251 253
252 WebContents* NavigationControllerImpl::GetWebContents() const { 254 WebContents* NavigationControllerImpl::GetWebContents() const {
253 return delegate_->GetWebContents(); 255 return delegate_->GetWebContents();
254 } 256 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 if (current_index != -1) { 339 if (current_index != -1) {
338 entry = GetEntryAtIndex(current_index); 340 entry = GetEntryAtIndex(current_index);
339 } 341 }
340 } 342 }
341 343
342 // If we are no where, then we can't reload. TODO(darin): We should add a 344 // If we are no where, then we can't reload. TODO(darin): We should add a
343 // CanReload method. 345 // CanReload method.
344 if (!entry) 346 if (!entry)
345 return; 347 return;
346 348
349 entry->set_reload_type(reload_type);
Charlie Reis 2016/08/08 23:57:53 What happens if the renderer initiates a reload (e
Takashi Toyoshima 2016/08/09 07:35:26 Right. Javascript initiated reload won't be captur
Charlie Reis 2016/08/10 05:05:13 Isn't this a problem for any renderer-initiated na
Takashi Toyoshima 2016/08/10 06:34:15 If we assume this reload type is valid only when t
350
347 if (g_check_for_repost && check_for_repost && 351 if (g_check_for_repost && check_for_repost &&
348 entry->GetHasPostData()) { 352 entry->GetHasPostData()) {
349 // The user is asking to reload a page with POST data. Prompt to make sure 353 // The user is asking to reload a page with POST data. Prompt to make sure
350 // they really want to do this. If they do, the dialog will call us back 354 // they really want to do this. If they do, the dialog will call us back
351 // with check_for_repost = false. 355 // with check_for_repost = false.
352 delegate_->NotifyBeforeFormRepostWarningShow(); 356 delegate_->NotifyBeforeFormRepostWarningShow();
353 357
354 pending_reload_ = reload_type; 358 pending_reload_ = reload_type;
355 delegate_->ActivateAndShowRepostFormWarningDialog(); 359 delegate_->ActivateAndShowRepostFormWarningDialog();
356 } else { 360 } else {
(...skipping 1581 matching lines...) Expand 10 before | Expand all | Expand 10 after
1938 } 1942 }
1939 1943
1940 for (size_t i = 0; i < frame->child_count(); i++) { 1944 for (size_t i = 0; i < frame->child_count(); i++) {
1941 FindFramesToNavigate(frame->child_at(i), same_document_loads, 1945 FindFramesToNavigate(frame->child_at(i), same_document_loads,
1942 different_document_loads); 1946 different_document_loads);
1943 } 1947 }
1944 } 1948 }
1945 1949
1946 void NavigationControllerImpl::NotifyNavigationEntryCommitted( 1950 void NavigationControllerImpl::NotifyNavigationEntryCommitted(
1947 LoadCommittedDetails* details) { 1951 LoadCommittedDetails* details) {
1948 details->entry = GetLastCommittedEntry(); 1952 NavigationEntryImpl* entry = GetLastCommittedEntry();
1953 CHECK(entry);
1954 details->entry = entry;
1955
1956 ui::PageTransition transition = details->entry->GetTransitionType();
1957 if (ui::PageTransitionIsMainFrame(transition)) {
1958 base::Time now = base::Time::Now();
1959
1960 bool is_navigation_forward_back =
1961 transition & ui::PAGE_TRANSITION_FORWARD_BACK;
Takashi Toyoshima 2016/08/09 12:06:17 This line broke Windows build.
1962 bool is_navigation_reload =
1963 !is_navigation_forward_back &&
1964 ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_RELOAD);
1965
1966 if (is_last_navigation_reload_ && is_navigation_reload) {
1967 base::TimeDelta delta = now - last_navigation_time_;
1968 UMA_HISTOGRAM_MEDIUM_TIMES("Navigation.Reload.ReloadToReloadDuration",
1969 delta);
1970 // Track the case that another reload folllows RELOAD_MAIN_RESOURCE type
1971 // of reload.
1972 if (last_reload_type_ == NavigationController::RELOAD_MAIN_RESOURCE) {
1973 UMA_HISTOGRAM_MEDIUM_TIMES(
1974 "Navigation.Reload.ReloadMainResourceToReloadDuration", delta);
1975 }
1976 }
1977
1978 is_last_navigation_reload_ = is_navigation_reload;
1979 last_reload_type_ = entry->reload_type();
1980 last_navigation_time_ = now;
1981 }
1949 1982
1950 // We need to notify the ssl_manager_ before the web_contents_ so the 1983 // We need to notify the ssl_manager_ before the web_contents_ so the
1951 // location bar will have up-to-date information about the security style 1984 // location bar will have up-to-date information about the security style
1952 // when it wants to draw. See http://crbug.com/11157 1985 // when it wants to draw. See http://crbug.com/11157
1953 ssl_manager_.DidCommitProvisionalLoad(*details); 1986 ssl_manager_.DidCommitProvisionalLoad(*details);
1954 1987
1955 delegate_->NotifyNavigationStateChanged(INVALIDATE_TYPE_ALL); 1988 delegate_->NotifyNavigationStateChanged(INVALIDATE_TYPE_ALL);
1956 delegate_->NotifyNavigationEntryCommitted(*details); 1989 delegate_->NotifyNavigationEntryCommitted(*details);
1957 1990
1958 // TODO(avi): Remove. http://crbug.com/170921 1991 // TODO(avi): Remove. http://crbug.com/170921
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
2104 } 2137 }
2105 } 2138 }
2106 } 2139 }
2107 2140
2108 void NavigationControllerImpl::SetGetTimestampCallbackForTest( 2141 void NavigationControllerImpl::SetGetTimestampCallbackForTest(
2109 const base::Callback<base::Time()>& get_timestamp_callback) { 2142 const base::Callback<base::Time()>& get_timestamp_callback) {
2110 get_timestamp_callback_ = get_timestamp_callback; 2143 get_timestamp_callback_ = get_timestamp_callback;
2111 } 2144 }
2112 2145
2113 } // namespace content 2146 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698