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

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

Issue 2866643005: [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 856ada6fc7f47432e2bcfc803c7fcacd9553199a..b2fc873f41f19a28d41c4e6e0346492aa7528c5c 100644
--- a/chrome/browser/android/offline_pages/background_loader_offliner.cc
+++ b/chrome/browser/android/offline_pages/background_loader_offliner.cc
@@ -172,8 +172,8 @@ bool BackgroundLoaderOffliner::LoadAndSave(
return false;
}
- if (!loader_)
- ResetState();
+ ResetLoader();
+ AttachObservers();
MarkLoadStartTime();
@@ -453,13 +453,16 @@ void BackgroundLoaderOffliner::ResetState() {
network_bytes_ = 0LL;
is_low_bar_met_ = false;
did_snapshot_on_last_retry_ = false;
- // 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