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

Unified Diff: android_webview/native/state_serializer.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: Fix android unit test (state_serializer_unittests.cc). Created 6 years, 11 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: android_webview/native/state_serializer.cc
diff --git a/android_webview/native/state_serializer.cc b/android_webview/native/state_serializer.cc
index 9b013a17710e7728edff61f7af7d89a7486dbbbb..f0787d53bba14d70705fd60fa9b21af449558a1d 100644
--- a/android_webview/native/state_serializer.cc
+++ b/android_webview/native/state_serializer.cc
@@ -35,7 +35,7 @@ namespace {
// Sanity check value that we are restoring from a valid pickle.
// This can potentially used as an actual serialization version number in the
// future if we ever decide to support restoring from older versions.
-const uint32 AW_STATE_VERSION = 20130814;
+const uint32 AW_STATE_VERSION = 20140115;
} // namespace
@@ -189,6 +189,18 @@ bool WriteNavigationEntryToPickle(const content::NavigationEntry& entry,
if (!pickle->WriteInt(entry.GetHttpStatusCode()))
return false;
+ // The redirect chain has a variable number of entries.
+ bool did_write_all_redirects = true;
+ if (!pickle->WriteUInt16(entry.GetRedirectChain().size()))
+ return false;
+ for (size_t i = 0; i < entry.GetRedirectChain().size(); i++) {
+ if (!pickle->WriteString(entry.GetRedirectChain().at(i).spec())) {
+ did_write_all_redirects = false;
+ }
+ }
+ if (!did_write_all_redirects)
+ return false;
+
// Please update AW_STATE_VERSION if serialization format is changed.
return true;
@@ -282,6 +294,27 @@ bool RestoreNavigationEntryFromPickle(PickleIterator* iterator,
entry->SetHttpStatusCode(http_status_code);
}
+ {
+ unsigned short redirect_chain_length = 0;
+ if (!iterator->ReadUInt16(&redirect_chain_length))
+ return false;
+ std::vector<GURL> full_redirect_chain;
+ bool was_full_chain_read_successfully = true;
+ for (size_t i = 0; i < redirect_chain_length; i++) {
+ std::string a_redirect;
+ if (!iterator->ReadString(&a_redirect)) {
+ was_full_chain_read_successfully = false;
+ } else {
+ full_redirect_chain.push_back(GURL(a_redirect));
+ }
+ }
+ if (was_full_chain_read_successfully) {
+ entry->SetRedirectChain(full_redirect_chain);
+ } else {
+ return false;
+ }
+ }
+
return true;
}

Powered by Google App Engine
This is Rietveld 408576698