Chromium Code Reviews| 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> | |
| 9 | |
| 10 #include "base/memory/weak_ptr.h" | |
| 8 #include "chrome/browser/android/offline_pages/prerendering_loader.h" | 11 #include "chrome/browser/android/offline_pages/prerendering_loader.h" |
| 9 #include "components/offline_pages/background/offliner.h" | 12 #include "components/offline_pages/background/offliner.h" |
| 10 #include "components/offline_pages/offline_page_model.h" | 13 #include "components/offline_pages/offline_page_model.h" |
| 11 | 14 |
| 12 class PrerenderManager; | |
| 13 | |
| 14 namespace content { | 15 namespace content { |
| 16 class BrowserContext; | |
| 15 class WebContents; | 17 class WebContents; |
| 16 } // namespace content | 18 } // namespace content |
| 17 | 19 |
| 18 namespace offline_pages { | 20 namespace offline_pages { |
| 19 | 21 |
| 20 class OfflinerPolicy; | 22 class OfflinerPolicy; |
| 21 | 23 |
| 22 // An Offliner implementation that attempts client-side rendering and saving | 24 // An Offliner implementation that attempts client-side rendering and saving |
| 23 // of an offline page. It uses the PrerenderingLoader to load the page and | 25 // of an offline page. It uses the PrerenderingLoader to load the page and |
| 24 // the OfflinePageModel to save it. | 26 // the OfflinePageModel to save it. |
| 25 class PrerenderingOffliner : public Offliner { | 27 class PrerenderingOffliner : public Offliner { |
| 26 public: | 28 public: |
| 27 PrerenderingOffliner(const OfflinerPolicy* policy, | 29 PrerenderingOffliner(content::BrowserContext* browser_context, |
|
Pete Williamson
2016/05/09 16:49:38
We could probably make content::BrowserContext con
dougarnett
2016/05/09 17:42:03
I don't think so as we want to get Profile from it
| |
| 28 PrerenderManager* prerender_manager, | 30 const OfflinerPolicy* policy, |
| 29 OfflinePageModel* offline_page_model); | 31 OfflinePageModel* offline_page_model); |
| 30 ~PrerenderingOffliner() override; | 32 ~PrerenderingOffliner() override; |
| 31 | 33 |
| 32 bool LoadAndSave(const SavePageRequest& request, | 34 bool LoadAndSave(const SavePageRequest& request, |
| 33 const CompletionCallback& callback) override; | 35 const CompletionCallback& callback) override; |
| 34 | 36 |
| 35 void Cancel() override; | 37 void Cancel() override; |
| 36 | 38 |
| 39 protected: | |
| 40 // Constructor for injecting PrerenderingLoader for testing. | |
| 41 PrerenderingOffliner(content::BrowserContext* browser_context, | |
|
Pete Williamson
2016/05/09 16:49:38
and here...
dougarnett
2016/05/09 17:42:04
ditto
| |
| 42 const OfflinerPolicy* policy, | |
| 43 OfflinePageModel* offline_page_model, | |
| 44 PrerenderingLoader* loader); | |
| 45 | |
| 37 private: | 46 private: |
| 47 void OnLoadPageDone(Offliner::CompletionStatus load_status, | |
|
Pete Williamson
2016/05/09 16:49:38
load_status can also likely be const. Might be a
dougarnett
2016/05/09 17:42:03
Done.
fgorski
2016/05/09 20:38:32
It is an enum, hence no need to const it.
| |
| 48 content::WebContents* contents); | |
| 49 | |
| 50 // Not owned. | |
| 51 OfflinePageModel* offline_page_model_; | |
| 38 std::unique_ptr<PrerenderingLoader> loader_; | 52 std::unique_ptr<PrerenderingLoader> loader_; |
| 53 base::WeakPtrFactory<PrerenderingOffliner> weak_ptr_factory_; | |
| 54 | |
| 55 DISALLOW_COPY_AND_ASSIGN(PrerenderingOffliner); | |
| 39 }; | 56 }; |
| 40 | 57 |
| 41 } // namespace offline_pages | 58 } // namespace offline_pages |
| 42 | 59 |
| 43 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_PRERENDERING_OFFLINER_H_ | 60 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_PRERENDERING_OFFLINER_H_ |
| OLD | NEW |