| 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_BACKGROUND_LOADER_OFFLINER_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_OFFLINE_PAGES_BACKGROUND_LOADER_OFFLINER_H_ |
| 6 #define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_BACKGROUND_LOADER_OFFLINER_H_ | 6 #define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_BACKGROUND_LOADER_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 20 matching lines...) Expand all Loading... |
| 31 public: | 31 public: |
| 32 BackgroundLoaderOffliner(content::BrowserContext* browser_context, | 32 BackgroundLoaderOffliner(content::BrowserContext* browser_context, |
| 33 const OfflinerPolicy* policy, | 33 const OfflinerPolicy* policy, |
| 34 OfflinePageModel* offline_page_model); | 34 OfflinePageModel* offline_page_model); |
| 35 ~BackgroundLoaderOffliner() override; | 35 ~BackgroundLoaderOffliner() override; |
| 36 | 36 |
| 37 // Offliner implementation. | 37 // Offliner implementation. |
| 38 bool LoadAndSave(const SavePageRequest& request, | 38 bool LoadAndSave(const SavePageRequest& request, |
| 39 const CompletionCallback& completion_callback, | 39 const CompletionCallback& completion_callback, |
| 40 const ProgressCallback& progress_callback) override; | 40 const ProgressCallback& progress_callback) override; |
| 41 void Cancel() override; | 41 void Cancel(const CancelCallback& callback) override; |
| 42 bool HandleTimeout(const SavePageRequest& request) override; | 42 bool HandleTimeout(const SavePageRequest& request) override; |
| 43 | 43 |
| 44 // WebContentsObserver implementation. | 44 // WebContentsObserver implementation. |
| 45 void DidStopLoading() override; | 45 void DidStopLoading() override; |
| 46 void RenderProcessGone(base::TerminationStatus status) override; | 46 void RenderProcessGone(base::TerminationStatus status) override; |
| 47 void WebContentsDestroyed() override; | 47 void WebContentsDestroyed() override; |
| 48 void DidFinishNavigation( | 48 void DidFinishNavigation( |
| 49 content::NavigationHandle* navigation_handle) override; | 49 content::NavigationHandle* navigation_handle) override; |
| 50 | 50 |
| 51 void SetPageDelayForTest(long delay_ms); | 51 void SetPageDelayForTest(long delay_ms); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 62 | 62 |
| 63 // Called when the page is ready to be saved. | 63 // Called when the page is ready to be saved. |
| 64 void SavePage(); | 64 void SavePage(); |
| 65 | 65 |
| 66 // Called when the page has been saved. | 66 // Called when the page has been saved. |
| 67 void OnPageSaved(SavePageResult save_result, int64_t offline_id); | 67 void OnPageSaved(SavePageResult save_result, int64_t offline_id); |
| 68 | 68 |
| 69 // Called when application state has changed. | 69 // Called when application state has changed. |
| 70 void OnApplicationStateChange( | 70 void OnApplicationStateChange( |
| 71 base::android::ApplicationState application_state); | 71 base::android::ApplicationState application_state); |
| 72 void HandleApplicationStateChangeCancel(const SavePageRequest& request, |
| 73 int64_t offline_id); |
| 72 | 74 |
| 73 std::unique_ptr<background_loader::BackgroundLoaderContents> loader_; | 75 std::unique_ptr<background_loader::BackgroundLoaderContents> loader_; |
| 74 // Not owned. | 76 // Not owned. |
| 75 content::BrowserContext* browser_context_; | 77 content::BrowserContext* browser_context_; |
| 76 // Not owned. | 78 // Not owned. |
| 77 OfflinePageModel* offline_page_model_; | 79 OfflinePageModel* offline_page_model_; |
| 78 // Tracks pending request, if any. | 80 // Tracks pending request, if any. |
| 79 std::unique_ptr<SavePageRequest> pending_request_; | 81 std::unique_ptr<SavePageRequest> pending_request_; |
| 80 // Callback when pending request completes. | 82 // Callback when pending request completes. |
| 81 CompletionCallback completion_callback_; | 83 CompletionCallback completion_callback_; |
| 82 // ApplicationStatusListener to monitor if Chrome moves to the foreground. | 84 // ApplicationStatusListener to monitor if Chrome moves to the foreground. |
| 83 std::unique_ptr<base::android::ApplicationStatusListener> app_listener_; | 85 std::unique_ptr<base::android::ApplicationStatusListener> app_listener_; |
| 84 // Whether we are on a low-end device. | 86 // Whether we are on a low-end device. |
| 85 bool is_low_end_device_; | 87 bool is_low_end_device_; |
| 88 |
| 86 // Save state. | 89 // Save state. |
| 87 SaveState save_state_; | 90 SaveState save_state_; |
| 88 // Page load state. | 91 // Page load state. |
| 89 PageLoadState page_load_state_; | 92 PageLoadState page_load_state_; |
| 90 // Seconds to delay before taking snapshot. | 93 // Seconds to delay before taking snapshot. |
| 91 long page_delay_ms_; | 94 long page_delay_ms_; |
| 92 | 95 |
| 96 // Callback for cancel. |
| 97 CancelCallback cancel_callback_; |
| 98 |
| 93 base::WeakPtrFactory<BackgroundLoaderOffliner> weak_ptr_factory_; | 99 base::WeakPtrFactory<BackgroundLoaderOffliner> weak_ptr_factory_; |
| 94 DISALLOW_COPY_AND_ASSIGN(BackgroundLoaderOffliner); | 100 DISALLOW_COPY_AND_ASSIGN(BackgroundLoaderOffliner); |
| 95 }; | 101 }; |
| 96 | 102 |
| 97 } // namespace offline_pages | 103 } // namespace offline_pages |
| 98 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_BACKGROUND_LOADER_OFFLINER_H_ | 104 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_BACKGROUND_LOADER_OFFLINER_H_ |
| OLD | NEW |