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

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

Issue 2310363002: Persist offline page info in a navigation entry if needed (Closed)
Patch Set: Add extended info support 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..02139965c445f9757dadd9b1bae718f0597034b3 100644
--- a/components/sessions/core/serialized_navigation_entry.cc
+++ b/components/sessions/core/serialized_navigation_entry.cc
@@ -182,6 +182,17 @@ void WriteString16ToPickle(base::Pickle* pickle,
}
}
+void WriteStringMapToPickle(base::Pickle* pickle,
+ int* bytes_written,
+ int max_bytes,
+ const std::map<std::string, std::string>& map) {
+ pickle->WriteInt(map.size());
+ for (const auto entry : map) {
+ WriteStringToPickle(pickle, bytes_written, max_bytes, entry.first);
+ WriteStringToPickle(pickle, bytes_written, max_bytes, entry.second);
+ }
+}
+
// A mask used for arbitrary boolean values needed to represent a
// NavigationEntry. Currently only contains HAS_POST_DATA.
//
@@ -213,6 +224,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 +269,8 @@ void SerializedNavigationEntry::WriteToPickle(int max_size,
pickle->WriteInt(http_status_code_);
pickle->WriteInt(referrer_policy_);
+
+ WriteStringMapToPickle(pickle, &bytes_written, max_size, extended_info_map_);
}
bool SerializedNavigationEntry::ReadFromPickle(base::PickleIterator* iterator) {
@@ -335,6 +349,19 @@ bool SerializedNavigationEntry::ReadFromPickle(base::PickleIterator* iterator) {
SerializedNavigationDriver::Get()->StripReferrerFromPageState(
encoded_page_state_);
}
+
+ int extended_info_map_size = 0;
+ if (iterator->ReadInt(&extended_info_map_size) &&
+ extended_info_map_size >= 0) {
+ 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 {
+ extended_info_map_.clear();
+ }
}
SerializedNavigationDriver::Get()->Sanitize(this);

Powered by Google App Engine
This is Rietveld 408576698