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

Unified Diff: content/browser/frame_host/navigation_controller_impl.cc

Issue 2600233003: Discard SSL certificates for non-committed entries to save memory. (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « content/browser/frame_host/navigation_controller_impl.h ('k') | content/public/browser/ssl_status.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/frame_host/navigation_controller_impl.cc
diff --git a/content/browser/frame_host/navigation_controller_impl.cc b/content/browser/frame_host/navigation_controller_impl.cc
index 5bde4bb4340d76cb67cc37f410824c5a814269d9..b7b9ea8a59c30bfc0da87c7efdcd0aee047fac09 100644
--- a/content/browser/frame_host/navigation_controller_impl.cc
+++ b/content/browser/frame_host/navigation_controller_impl.cc
@@ -559,6 +559,13 @@ int NavigationControllerImpl::GetIndexForOffset(int offset) const {
return GetCurrentEntryIndex() + offset;
}
+void NavigationControllerImpl::DiscardUnusedSSLCerts() {
+ for (size_t i = 0; i < entries_.size(); ++i) {
+ if (static_cast<int>(i) != last_committed_entry_index_)
+ entries_[i]->GetSSL().certificate = nullptr;
+ }
+}
+
void NavigationControllerImpl::TakeScreenshot() {
screenshot_manager_->TakeScreenshot();
}
@@ -1272,6 +1279,7 @@ void NavigationControllerImpl::RendererDidNavigateToExistingPage(
// If a transient entry was removed, the indices might have changed, so we
// have to query the entry index again.
last_committed_entry_index_ = GetIndexOfEntry(entry);
+ DiscardUnusedSSLCerts();
}
void NavigationControllerImpl::RendererDidNavigateToSamePage(
@@ -1397,6 +1405,7 @@ bool NavigationControllerImpl::RendererDidNavigateAutoSubframe(
// case. For newly created subframes, there was no pending entry.
last_committed_entry_index_ = entry_index;
DiscardNonCommittedEntriesInternal();
+ DiscardUnusedSSLCerts();
// History navigations should send a commit notification.
send_commit_notification = true;
@@ -1552,6 +1561,7 @@ void NavigationControllerImpl::CopyStateFromAndPrune(
// Adjust indices such that the last entry and pending are at the end now.
last_committed_entry_index_ = GetEntryCount() - 1;
+ DiscardUnusedSSLCerts();
delegate_->SetHistoryOffsetAndLength(last_committed_entry_index_,
GetEntryCount());
@@ -1762,6 +1772,7 @@ void NavigationControllerImpl::InsertOrReplaceEntry(
entries_.push_back(std::move(entry));
last_committed_entry_index_ = static_cast<int>(entries_.size()) - 1;
+ DiscardUnusedSSLCerts();
}
void NavigationControllerImpl::PruneOldestEntryIfFull() {
@@ -2069,6 +2080,7 @@ void NavigationControllerImpl::FinishRestore(int selected_index,
ConfigureEntriesForRestore(&entries_, type);
last_committed_entry_index_ = selected_index;
+ DiscardUnusedSSLCerts();
}
void NavigationControllerImpl::DiscardNonCommittedEntriesInternal() {
« no previous file with comments | « content/browser/frame_host/navigation_controller_impl.h ('k') | content/public/browser/ssl_status.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698