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

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

Issue 2736843002: Fix the Download Notifications for Offline Pages to indicate bytes loaded. (Closed)
Patch Set: more fixes to more tests. 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 17 matching lines...) Expand all
28 // the OfflinePageModel to save it. Only one request may be active at a time. 28 // the OfflinePageModel to save it. Only one request may be active at a time.
29 class PrerenderingOffliner : public Offliner { 29 class PrerenderingOffliner : public Offliner {
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& completion_callback,
39 const ProgressCallback& progress_callback) override;
39 void Cancel(const CancelCallback& callback) override; 40 void Cancel(const CancelCallback& callback) override;
40 bool HandleTimeout(const SavePageRequest& request) override; 41 bool HandleTimeout(const SavePageRequest& request) override;
41 42
42 // Allows a loader to be injected for testing. This may only be done once 43 // Allows a loader to be injected for testing. This may only be done once
43 // and must be called before any of the Offliner interface methods are called. 44 // and must be called before any of the Offliner interface methods are called.
44 void SetLoaderForTesting(std::unique_ptr<PrerenderingLoader> loader); 45 void SetLoaderForTesting(std::unique_ptr<PrerenderingLoader> loader);
45 46
46 void SetLowEndDeviceForTesting(bool is_low_end_device); 47 void SetLowEndDeviceForTesting(bool is_low_end_device);
47 48
48 void SetApplicationStateForTesting( 49 void SetApplicationStateForTesting(
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // Not owned. 87 // Not owned.
87 OfflinePageModel* offline_page_model_; 88 OfflinePageModel* offline_page_model_;
88 // Lazily created. 89 // Lazily created.
89 std::unique_ptr<PrerenderingLoader> loader_; 90 std::unique_ptr<PrerenderingLoader> loader_;
90 // Tracks pending request, if any. Owned copy. 91 // Tracks pending request, if any. Owned copy.
91 // May be used to ensure a callback applies to the pending request (e.g., in 92 // May be used to ensure a callback applies to the pending request (e.g., in
92 // case we receive a save page callback for an old, canceled request). 93 // case we receive a save page callback for an old, canceled request).
93 std::unique_ptr<SavePageRequest> pending_request_; 94 std::unique_ptr<SavePageRequest> pending_request_;
94 // Callback to call when pending request completes/fails. 95 // Callback to call when pending request completes/fails.
95 CompletionCallback completion_callback_; 96 CompletionCallback completion_callback_;
97 ProgressCallback progress_callback_;
96 bool is_low_end_device_; 98 bool is_low_end_device_;
97 // ApplicationStatusListener to monitor if the Chrome moves to the foreground. 99 // ApplicationStatusListener to monitor if the Chrome moves to the foreground.
98 std::unique_ptr<base::android::ApplicationStatusListener> app_listener_; 100 std::unique_ptr<base::android::ApplicationStatusListener> app_listener_;
99 base::WeakPtrFactory<PrerenderingOffliner> weak_ptr_factory_; 101 base::WeakPtrFactory<PrerenderingOffliner> weak_ptr_factory_;
100 102
101 DISALLOW_COPY_AND_ASSIGN(PrerenderingOffliner); 103 DISALLOW_COPY_AND_ASSIGN(PrerenderingOffliner);
102 }; 104 };
103 105
104 } // namespace offline_pages 106 } // namespace offline_pages
105 107
106 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_PRERENDERING_OFFLINER_H_ 108 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_PRERENDERING_OFFLINER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698