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

Side by Side Diff: content/browser/frame_host/navigation_controller_impl.cc

Issue 1184423005: Add item and document sequence numbers to FrameNavigationEntry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add const; git cl format Created 5 years, 6 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 #include "content/browser/frame_host/navigation_controller_impl.h" 5 #include "content/browser/frame_host/navigation_controller_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 380
381 NavigationEntryImpl* NavigationControllerImpl::GetEntryWithPageID( 381 NavigationEntryImpl* NavigationControllerImpl::GetEntryWithPageID(
382 SiteInstance* instance, int32 page_id) const { 382 SiteInstance* instance, int32 page_id) const {
383 int index = GetEntryIndexWithPageID(instance, page_id); 383 int index = GetEntryIndexWithPageID(instance, page_id);
384 return (index != -1) ? entries_[index].get() : NULL; 384 return (index != -1) ? entries_[index].get() : NULL;
385 } 385 }
386 386
387 bool NavigationControllerImpl::HasCommittedRealLoad( 387 bool NavigationControllerImpl::HasCommittedRealLoad(
388 FrameTreeNode* frame_tree_node) const { 388 FrameTreeNode* frame_tree_node) const {
389 NavigationEntryImpl* last_committed = GetLastCommittedEntry(); 389 NavigationEntryImpl* last_committed = GetLastCommittedEntry();
390 return last_committed && last_committed->HasFrameEntry(frame_tree_node); 390 return last_committed && last_committed->GetFrameEntry(frame_tree_node);
391 } 391 }
392 392
393 void NavigationControllerImpl::LoadEntry(NavigationEntryImpl* entry) { 393 void NavigationControllerImpl::LoadEntry(NavigationEntryImpl* entry) {
394 // When navigating to a new page, we don't know for sure if we will actually 394 // When navigating to a new page, we don't know for sure if we will actually
395 // end up leaving the current page. The new page load could for example 395 // end up leaving the current page. The new page load could for example
396 // result in a download or a 'no content' response (e.g., a mailto: URL). 396 // result in a download or a 'no content' response (e.g., a mailto: URL).
397 SetPendingEntry(entry); 397 SetPendingEntry(entry);
398 NavigateToPendingEntry(NO_RELOAD); 398 NavigateToPendingEntry(NO_RELOAD);
399 } 399 }
400 400
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 new_entry->SetReferrer(params.referrer); 1216 new_entry->SetReferrer(params.referrer);
1217 new_entry->SetPageID(params.page_id); 1217 new_entry->SetPageID(params.page_id);
1218 new_entry->SetTransitionType(params.transition); 1218 new_entry->SetTransitionType(params.transition);
1219 new_entry->set_site_instance( 1219 new_entry->set_site_instance(
1220 static_cast<SiteInstanceImpl*>(rfh->GetSiteInstance())); 1220 static_cast<SiteInstanceImpl*>(rfh->GetSiteInstance()));
1221 new_entry->SetHasPostData(params.is_post); 1221 new_entry->SetHasPostData(params.is_post);
1222 new_entry->SetPostID(params.post_id); 1222 new_entry->SetPostID(params.post_id);
1223 new_entry->SetOriginalRequestURL(params.original_request_url); 1223 new_entry->SetOriginalRequestURL(params.original_request_url);
1224 new_entry->SetIsOverridingUserAgent(params.is_overriding_user_agent); 1224 new_entry->SetIsOverridingUserAgent(params.is_overriding_user_agent);
1225 1225
1226 // Update the FrameNavigationEntry for new main frame commits.
1227 FrameNavigationEntry* frame_entry =
1228 new_entry->GetFrameEntry(rfh->frame_tree_node());
1229 frame_entry->set_item_sequence_number(params.item_sequence_number);
1230 frame_entry->set_document_sequence_number(params.document_sequence_number);
1231
1226 // history.pushState() is classified as a navigation to a new page, but 1232 // history.pushState() is classified as a navigation to a new page, but
1227 // sets was_within_same_page to true. In this case, we already have the 1233 // sets was_within_same_page to true. In this case, we already have the
1228 // title and favicon available, so set them immediately. 1234 // title and favicon available, so set them immediately.
1229 if (params.was_within_same_page && GetLastCommittedEntry()) { 1235 if (params.was_within_same_page && GetLastCommittedEntry()) {
1230 new_entry->SetTitle(GetLastCommittedEntry()->GetTitle()); 1236 new_entry->SetTitle(GetLastCommittedEntry()->GetTitle());
1231 new_entry->GetFavicon() = GetLastCommittedEntry()->GetFavicon(); 1237 new_entry->GetFavicon() = GetLastCommittedEntry()->GetFavicon();
1232 } 1238 }
1233 1239
1234 DCHECK(!params.history_list_was_cleared || !replace_entry); 1240 DCHECK(!params.history_list_was_cleared || !replace_entry);
1235 // The browser requested to clear the session history when it initiated the 1241 // The browser requested to clear the session history when it initiated the
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1392 // stored in the page state for each of those entries. This happens out of 1398 // stored in the page state for each of those entries. This happens out of
1393 // band with the actual navigations. 1399 // band with the actual navigations.
1394 DCHECK(GetLastCommittedEntry()) << "ClassifyNavigation should guarantee " 1400 DCHECK(GetLastCommittedEntry()) << "ClassifyNavigation should guarantee "
1395 << "that a last committed entry exists."; 1401 << "that a last committed entry exists.";
1396 1402
1397 NavigationEntryImpl* new_entry = nullptr; 1403 NavigationEntryImpl* new_entry = nullptr;
1398 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1404 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
1399 switches::kSitePerProcess)) { 1405 switches::kSitePerProcess)) {
1400 // Make sure new_entry takes ownership of frame_entry in a scoped_refptr. 1406 // Make sure new_entry takes ownership of frame_entry in a scoped_refptr.
1401 FrameNavigationEntry* frame_entry = new FrameNavigationEntry( 1407 FrameNavigationEntry* frame_entry = new FrameNavigationEntry(
1402 rfh->frame_tree_node()->frame_tree_node_id(), rfh->GetSiteInstance(), 1408 rfh->frame_tree_node()->frame_tree_node_id(),
1403 params.url, params.referrer); 1409 params.item_sequence_number, params.document_sequence_number,
1410 rfh->GetSiteInstance(), params.url, params.referrer);
1404 new_entry = GetLastCommittedEntry()->CloneAndReplace(rfh->frame_tree_node(), 1411 new_entry = GetLastCommittedEntry()->CloneAndReplace(rfh->frame_tree_node(),
1405 frame_entry); 1412 frame_entry);
1406 CHECK(frame_entry->HasOneRef()); 1413 CHECK(frame_entry->HasOneRef());
1407 } else { 1414 } else {
1408 new_entry = GetLastCommittedEntry()->Clone(); 1415 new_entry = GetLastCommittedEntry()->Clone();
1409 } 1416 }
1410 1417
1411 new_entry->SetPageID(params.page_id); 1418 new_entry->SetPageID(params.page_id);
1412 InsertOrReplaceEntry(new_entry, false); 1419 InsertOrReplaceEntry(new_entry, false);
1413 } 1420 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1448 DiscardNonCommittedEntriesInternal(); 1455 DiscardNonCommittedEntriesInternal();
1449 return true; 1456 return true;
1450 } 1457 }
1451 } 1458 }
1452 1459
1453 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1460 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
1454 switches::kSitePerProcess)) { 1461 switches::kSitePerProcess)) {
1455 // This may be a "new auto" case where we add a new FrameNavigationEntry, or 1462 // This may be a "new auto" case where we add a new FrameNavigationEntry, or
1456 // it may be a "history auto" case where we update an existing one. 1463 // it may be a "history auto" case where we update an existing one.
1457 NavigationEntryImpl* last_committed = GetLastCommittedEntry(); 1464 NavigationEntryImpl* last_committed = GetLastCommittedEntry();
1458 last_committed->AddOrUpdateFrameEntry(rfh->frame_tree_node(), 1465 last_committed->AddOrUpdateFrameEntry(
1459 rfh->GetSiteInstance(), params.url, 1466 rfh->frame_tree_node(), params.item_sequence_number,
1460 params.referrer, params.page_state); 1467 params.document_sequence_number, rfh->GetSiteInstance(), params.url,
1468 params.referrer, params.page_state);
1461 1469
1462 // Cross-process subframe navigations may leave a pending entry around. 1470 // Cross-process subframe navigations may leave a pending entry around.
1463 // Clear it if it's actually for the subframe. 1471 // Clear it if it's actually for the subframe.
1464 // TODO(creis): Don't use pending entries for subframe navigations. 1472 // TODO(creis): Don't use pending entries for subframe navigations.
1465 // See https://crbug.com/495161. 1473 // See https://crbug.com/495161.
1466 if (pending_entry_ && 1474 if (pending_entry_ &&
1467 pending_entry_->frame_tree_node_id() == 1475 pending_entry_->frame_tree_node_id() ==
1468 rfh->frame_tree_node()->frame_tree_node_id()) { 1476 rfh->frame_tree_node()->frame_tree_node_id()) {
1469 DiscardPendingEntry(false); 1477 DiscardPendingEntry(false);
1470 } 1478 }
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
2050 } 2058 }
2051 } 2059 }
2052 } 2060 }
2053 2061
2054 void NavigationControllerImpl::SetGetTimestampCallbackForTest( 2062 void NavigationControllerImpl::SetGetTimestampCallbackForTest(
2055 const base::Callback<base::Time()>& get_timestamp_callback) { 2063 const base::Callback<base::Time()>& get_timestamp_callback) {
2056 get_timestamp_callback_ = get_timestamp_callback; 2064 get_timestamp_callback_ = get_timestamp_callback;
2057 } 2065 }
2058 2066
2059 } // namespace content 2067 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698