Chromium Code Reviews| 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 COMPONENTS_OFFLINE_PAGE_DOWNLOADS_DOWNLOAD_UI_ADAPTER_H_ | 5 #ifndef COMPONENTS_OFFLINE_PAGE_DOWNLOADS_DOWNLOAD_UI_ADAPTER_H_ |
| 6 #define COMPONENTS_OFFLINE_PAGE_DOWNLOADS_DOWNLOAD_UI_ADAPTER_H_ | 6 #define COMPONENTS_OFFLINE_PAGE_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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 // itself as an observer. | 63 // itself as an observer. |
| 64 // When the last observer si removed, cached list of items is destroyed and | 64 // When the last observer si removed, cached list of items is destroyed and |
| 65 // next time the initial loading will take longer. | 65 // next time the initial loading will take longer. |
| 66 void AddObserver(Observer* observer); | 66 void AddObserver(Observer* observer); |
| 67 void RemoveObserver(Observer* observer); | 67 void RemoveObserver(Observer* observer); |
| 68 | 68 |
| 69 const DownloadUIItemsMap& GetAllItems() const; | 69 const DownloadUIItemsMap& GetAllItems() const; |
| 70 // May return nullptr. | 70 // May return nullptr. |
| 71 const DownloadUIItem* GetItem(const std::string& guid) const; | 71 const DownloadUIItem* GetItem(const std::string& guid) const; |
| 72 | 72 |
| 73 // Commands from UI. Start async operations, result is observable | |
| 74 // via Observer or directly by the user (as in 'open'). | |
| 75 void DeleteItem(const std::string& guid); | |
| 76 std::string GetOfflineUrlByGuid(guid); | |
|
fgorski
2016/08/09 04:00:51
this is where it does not compile.
Dmitry Titov
2016/08/12 04:01:39
Done.
| |
| 77 | |
|
fgorski
2016/08/09 04:00:51
nit: remove empty line
Dmitry Titov
2016/08/12 04:01:39
Done.
| |
| 78 | |
| 73 // OfflinePageModel::Observer | 79 // OfflinePageModel::Observer |
| 74 void OfflinePageModelLoaded(OfflinePageModel* model) override; | 80 void OfflinePageModelLoaded(OfflinePageModel* model) override; |
| 75 void OfflinePageModelChanged(OfflinePageModel* model) override; | 81 void OfflinePageModelChanged(OfflinePageModel* model) override; |
| 76 void OfflinePageDeleted(int64_t offline_id, | 82 void OfflinePageDeleted(int64_t offline_id, |
| 77 const ClientId& client_id) override; | 83 const ClientId& client_id) override; |
| 78 | 84 |
| 79 private: | 85 private: |
| 80 void LoadCache(); | 86 void LoadCache(); |
| 81 void ClearCache(); | 87 void ClearCache(); |
| 82 | 88 |
| 83 // Task callbacks. | 89 // Task callbacks. |
| 84 void OnOfflinePagesLoaded(const MultipleOfflinePageItemResult& pages); | 90 void OnOfflinePagesLoaded(const MultipleOfflinePageItemResult& pages); |
| 85 void NotifyItemsLoaded(Observer* observer); | 91 void NotifyItemsLoaded(Observer* observer); |
| 86 void OnOfflinePagesChanged(const MultipleOfflinePageItemResult& pages); | 92 void OnOfflinePagesChanged(const MultipleOfflinePageItemResult& pages); |
| 93 void OnDeleteItemByGuid( | |
| 94 const MultipleOfflinePageItemResult& pages, const std::string& guid); | |
| 95 void OnDeletePagesDone(bool success); | |
| 96 | |
| 97 OfflinePageItem* FindPageByGuid( | |
| 98 const MultipleOfflinePageItemResult& pages, const std::string& guid); | |
| 87 bool IsVisibleInUI(const OfflinePageItem& page); | 99 bool IsVisibleInUI(const OfflinePageItem& page); |
| 88 | 100 |
| 89 // Always valid, this class is a member of the model. | 101 // Always valid, this class is a member of the model. |
| 90 OfflinePageModel* model_; | 102 OfflinePageModel* model_; |
| 91 | 103 |
| 92 bool is_loaded_; | 104 bool is_loaded_; |
| 93 | 105 |
| 94 // The cache of UI items. | 106 // The cache of UI items. |
| 95 DownloadUIItemsMap items_; | 107 DownloadUIItemsMap items_; |
| 96 | 108 |
| 97 // The observers. | 109 // The observers. |
| 98 base::ObserverList<Observer> observers_; | 110 base::ObserverList<Observer> observers_; |
| 99 | 111 |
| 100 base::WeakPtrFactory<DownloadUIAdapter> weak_ptr_factory_; | 112 base::WeakPtrFactory<DownloadUIAdapter> weak_ptr_factory_; |
| 101 | 113 |
| 102 DISALLOW_COPY_AND_ASSIGN(DownloadUIAdapter); | 114 DISALLOW_COPY_AND_ASSIGN(DownloadUIAdapter); |
| 103 }; | 115 }; |
| 104 | 116 |
| 105 } // namespace offline_pages | 117 } // namespace offline_pages |
| 106 | 118 |
| 107 #endif // COMPONENTS_OFFLINE_PAGE_DOWNLOADS_DOWNLOAD_UI_ADAPTER_H_ | 119 #endif // COMPONENTS_OFFLINE_PAGE_DOWNLOADS_DOWNLOAD_UI_ADAPTER_H_ |
| OLD | NEW |