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

Unified Diff: chrome/browser/android/offline_pages/prerendering_offliner.h

Issue 2149773002: PrerenderingOffliner will abort background load if it sees chrome transitioning to foreground on lo… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revise some comments wrt app listener setting/clearing Created 4 years, 5 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
« no previous file with comments | « no previous file | chrome/browser/android/offline_pages/prerendering_offliner.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/offline_pages/prerendering_offliner.h
diff --git a/chrome/browser/android/offline_pages/prerendering_offliner.h b/chrome/browser/android/offline_pages/prerendering_offliner.h
index ad74af1458133bf5b9f7308ba9abc35b5868fcb1..83d09d06b4add1aa5b7174ebfcaf19d8390b2c71 100644
--- a/chrome/browser/android/offline_pages/prerendering_offliner.h
+++ b/chrome/browser/android/offline_pages/prerendering_offliner.h
@@ -7,6 +7,7 @@
#include <memory>
+#include "base/android/application_status_listener.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/android/offline_pages/prerendering_loader.h"
#include "components/offline_pages/background/offliner.h"
@@ -41,6 +42,11 @@ class PrerenderingOffliner : public Offliner {
// and must be called before any of the Offliner interface methods are called.
void SetLoaderForTesting(std::unique_ptr<PrerenderingLoader> loader);
+ void SetLowEndDeviceForTesting(bool is_low_end_device);
+
+ void SetApplicationStateForTesting(
+ base::android::ApplicationState application_state);
+
protected:
// Internal method for requesting OfflinePageModel to save page.
// Exposed for unit testing.
@@ -48,24 +54,24 @@ class PrerenderingOffliner : public Offliner {
virtual void SavePage(const GURL& url,
const ClientId& client_id,
std::unique_ptr<OfflinePageArchiver> archiver,
- const SavePageCallback& callback);
+ const SavePageCallback& save_callback);
private:
// Callback logic for PrerenderingLoader::LoadPage().
void OnLoadPageDone(const SavePageRequest& request,
- const CompletionCallback& completion_callback,
Offliner::RequestStatus load_status,
content::WebContents* web_contents);
// Callback logic for OfflinePageModel::SavePage().
void OnSavePageDone(const SavePageRequest& request,
- const CompletionCallback& completion_callback,
SavePageResult save_result,
int64_t offline_id);
PrerenderingLoader* GetOrCreateLoader();
- void SetPendingRequest(int64_t request_id);
- void ClearPendingRequest();
+
+ // Listener function for changes to application background/foreground state.
+ void OnApplicationStateChange(
+ base::android::ApplicationState application_state);
// Not owned.
content::BrowserContext* browser_context_;
@@ -77,6 +83,11 @@ class PrerenderingOffliner : public Offliner {
// May be used to ensure a callback applies to the pending request (e.g., in
// case we receive a save page callback for an old, canceled request).
std::unique_ptr<SavePageRequest> pending_request_;
+ // Callback to call when pending request completes/fails.
+ CompletionCallback completion_callback_;
+ bool is_low_end_device_;
+ // ApplicationStatusListener to monitor if the Chrome moves to the foreground.
+ std::unique_ptr<base::android::ApplicationStatusListener> app_listener_;
base::WeakPtrFactory<PrerenderingOffliner> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(PrerenderingOffliner);
« no previous file with comments | « no previous file | chrome/browser/android/offline_pages/prerendering_offliner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698