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

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: 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 790 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 new_type == NAVIGATION_TYPE_EXISTING_PAGE; 801 new_type == NAVIGATION_TYPE_EXISTING_PAGE;
802 // There are mismatches in the field where the new classifier thinks it's 802 // There are mismatches in the field where the new classifier thinks it's
803 // AUTO_SUBFRAME and the old classifier somehow thinks it's NEW or IGNORE. For 803 // AUTO_SUBFRAME and the old classifier somehow thinks it's NEW or IGNORE. For
804 // IGNORE we know of at least one repro (https://crbug.com/492875), and for 804 // IGNORE we know of at least one repro (https://crbug.com/492875), and for
805 // NEW it's not entirely clear what's going on, but we're pretty sure the new 805 // NEW it's not entirely clear what's going on, but we're pretty sure the new
806 // classifier is correct for both cases, so we're letting these mismatches go. 806 // classifier is correct for both cases, so we're letting these mismatches go.
807 ignore_mismatch |= details->type == NAVIGATION_TYPE_NEW_SUBFRAME && 807 ignore_mismatch |= details->type == NAVIGATION_TYPE_NEW_SUBFRAME &&
808 new_type == NAVIGATION_TYPE_AUTO_SUBFRAME; 808 new_type == NAVIGATION_TYPE_AUTO_SUBFRAME;
809 ignore_mismatch |= details->type == NAVIGATION_TYPE_NAV_IGNORE && 809 ignore_mismatch |= details->type == NAVIGATION_TYPE_NAV_IGNORE &&
810 new_type == NAVIGATION_TYPE_AUTO_SUBFRAME; 810 new_type == NAVIGATION_TYPE_AUTO_SUBFRAME;
811 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 811 bool is_site_per_process = base::CommandLine::ForCurrentProcess()->HasSwitch(
Charlie Reis 2015/06/17 22:56:23 I'll undo this. (I was using it below in an earli
Avi (use Gerrit) 2015/06/18 00:57:00 Acknowledged.
Charlie Reis 2015/06/18 20:30:17 Done.
812 switches::kSitePerProcess)) { 812 switches::kSitePerProcess);
813 if (is_site_per_process) {
813 // We know that the old classifier is wrong for OOPIFs, so use the new one 814 // We know that the old classifier is wrong for OOPIFs, so use the new one
814 // in --site-per-process mode. 815 // in --site-per-process mode.
815 details->type = new_type; 816 details->type = new_type;
816 ignore_mismatch = true; 817 ignore_mismatch = true;
817 } 818 }
818 if (!ignore_mismatch) { 819 if (!ignore_mismatch) {
819 DCHECK_EQ(details->type, new_type); 820 DCHECK_EQ(details->type, new_type);
820 } 821 }
821 822
822 // is_in_page must be computed before the entry gets committed. 823 // is_in_page must be computed before the entry gets committed.
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 new_entry->SetReferrer(params.referrer); 1217 new_entry->SetReferrer(params.referrer);
1217 new_entry->SetPageID(params.page_id); 1218 new_entry->SetPageID(params.page_id);
1218 new_entry->SetTransitionType(params.transition); 1219 new_entry->SetTransitionType(params.transition);
1219 new_entry->set_site_instance( 1220 new_entry->set_site_instance(
1220 static_cast<SiteInstanceImpl*>(rfh->GetSiteInstance())); 1221 static_cast<SiteInstanceImpl*>(rfh->GetSiteInstance()));
1221 new_entry->SetHasPostData(params.is_post); 1222 new_entry->SetHasPostData(params.is_post);
1222 new_entry->SetPostID(params.post_id); 1223 new_entry->SetPostID(params.post_id);
1223 new_entry->SetOriginalRequestURL(params.original_request_url); 1224 new_entry->SetOriginalRequestURL(params.original_request_url);
1224 new_entry->SetIsOverridingUserAgent(params.is_overriding_user_agent); 1225 new_entry->SetIsOverridingUserAgent(params.is_overriding_user_agent);
1225 1226
1227 // Update the FrameNavigationEntry for new main frame commits.
1228 FrameNavigationEntry* frame_entry = new_entry->root_node()->frame_entry.get();
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(rfh->frame_tree_node(),
1466 params.item_sequence_number,
1467 params.document_sequence_number,
1459 rfh->GetSiteInstance(), params.url, 1468 rfh->GetSiteInstance(), params.url,
1460 params.referrer, params.page_state); 1469 params.referrer, params.page_state);
1461 1470
1462 // Cross-process subframe navigations may leave a pending entry around. 1471 // Cross-process subframe navigations may leave a pending entry around.
1463 // Clear it if it's actually for the subframe. 1472 // Clear it if it's actually for the subframe.
1464 // TODO(creis): Don't use pending entries for subframe navigations. 1473 // TODO(creis): Don't use pending entries for subframe navigations.
1465 // See https://crbug.com/495161. 1474 // See https://crbug.com/495161.
1466 if (pending_entry_ && 1475 if (pending_entry_ &&
1467 pending_entry_->frame_tree_node_id() == 1476 pending_entry_->frame_tree_node_id() ==
1468 rfh->frame_tree_node()->frame_tree_node_id()) { 1477 rfh->frame_tree_node()->frame_tree_node_id()) {
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
2050 } 2059 }
2051 } 2060 }
2052 } 2061 }
2053 2062
2054 void NavigationControllerImpl::SetGetTimestampCallbackForTest( 2063 void NavigationControllerImpl::SetGetTimestampCallbackForTest(
2055 const base::Callback<base::Time()>& get_timestamp_callback) { 2064 const base::Callback<base::Time()>& get_timestamp_callback) {
2056 get_timestamp_callback_ = get_timestamp_callback; 2065 get_timestamp_callback_ = get_timestamp_callback;
2057 } 2066 }
2058 2067
2059 } // namespace content 2068 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698