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; |
} |