OLD | NEW |
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/offline_page_model.h" | 14 #include "components/offline_pages/core/offline_page_model.h" |
15 #include "components/offline_pages/core/offline_page_types.h" | 15 #include "components/offline_pages/core/offline_page_types.h" |
16 | 16 |
17 namespace content { | 17 namespace content { |
18 class BrowserContext; | 18 class BrowserContext; |
19 class WebContents; | 19 class WebContents; |
20 } // namespace content | 20 } // namespace content |
21 | 21 |
22 namespace offline_pages { | 22 namespace offline_pages { |
23 | 23 |
| 24 class OfflinerPolicy; |
| 25 |
24 // An Offliner implementation that attempts client-side rendering and saving | 26 // An Offliner implementation that attempts client-side rendering and saving |
25 // of an offline page. It uses the PrerenderingLoader to load the page and | 27 // of an offline page. It uses the PrerenderingLoader to load the page and |
26 // 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. |
27 class PrerenderingOffliner : public Offliner { | 29 class PrerenderingOffliner : public Offliner { |
28 public: | 30 public: |
29 PrerenderingOffliner(content::BrowserContext* browser_context, | 31 PrerenderingOffliner(content::BrowserContext* browser_context, |
| 32 const OfflinerPolicy* policy, |
30 OfflinePageModel* offline_page_model); | 33 OfflinePageModel* offline_page_model); |
31 ~PrerenderingOffliner() override; | 34 ~PrerenderingOffliner() override; |
32 | 35 |
33 // Offliner implementation. | 36 // Offliner implementation. |
34 bool LoadAndSave(const SavePageRequest& request, | 37 bool LoadAndSave(const SavePageRequest& request, |
35 const CompletionCallback& callback) override; | 38 const CompletionCallback& callback) override; |
36 void Cancel() override; | 39 void Cancel() override; |
37 | 40 |
38 // Allows a loader to be injected for testing. This may only be done once | 41 // Allows a loader to be injected for testing. This may only be done once |
39 // and must be called before any of the Offliner interface methods are called. | 42 // and must be called before any of the Offliner interface methods are called. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 // ApplicationStatusListener to monitor if the Chrome moves to the foreground. | 89 // ApplicationStatusListener to monitor if the Chrome moves to the foreground. |
87 std::unique_ptr<base::android::ApplicationStatusListener> app_listener_; | 90 std::unique_ptr<base::android::ApplicationStatusListener> app_listener_; |
88 base::WeakPtrFactory<PrerenderingOffliner> weak_ptr_factory_; | 91 base::WeakPtrFactory<PrerenderingOffliner> weak_ptr_factory_; |
89 | 92 |
90 DISALLOW_COPY_AND_ASSIGN(PrerenderingOffliner); | 93 DISALLOW_COPY_AND_ASSIGN(PrerenderingOffliner); |
91 }; | 94 }; |
92 | 95 |
93 } // namespace offline_pages | 96 } // namespace offline_pages |
94 | 97 |
95 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_PRERENDERING_OFFLINER_H_ | 98 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_PRERENDERING_OFFLINER_H_ |
OLD | NEW |