| 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" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 // 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. |
| 43 void SetLoaderForTesting(std::unique_ptr<PrerenderingLoader> loader); | 43 void SetLoaderForTesting(std::unique_ptr<PrerenderingLoader> loader); |
| 44 | 44 |
| 45 void SetLowEndDeviceForTesting(bool is_low_end_device); | 45 void SetLowEndDeviceForTesting(bool is_low_end_device); |
| 46 | 46 |
| 47 void SetApplicationStateForTesting( | 47 void SetApplicationStateForTesting( |
| 48 base::android::ApplicationState application_state); | 48 base::android::ApplicationState application_state); |
| 49 | 49 |
| 50 protected: | 50 protected: |
| 51 // Internal method for requesting OfflinePageModel to save page. Exposed for | 51 // Internal method for requesting OfflinePageModel to save page. Exposed for |
| 52 // unit testing. |proposed_offline_id| will be used if non-zero. If it is | 52 // unit testing. |
| 53 // zero, a new, random, id will be generated instead. | |
| 54 // TODO(dougarnett): Consider making OfflinePageModel mockable instead. | 53 // TODO(dougarnett): Consider making OfflinePageModel mockable instead. |
| 55 virtual void SavePage(const GURL& url, | 54 virtual void SavePage( |
| 56 const ClientId& client_id, | 55 const OfflinePageModel::SavePageParams& save_page_params, |
| 57 int64_t proposed_offline_id, | 56 std::unique_ptr<OfflinePageArchiver> archiver, |
| 58 std::unique_ptr<OfflinePageArchiver> archiver, | 57 const SavePageCallback& save_callback); |
| 59 const SavePageCallback& save_callback); | |
| 60 | 58 |
| 61 private: | 59 private: |
| 62 // Callback logic for PrerenderingLoader::LoadPage(). | 60 // Callback logic for PrerenderingLoader::LoadPage(). |
| 63 void OnLoadPageDone(const SavePageRequest& request, | 61 void OnLoadPageDone(const SavePageRequest& request, |
| 64 Offliner::RequestStatus load_status, | 62 Offliner::RequestStatus load_status, |
| 65 content::WebContents* web_contents); | 63 content::WebContents* web_contents); |
| 66 | 64 |
| 67 // Callback logic for OfflinePageModel::SavePage(). | 65 // Callback logic for OfflinePageModel::SavePage(). |
| 68 void OnSavePageDone(const SavePageRequest& request, | 66 void OnSavePageDone(const SavePageRequest& request, |
| 69 SavePageResult save_result, | 67 SavePageResult save_result, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 91 // ApplicationStatusListener to monitor if the Chrome moves to the foreground. | 89 // ApplicationStatusListener to monitor if the Chrome moves to the foreground. |
| 92 std::unique_ptr<base::android::ApplicationStatusListener> app_listener_; | 90 std::unique_ptr<base::android::ApplicationStatusListener> app_listener_; |
| 93 base::WeakPtrFactory<PrerenderingOffliner> weak_ptr_factory_; | 91 base::WeakPtrFactory<PrerenderingOffliner> weak_ptr_factory_; |
| 94 | 92 |
| 95 DISALLOW_COPY_AND_ASSIGN(PrerenderingOffliner); | 93 DISALLOW_COPY_AND_ASSIGN(PrerenderingOffliner); |
| 96 }; | 94 }; |
| 97 | 95 |
| 98 } // namespace offline_pages | 96 } // namespace offline_pages |
| 99 | 97 |
| 100 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_PRERENDERING_OFFLINER_H_ | 98 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_PRERENDERING_OFFLINER_H_ |
| OLD | NEW |