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

Side by Side Diff: chrome/browser/android/offline_pages/prerendering_offliner.h

Issue 2637563002: [Offline Pages] Snapshotting on timeout of last retry. (Closed)
Patch Set: merging with master again Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_ANDROID_OFFLINE_PAGES_PRERENDERING_OFFLINER_H_ 5 #ifndef CHROME_BROWSER_ANDROID_OFFLINE_PAGES_PRERENDERING_OFFLINER_H_
6 #define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_PRERENDERING_OFFLINER_H_ 6 #define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_PRERENDERING_OFFLINER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/android/application_status_listener.h" 10 #include "base/android/application_status_listener.h"
(...skipping 19 matching lines...) Expand all
30 public: 30 public:
31 PrerenderingOffliner(content::BrowserContext* browser_context, 31 PrerenderingOffliner(content::BrowserContext* browser_context,
32 const OfflinerPolicy* policy, 32 const OfflinerPolicy* policy,
33 OfflinePageModel* offline_page_model); 33 OfflinePageModel* offline_page_model);
34 ~PrerenderingOffliner() override; 34 ~PrerenderingOffliner() override;
35 35
36 // Offliner implementation. 36 // Offliner implementation.
37 bool LoadAndSave(const SavePageRequest& request, 37 bool LoadAndSave(const SavePageRequest& request,
38 const CompletionCallback& callback) override; 38 const CompletionCallback& callback) override;
39 void Cancel() override; 39 void Cancel() override;
40 bool HandleTimeout(const SavePageRequest& request) override;
40 41
41 // Allows a loader to be injected for testing. This may only be done once 42 // Allows a loader to be injected for testing. This may only be done once
42 // and must be called before any of the Offliner interface methods are called. 43 // and must be called before any of the Offliner interface methods are called.
43 void SetLoaderForTesting(std::unique_ptr<PrerenderingLoader> loader); 44 void SetLoaderForTesting(std::unique_ptr<PrerenderingLoader> loader);
44 45
45 void SetLowEndDeviceForTesting(bool is_low_end_device); 46 void SetLowEndDeviceForTesting(bool is_low_end_device);
46 47
47 void SetApplicationStateForTesting( 48 void SetApplicationStateForTesting(
48 base::android::ApplicationState application_state); 49 base::android::ApplicationState application_state);
49 50
(...skipping 22 matching lines...) Expand all
72 73
73 PrerenderingLoader* GetOrCreateLoader(); 74 PrerenderingLoader* GetOrCreateLoader();
74 75
75 // Listener function for changes to application background/foreground state. 76 // Listener function for changes to application background/foreground state.
76 void OnApplicationStateChange( 77 void OnApplicationStateChange(
77 base::android::ApplicationState application_state); 78 base::android::ApplicationState application_state);
78 79
79 // Not owned. 80 // Not owned.
80 content::BrowserContext* browser_context_; 81 content::BrowserContext* browser_context_;
81 // Not owned. 82 // Not owned.
83 const OfflinerPolicy* policy_;
84 // Not owned.
82 OfflinePageModel* offline_page_model_; 85 OfflinePageModel* offline_page_model_;
83 // Lazily created. 86 // Lazily created.
84 std::unique_ptr<PrerenderingLoader> loader_; 87 std::unique_ptr<PrerenderingLoader> loader_;
85 // Tracks pending request, if any. Owned copy. 88 // Tracks pending request, if any. Owned copy.
86 // May be used to ensure a callback applies to the pending request (e.g., in 89 // May be used to ensure a callback applies to the pending request (e.g., in
87 // case we receive a save page callback for an old, canceled request). 90 // case we receive a save page callback for an old, canceled request).
88 std::unique_ptr<SavePageRequest> pending_request_; 91 std::unique_ptr<SavePageRequest> pending_request_;
89 // Callback to call when pending request completes/fails. 92 // Callback to call when pending request completes/fails.
90 CompletionCallback completion_callback_; 93 CompletionCallback completion_callback_;
91 bool is_low_end_device_; 94 bool is_low_end_device_;
92 // ApplicationStatusListener to monitor if the Chrome moves to the foreground. 95 // ApplicationStatusListener to monitor if the Chrome moves to the foreground.
93 std::unique_ptr<base::android::ApplicationStatusListener> app_listener_; 96 std::unique_ptr<base::android::ApplicationStatusListener> app_listener_;
94 base::WeakPtrFactory<PrerenderingOffliner> weak_ptr_factory_; 97 base::WeakPtrFactory<PrerenderingOffliner> weak_ptr_factory_;
95 98
96 DISALLOW_COPY_AND_ASSIGN(PrerenderingOffliner); 99 DISALLOW_COPY_AND_ASSIGN(PrerenderingOffliner);
97 }; 100 };
98 101
99 } // namespace offline_pages 102 } // namespace offline_pages
100 103
101 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_PRERENDERING_OFFLINER_H_ 104 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_PRERENDERING_OFFLINER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698