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

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: Comments. Created 6 years, 10 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..10a2f101c4cdd8df1aeebc547e6c664f51ee684a 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,24 @@ sync_pb::TabNavigation SerializedNavigationEntry::ToSyncData() const {
sync_data.add_content_pack_categories(*it);
}
+ // Copy all redirect chain entries except the last URL.
sky 2014/02/20 22:12:26 Document why the last isn't copied.
Donn Denman 2014/02/21 08:18:56 Done.
+ for (size_t i = 0; i < redirect_chain_.size(); i++) {
sky 2014/02/20 22:12:26 Why don't you have a loop for the first n-1 and th
Donn Denman 2014/02/21 08:18:56 Done. I'm ashamed I didn't see that - it's much m
+ bool is_last_url = (i == redirect_chain_.size() - 1);
+ if (is_last_url) {
+ bool did_redirect = redirect_chain_.size() > 1;
+ if (did_redirect &&
+ sync_data.virtual_url() != redirect_chain_.at(i).spec()) {
+ // If the last URL didn't match the virtual_url, record it separately.
+ sync_data.set_last_navigation_redirect_url(
+ redirect_chain_.at(i).spec());
+ }
+ } else {
+ sync_pb::NavigationRedirect *navigation_redirect =
sky 2014/02/20 22:12:26 NavigationRedirect*
Donn Denman 2014/02/21 08:18:56 Done.
+ sync_data.add_navigation_redirect();
+ navigation_redirect->set_url(redirect_chain_.at(i).spec());
sky 2014/02/20 22:12:26 at->[]
Donn Denman 2014/02/21 08:18:56 Done.
+ }
+ }
+
sync_data.set_is_restored(is_restored_);
return sync_data;

Powered by Google App Engine
This is Rietveld 408576698