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

Unified Diff: components/sessions/core/serialized_navigation_entry.cc

Issue 2310363002: Persist offline page info in a navigation entry if needed (Closed)
Patch Set: Update Created 4 years, 3 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/core/serialized_navigation_entry.cc
diff --git a/components/sessions/core/serialized_navigation_entry.cc b/components/sessions/core/serialized_navigation_entry.cc
index 4f4124c598a5e7c50be2ed812a71946ec0aa6b33..e2294db0bb145e48c95306d3b76752677cbd6b68 100644
--- a/components/sessions/core/serialized_navigation_entry.cc
+++ b/components/sessions/core/serialized_navigation_entry.cc
@@ -213,6 +213,7 @@ enum TypeMask {
// search_terms_
// http_status_code_
// referrer_policy_
+// extended_info_map_
void SerializedNavigationEntry::WriteToPickle(int max_size,
base::Pickle* pickle) const {
@@ -257,6 +258,14 @@ void SerializedNavigationEntry::WriteToPickle(int max_size,
pickle->WriteInt(http_status_code_);
pickle->WriteInt(referrer_policy_);
+
+#if !defined(OS_IOS)
+ pickle->WriteInt(extended_info_map_.size());
+ for (const auto entry : extended_info_map_) {
+ WriteStringToPickle(pickle, &bytes_written, max_size, entry.first);
+ WriteStringToPickle(pickle, &bytes_written, max_size, entry.second);
+ }
+#endif // !defined(OS_IOS)
}
bool SerializedNavigationEntry::ReadFromPickle(base::PickleIterator* iterator) {
@@ -335,6 +344,21 @@ bool SerializedNavigationEntry::ReadFromPickle(base::PickleIterator* iterator) {
SerializedNavigationDriver::Get()->StripReferrerFromPageState(
encoded_page_state_);
}
+
+#if !defined(OS_IOS)
+ int extended_info_map_size = 0;
+ if (iterator->ReadInt(&extended_info_map_size) &&
+ extended_info_map_size >= 0) {
sky 2016/09/29 03:08:19 > 0?
jianli 2016/09/29 22:02:29 Done.
+ for (int i = 0; i < extended_info_map_size; ++i) {
+ std::string key;
+ std::string value;
+ if (iterator->ReadString(&key) && iterator->ReadString(&value))
+ extended_info_map_[key] = value;
+ }
+ } else {
sky 2016/09/29 03:08:19 I don't think you need the else case as everything
jianli 2016/09/29 22:02:29 Done.
+ extended_info_map_.clear();
+ }
+ #endif // !defined(OS_IOS)
}
SerializedNavigationDriver::Get()->Sanitize(this);

Powered by Google App Engine
This is Rietveld 408576698