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

Unified Diff: components/sessions/content/content_serialized_navigation_builder.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/content/content_serialized_navigation_builder.cc
diff --git a/components/sessions/content/content_serialized_navigation_builder.cc b/components/sessions/content/content_serialized_navigation_builder.cc
index 59df5cc2d016730fa5a64ff1c9875b12ad3cd696..b5793c3c4420b05a882945c59916e5e0d11289ca 100644
--- a/components/sessions/content/content_serialized_navigation_builder.cc
+++ b/components/sessions/content/content_serialized_navigation_builder.cc
@@ -4,7 +4,10 @@
#include "components/sessions/content/content_serialized_navigation_builder.h"
+#include "base/logging.h"
#include "components/sessions/content/content_record_password_state.h"
+#include "components/sessions/content/content_serialized_navigation_driver.h"
+#include "components/sessions/content/extended_info_handler.h"
#include "components/sessions/core/serialized_navigation_entry.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/favicon_status.h"
@@ -42,6 +45,15 @@ ContentSerializedNavigationBuilder::FromNavigationEntry(
navigation.redirect_chain_ = entry.GetRedirectChain();
navigation.password_state_ = GetPasswordStateFromNavigation(entry);
+ for (const auto& handler_entry :
+ ContentSerializedNavigationDriver::GetInstance()->
+ GetAllExtendedInfoHandlers()) {
+ ExtendedInfoHandler* handler = handler_entry.second.get();
+ DCHECK(handler);
+ navigation.extended_info_map_[handler_entry.first] =
sky 2016/09/29 03:08:19 I think you should only add the entry if GetExtend
jianli 2016/09/29 22:02:28 Done.
+ handler->GetExtendedInfo(entry);
+ }
+
return navigation;
}
@@ -78,6 +90,18 @@ ContentSerializedNavigationBuilder::ToNavigationEntry(
entry->SetHttpStatusCode(navigation->http_status_code_);
entry->SetRedirectChain(navigation->redirect_chain_);
+ for (const auto& handler_entry :
sky 2016/09/29 03:08:19 Rather than iterating over the handlers I think it
jianli 2016/09/29 22:02:28 Done.
+ ContentSerializedNavigationDriver::GetInstance()->
+ GetAllExtendedInfoHandlers()) {
+ const std::string& key = handler_entry.first;
+ if (!navigation->extended_info_map_.count(key))
+ continue;
+ ExtendedInfoHandler* handler = handler_entry.second.get();
+ DCHECK(handler);
+ const std::string& value = navigation->extended_info_map_.at(key);
sky 2016/09/29 03:08:19 at -> [key] ?
jianli 2016/09/29 22:02:29 I can't use operator[] since navigation is const t
+ handler->RestoreExtendedInfo(value, entry.get());
+ }
+
// These fields should have default values.
DCHECK_EQ(SerializedNavigationEntry::STATE_INVALID,
navigation->blocked_state_);

Powered by Google App Engine
This is Rietveld 408576698