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

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

Issue 2857063002: Add a way to send the resource percentage signal to the RC. (Closed)
Patch Set: Make sure we don't send notifications unless we are offlining 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 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"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "chrome/browser/android/offline_pages/prerendering_loader.h" 12 #include "chrome/browser/android/offline_pages/prerendering_loader.h"
13 #include "components/offline_pages/core/background/offliner.h" 13 #include "components/offline_pages/core/background/offliner.h"
14 #include "components/offline_pages/core/background/resource_data_type.h"
14 #include "components/offline_pages/core/offline_page_model.h" 15 #include "components/offline_pages/core/offline_page_model.h"
15 #include "components/offline_pages/core/offline_page_types.h" 16 #include "components/offline_pages/core/offline_page_types.h"
16 17
17 namespace content { 18 namespace content {
18 class BrowserContext; 19 class BrowserContext;
19 class WebContents; 20 class WebContents;
20 } // namespace content 21 } // namespace content
21 22
22 namespace offline_pages { 23 namespace offline_pages {
23 24
24 class OfflinerPolicy; 25 class OfflinerPolicy;
25 26
26 // An Offliner implementation that attempts client-side rendering and saving 27 // An Offliner implementation that attempts client-side rendering and saving
27 // of an offline page. It uses the PrerenderingLoader to load the page and 28 // of an offline page. It uses the PrerenderingLoader to load the page and
28 // the OfflinePageModel to save it. Only one request may be active at a time. 29 // the OfflinePageModel to save it. Only one request may be active at a time.
29 class PrerenderingOffliner : public Offliner { 30 class PrerenderingOffliner : public Offliner {
30 public: 31 public:
31 PrerenderingOffliner(content::BrowserContext* browser_context, 32 PrerenderingOffliner(content::BrowserContext* browser_context,
32 const OfflinerPolicy* policy, 33 const OfflinerPolicy* policy,
33 OfflinePageModel* offline_page_model); 34 OfflinePageModel* offline_page_model);
34 ~PrerenderingOffliner() override; 35 ~PrerenderingOffliner() override;
35 36
36 // Offliner implementation. 37 // Offliner implementation.
37 bool LoadAndSave(const SavePageRequest& request, 38 bool LoadAndSave(const SavePageRequest& request,
38 const CompletionCallback& completion_callback, 39 const CompletionCallback& completion_callback,
39 const ProgressCallback& progress_callback) override; 40 const ProgressCallback& progress_callback) override;
40 bool Cancel(const CancelCallback& callback) override; 41 bool Cancel(const CancelCallback& callback) override;
41 bool HandleTimeout(int64_t request_id) override; 42 bool HandleTimeout(int64_t request_id) override;
43 void ObserveResourceTracking(const ResourceDataType type,
44 int64_t started_count,
45 int64_t completed_count) override;
42 46
43 // Allows a loader to be injected for testing. This may only be done once 47 // Allows a loader to be injected for testing. This may only be done once
44 // and must be called before any of the Offliner interface methods are called. 48 // and must be called before any of the Offliner interface methods are called.
45 void SetLoaderForTesting(std::unique_ptr<PrerenderingLoader> loader); 49 void SetLoaderForTesting(std::unique_ptr<PrerenderingLoader> loader);
46 50
47 void SetLowEndDeviceForTesting(bool is_low_end_device); 51 void SetLowEndDeviceForTesting(bool is_low_end_device);
48 52
49 void SetApplicationStateForTesting( 53 void SetApplicationStateForTesting(
50 base::android::ApplicationState application_state); 54 base::android::ApplicationState application_state);
51 55
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 // ApplicationStatusListener to monitor if the Chrome moves to the foreground. 105 // ApplicationStatusListener to monitor if the Chrome moves to the foreground.
102 std::unique_ptr<base::android::ApplicationStatusListener> app_listener_; 106 std::unique_ptr<base::android::ApplicationStatusListener> app_listener_;
103 base::WeakPtrFactory<PrerenderingOffliner> weak_ptr_factory_; 107 base::WeakPtrFactory<PrerenderingOffliner> weak_ptr_factory_;
104 108
105 DISALLOW_COPY_AND_ASSIGN(PrerenderingOffliner); 109 DISALLOW_COPY_AND_ASSIGN(PrerenderingOffliner);
106 }; 110 };
107 111
108 } // namespace offline_pages 112 } // namespace offline_pages
109 113
110 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_PRERENDERING_OFFLINER_H_ 114 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_PRERENDERING_OFFLINER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698