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

Unified Diff: chrome/browser/android/offline_pages/background_loader_offliner.cc

Issue 2873393004: [Offline pages] Stop observing web contents and reset to null after use. Only create a new web cont… (Closed)
Patch Set: Created 3 years, 7 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: chrome/browser/android/offline_pages/background_loader_offliner.cc
diff --git a/chrome/browser/android/offline_pages/background_loader_offliner.cc b/chrome/browser/android/offline_pages/background_loader_offliner.cc
index 5e18f9ff775e7b475516983c5c80758c501e1a8c..4b5d23b335f9d913d671671ce9c45e3a682c79ba 100644
--- a/chrome/browser/android/offline_pages/background_loader_offliner.cc
+++ b/chrome/browser/android/offline_pages/background_loader_offliner.cc
@@ -149,8 +149,8 @@ bool BackgroundLoaderOffliner::LoadAndSave(
return false;
}
- if (!loader_)
- ResetState();
+ ResetLoader();
+ AttachObservers();
// Track copy of pending request.
pending_request_.reset(new SavePageRequest(request));
@@ -355,13 +355,16 @@ void BackgroundLoaderOffliner::ResetState() {
snapshot_controller_.reset();
page_load_state_ = SUCCESS;
network_bytes_ = 0LL;
- // TODO(chili): Remove after RequestCoordinator can handle multiple offliners.
- // We reset the loader and observer after completion so loaders
- // will not be re-used across different requests/tries. This is a temporary
- // solution while there exists assumptions about the number of offliners
- // there are.
+ content::WebContentsObserver::Observe(nullptr);
+ loader_.reset();
+}
+
+void BackgroundLoaderOffliner::ResetLoader() {
loader_.reset(
new background_loader::BackgroundLoaderContents(browser_context_));
+}
+
+void BackgroundLoaderOffliner::AttachObservers() {
content::WebContents* contents = loader_->web_contents();
content::WebContentsObserver::Observe(contents);
OfflinerData::AddToWebContents(contents, this);

Powered by Google App Engine
This is Rietveld 408576698