| 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" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "components/offline_pages/content/background_loader/background_loader_c
ontents.h" | 13 #include "components/offline_pages/content/background_loader/background_loader_c
ontents.h" |
| 14 #include "components/offline_pages/core/background/offliner.h" | 14 #include "components/offline_pages/core/background/offliner.h" |
| 15 #include "components/offline_pages/core/background/resource_data_type.h" |
| 15 #include "components/offline_pages/core/offline_page_types.h" | 16 #include "components/offline_pages/core/offline_page_types.h" |
| 16 #include "components/offline_pages/core/snapshot_controller.h" | 17 #include "components/offline_pages/core/snapshot_controller.h" |
| 17 #include "content/public/browser/web_contents_observer.h" | 18 #include "content/public/browser/web_contents_observer.h" |
| 18 | 19 |
| 19 namespace content { | 20 namespace content { |
| 20 class BrowserContext; | 21 class BrowserContext; |
| 21 } // namespace content | 22 } // namespace content |
| 22 | 23 |
| 23 namespace offline_pages { | 24 namespace offline_pages { |
| 24 | 25 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 39 | 40 |
| 40 static BackgroundLoaderOffliner* FromWebContents( | 41 static BackgroundLoaderOffliner* FromWebContents( |
| 41 content::WebContents* contents); | 42 content::WebContents* contents); |
| 42 | 43 |
| 43 // Offliner implementation. | 44 // Offliner implementation. |
| 44 bool LoadAndSave(const SavePageRequest& request, | 45 bool LoadAndSave(const SavePageRequest& request, |
| 45 const CompletionCallback& completion_callback, | 46 const CompletionCallback& completion_callback, |
| 46 const ProgressCallback& progress_callback) override; | 47 const ProgressCallback& progress_callback) override; |
| 47 bool Cancel(const CancelCallback& callback) override; | 48 bool Cancel(const CancelCallback& callback) override; |
| 48 bool HandleTimeout(int64_t request_id) override; | 49 bool HandleTimeout(int64_t request_id) override; |
| 50 void ObserveResourceTracking(const ResourceDataType type, |
| 51 int64_t started_count, |
| 52 int64_t completed_count) override; |
| 49 | 53 |
| 50 // WebContentsObserver implementation. | 54 // WebContentsObserver implementation. |
| 51 void DocumentAvailableInMainFrame() override; | 55 void DocumentAvailableInMainFrame() override; |
| 52 void DocumentOnLoadCompletedInMainFrame() override; | 56 void DocumentOnLoadCompletedInMainFrame() override; |
| 53 void RenderProcessGone(base::TerminationStatus status) override; | 57 void RenderProcessGone(base::TerminationStatus status) override; |
| 54 void WebContentsDestroyed() override; | 58 void WebContentsDestroyed() override; |
| 55 void DidFinishNavigation( | 59 void DidFinishNavigation( |
| 56 content::NavigationHandle* navigation_handle) override; | 60 content::NavigationHandle* navigation_handle) override; |
| 57 | 61 |
| 58 // SnapshotController::Client implementation. | 62 // SnapshotController::Client implementation. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 86 base::android::ApplicationState application_state); | 90 base::android::ApplicationState application_state); |
| 87 | 91 |
| 88 // Called to remember at what time we started loading. | 92 // Called to remember at what time we started loading. |
| 89 void MarkLoadStartTime(); | 93 void MarkLoadStartTime(); |
| 90 | 94 |
| 91 // Called to add a loading signal as we observe it. | 95 // Called to add a loading signal as we observe it. |
| 92 void AddLoadingSignal(const char* signal_name); | 96 void AddLoadingSignal(const char* signal_name); |
| 93 | 97 |
| 94 void DeleteOfflinePageCallback(const SavePageRequest& request, | 98 void DeleteOfflinePageCallback(const SavePageRequest& request, |
| 95 DeletePageResult result); | 99 DeletePageResult result); |
| 100 // Add a resource loading signal as we observe it. |
| 101 void AddResourceSignal(const ResourceDataType type, |
| 102 int64_t started_count, |
| 103 int64_t completed_count); |
| 96 | 104 |
| 97 std::unique_ptr<background_loader::BackgroundLoaderContents> loader_; | 105 std::unique_ptr<background_loader::BackgroundLoaderContents> loader_; |
| 98 // Not owned. | 106 // Not owned. |
| 99 content::BrowserContext* browser_context_; | 107 content::BrowserContext* browser_context_; |
| 100 // Not owned. | 108 // Not owned. |
| 101 OfflinePageModel* offline_page_model_; | 109 OfflinePageModel* offline_page_model_; |
| 102 // Not owned. | 110 // Not owned. |
| 103 const OfflinerPolicy* policy_; | 111 const OfflinerPolicy* policy_; |
| 104 // Tracks pending request, if any. | 112 // Tracks pending request, if any. |
| 105 std::unique_ptr<SavePageRequest> pending_request_; | 113 std::unique_ptr<SavePageRequest> pending_request_; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 134 | 142 |
| 135 // Callback for cancel. | 143 // Callback for cancel. |
| 136 CancelCallback cancel_callback_; | 144 CancelCallback cancel_callback_; |
| 137 | 145 |
| 138 base::WeakPtrFactory<BackgroundLoaderOffliner> weak_ptr_factory_; | 146 base::WeakPtrFactory<BackgroundLoaderOffliner> weak_ptr_factory_; |
| 139 DISALLOW_COPY_AND_ASSIGN(BackgroundLoaderOffliner); | 147 DISALLOW_COPY_AND_ASSIGN(BackgroundLoaderOffliner); |
| 140 }; | 148 }; |
| 141 | 149 |
| 142 } // namespace offline_pages | 150 } // namespace offline_pages |
| 143 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_BACKGROUND_LOADER_OFFLINER_H_ | 151 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_BACKGROUND_LOADER_OFFLINER_H_ |
| OLD | NEW |