| 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 "components/offline_pages/content/background_loader/background_loader_c
ontents.h" | 13 #include "components/offline_pages/content/background_loader/background_loader_c
ontents.h" |
| 13 #include "components/offline_pages/core/background/offliner.h" | 14 #include "components/offline_pages/core/background/offliner.h" |
| 14 #include "components/offline_pages/core/offline_page_types.h" | 15 #include "components/offline_pages/core/offline_page_types.h" |
| 15 #include "components/offline_pages/core/snapshot_controller.h" | 16 #include "components/offline_pages/core/snapshot_controller.h" |
| 16 #include "content/public/browser/web_contents_observer.h" | 17 #include "content/public/browser/web_contents_observer.h" |
| 17 | 18 |
| 18 namespace content { | 19 namespace content { |
| 19 class BrowserContext; | 20 class BrowserContext; |
| 20 } // namespace content | 21 } // namespace content |
| 21 | 22 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 | 73 |
| 73 // Called when the page has been saved. | 74 // Called when the page has been saved. |
| 74 void OnPageSaved(SavePageResult save_result, int64_t offline_id); | 75 void OnPageSaved(SavePageResult save_result, int64_t offline_id); |
| 75 | 76 |
| 76 // Called when application state has changed. | 77 // Called when application state has changed. |
| 77 void OnApplicationStateChange( | 78 void OnApplicationStateChange( |
| 78 base::android::ApplicationState application_state); | 79 base::android::ApplicationState application_state); |
| 79 void HandleApplicationStateChangeCancel(const SavePageRequest& request, | 80 void HandleApplicationStateChangeCancel(const SavePageRequest& request, |
| 80 int64_t offline_id); | 81 int64_t offline_id); |
| 81 | 82 |
| 83 // Called to remember at what time we started loading. |
| 84 void MarkLoadStartTime(); |
| 85 |
| 86 // Called to add a loading signal as we observe it. |
| 87 void AddLoadingSignal(const char* signal_name); |
| 88 |
| 82 std::unique_ptr<background_loader::BackgroundLoaderContents> loader_; | 89 std::unique_ptr<background_loader::BackgroundLoaderContents> loader_; |
| 83 // Not owned. | 90 // Not owned. |
| 84 content::BrowserContext* browser_context_; | 91 content::BrowserContext* browser_context_; |
| 85 // Not owned. | 92 // Not owned. |
| 86 OfflinePageModel* offline_page_model_; | 93 OfflinePageModel* offline_page_model_; |
| 87 // Not owned. | 94 // Not owned. |
| 88 const OfflinerPolicy* policy_; | 95 const OfflinerPolicy* policy_; |
| 89 // Tracks pending request, if any. | 96 // Tracks pending request, if any. |
| 90 std::unique_ptr<SavePageRequest> pending_request_; | 97 std::unique_ptr<SavePageRequest> pending_request_; |
| 91 // Handles determining when a page should be snapshotted. | 98 // Handles determining when a page should be snapshotted. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 105 PageLoadState page_load_state_; | 112 PageLoadState page_load_state_; |
| 106 // Seconds to delay before taking snapshot. | 113 // Seconds to delay before taking snapshot. |
| 107 long page_delay_ms_; | 114 long page_delay_ms_; |
| 108 // Network bytes loaded. | 115 // Network bytes loaded. |
| 109 int64_t network_bytes_; | 116 int64_t network_bytes_; |
| 110 // Whether the low bar of snapshot quality has been met. | 117 // Whether the low bar of snapshot quality has been met. |
| 111 bool is_low_bar_met_; | 118 bool is_low_bar_met_; |
| 112 // Whether the snapshot is on the last retry. | 119 // Whether the snapshot is on the last retry. |
| 113 bool did_snapshot_on_last_retry_; | 120 bool did_snapshot_on_last_retry_; |
| 114 | 121 |
| 122 // Time in ticks of when we start loading the page. |
| 123 base::TimeTicks load_start_time_; |
| 124 |
| 125 // Saves loading signals. |
| 126 // TODO(petewil): We will be replacing this with the new snapshot controller. |
| 127 base::DictionaryValue signal_data_; |
| 128 |
| 115 // Callback for cancel. | 129 // Callback for cancel. |
| 116 CancelCallback cancel_callback_; | 130 CancelCallback cancel_callback_; |
| 117 | 131 |
| 118 base::WeakPtrFactory<BackgroundLoaderOffliner> weak_ptr_factory_; | 132 base::WeakPtrFactory<BackgroundLoaderOffliner> weak_ptr_factory_; |
| 119 DISALLOW_COPY_AND_ASSIGN(BackgroundLoaderOffliner); | 133 DISALLOW_COPY_AND_ASSIGN(BackgroundLoaderOffliner); |
| 120 }; | 134 }; |
| 121 | 135 |
| 122 } // namespace offline_pages | 136 } // namespace offline_pages |
| 123 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_BACKGROUND_LOADER_OFFLINER_H_ | 137 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_BACKGROUND_LOADER_OFFLINER_H_ |
| OLD | NEW |