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

Unified Diff: components/sessions/serialized_navigation_entry.cc

Issue 101573003: Add the navigation redirect-chain to Sync sessions proto for offline analysis. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Brett's comment on patch set 46, and rebase. Created 6 years, 8 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: components/sessions/serialized_navigation_entry.cc
diff --git a/components/sessions/serialized_navigation_entry.cc b/components/sessions/serialized_navigation_entry.cc
index 45f3cf03106807230c66c291e517dd45f957d1a6..5b5a8c49fd22ec39801ecdde1d5787d0162a08cb 100644
--- a/components/sessions/serialized_navigation_entry.cc
+++ b/components/sessions/serialized_navigation_entry.cc
@@ -57,6 +57,7 @@ SerializedNavigationEntry SerializedNavigationEntry::FromNavigationEntry(
if (entry.GetFavicon().valid)
navigation.favicon_url_ = entry.GetFavicon().url;
navigation.http_status_code_ = entry.GetHttpStatusCode();
+ navigation.redirect_chain_ = entry.GetRedirectChain();
return navigation;
}
@@ -363,6 +364,7 @@ scoped_ptr<NavigationEntry> SerializedNavigationEntry::ToNavigationEntry(
entry->SetTimestamp(timestamp_);
entry->SetExtraData(kSearchTermsKey, search_terms_);
entry->SetHttpStatusCode(http_status_code_);
+ entry->SetRedirectChain(redirect_chain_);
// These fields should have default values.
DCHECK_EQ(STATE_INVALID, blocked_state_);
@@ -477,6 +479,22 @@ sync_pb::TabNavigation SerializedNavigationEntry::ToSyncData() const {
sync_data.add_content_pack_categories(*it);
}
+ // Copy all redirect chain entries except the last URL (which should match
+ // the virtual_url).
+ if (redirect_chain_.size() > 1) { // Single entry chains have no redirection.
+ size_t last_entry = redirect_chain_.size() - 1;
+ for (size_t i = 0; i < last_entry; i++) {
+ sync_pb::NavigationRedirect* navigation_redirect =
+ sync_data.add_navigation_redirect();
+ navigation_redirect->set_url(redirect_chain_[i].spec());
+ }
+ // If the last URL didn't match the virtual_url, record it separately.
+ if (sync_data.virtual_url() != redirect_chain_[last_entry].spec()) {
+ sync_data.set_last_navigation_redirect_url(
+ redirect_chain_[last_entry].spec());
+ }
+ }
+
sync_data.set_is_restored(is_restored_);
return sync_data;
« no previous file with comments | « components/sessions/serialized_navigation_entry.h ('k') | components/sessions/serialized_navigation_entry_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698