| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 COMPONENTS_OFFLINE_PAGES_CORE_DOWNLOADS_DOWNLOAD_UI_ADAPTER_H_ | 5 #ifndef COMPONENTS_OFFLINE_PAGES_CORE_DOWNLOADS_DOWNLOAD_UI_ADAPTER_H_ |
| 6 #define COMPONENTS_OFFLINE_PAGES_CORE_DOWNLOADS_DOWNLOAD_UI_ADAPTER_H_ | 6 #define COMPONENTS_OFFLINE_PAGES_CORE_DOWNLOADS_DOWNLOAD_UI_ADAPTER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 // Returns all UI items. The list contains references to items in the cache | 96 // Returns all UI items. The list contains references to items in the cache |
| 97 // and has to be used synchronously. | 97 // and has to be used synchronously. |
| 98 std::vector<const DownloadUIItem*> GetAllItems() const; | 98 std::vector<const DownloadUIItem*> GetAllItems() const; |
| 99 // May return nullptr if item with specified guid does not exist. | 99 // May return nullptr if item with specified guid does not exist. |
| 100 const DownloadUIItem* GetItem(const std::string& guid) const; | 100 const DownloadUIItem* GetItem(const std::string& guid) const; |
| 101 | 101 |
| 102 // Commands from UI. Start async operations, result is observable | 102 // Commands from UI. Start async operations, result is observable |
| 103 // via Observer or directly by the user (as in 'open'). | 103 // via Observer or directly by the user (as in 'open'). |
| 104 void DeleteItem(const std::string& guid); | 104 void DeleteItem(const std::string& guid); |
| 105 int64_t GetOfflineIdByGuid(const std::string& guid) const; | 105 int64_t GetOfflineIdByGuid(const std::string& guid) const; |
| 106 void UpdateProgress(int64_t offline_id, int64_t bytes); | |
| 107 | 106 |
| 108 // OfflinePageModel::Observer | 107 // OfflinePageModel::Observer |
| 109 void OfflinePageModelLoaded(OfflinePageModel* model) override; | 108 void OfflinePageModelLoaded(OfflinePageModel* model) override; |
| 110 void OfflinePageAdded(OfflinePageModel* model, | 109 void OfflinePageAdded(OfflinePageModel* model, |
| 111 const OfflinePageItem& added_page) override; | 110 const OfflinePageItem& added_page) override; |
| 112 void OfflinePageDeleted(int64_t offline_id, | 111 void OfflinePageDeleted(int64_t offline_id, |
| 113 const ClientId& client_id) override; | 112 const ClientId& client_id) override; |
| 114 | 113 |
| 115 // RequestCoordinator::Observer | 114 // RequestCoordinator::Observer |
| 116 void OnAdded(const SavePageRequest& request) override; | 115 void OnAdded(const SavePageRequest& request) override; |
| 117 void OnCompleted(const SavePageRequest& request, | 116 void OnCompleted(const SavePageRequest& request, |
| 118 RequestNotifier::BackgroundSavePageResult status) override; | 117 RequestNotifier::BackgroundSavePageResult status) override; |
| 119 void OnChanged(const SavePageRequest& request) override; | 118 void OnChanged(const SavePageRequest& request) override; |
| 119 void OnNetworkProgress(const SavePageRequest& request, |
| 120 int64_t received_bytes) override; |
| 120 | 121 |
| 121 // For the DownloadUIAdapter::Delegate, to report the temporary hidden status | 122 // For the DownloadUIAdapter::Delegate, to report the temporary hidden status |
| 122 // change. | 123 // change. |
| 123 void TemporaryHiddenStatusChanged(const ClientId& client_id); | 124 void TemporaryHiddenStatusChanged(const ClientId& client_id); |
| 124 | 125 |
| 125 Delegate* delegate() { return delegate_.get(); } | 126 Delegate* delegate() { return delegate_.get(); } |
| 126 | 127 |
| 127 private: | 128 private: |
| 128 enum class State { NOT_LOADED, LOADING_PAGES, LOADING_REQUESTS, LOADED }; | 129 enum class State { NOT_LOADED, LOADING_PAGES, LOADING_REQUESTS, LOADED }; |
| 129 | 130 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 int observers_count_; | 196 int observers_count_; |
| 196 | 197 |
| 197 base::WeakPtrFactory<DownloadUIAdapter> weak_ptr_factory_; | 198 base::WeakPtrFactory<DownloadUIAdapter> weak_ptr_factory_; |
| 198 | 199 |
| 199 DISALLOW_COPY_AND_ASSIGN(DownloadUIAdapter); | 200 DISALLOW_COPY_AND_ASSIGN(DownloadUIAdapter); |
| 200 }; | 201 }; |
| 201 | 202 |
| 202 } // namespace offline_pages | 203 } // namespace offline_pages |
| 203 | 204 |
| 204 #endif // COMPONENTS_OFFLINE_PAGE_DOWNLOADS_DOWNLOAD_UI_ADAPTER_H_ | 205 #endif // COMPONENTS_OFFLINE_PAGE_DOWNLOADS_DOWNLOAD_UI_ADAPTER_H_ |
| OLD | NEW |