| 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_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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 71 |
| 72 protected: | 72 protected: |
| 73 virtual ~Observer() = default; | 73 virtual ~Observer() = default; |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 DownloadUIAdapter(OfflinePageModel* model, | 76 DownloadUIAdapter(OfflinePageModel* model, |
| 77 RequestCoordinator* coordinator, | 77 RequestCoordinator* coordinator, |
| 78 std::unique_ptr<Delegate> delegate); | 78 std::unique_ptr<Delegate> delegate); |
| 79 ~DownloadUIAdapter() override; | 79 ~DownloadUIAdapter() override; |
| 80 | 80 |
| 81 static DownloadUIAdapter* FromOfflinePageModel(OfflinePageModel* model); |
| 82 static void AttachToOfflinePageModel(DownloadUIAdapter* adapter, |
| 83 OfflinePageModel* model); |
| 84 |
| 81 // This adapter is potentially shared by UI elements, each of which adds | 85 // This adapter is potentially shared by UI elements, each of which adds |
| 82 // itself as an observer. | 86 // itself as an observer. |
| 83 // When the last observer is removed, cached list of items is destroyed and | 87 // When the last observer is removed, cached list of items is destroyed and |
| 84 // next time the initial loading will take longer. | 88 // next time the initial loading will take longer. |
| 85 void AddObserver(Observer* observer); | 89 void AddObserver(Observer* observer); |
| 86 void RemoveObserver(Observer* observer); | 90 void RemoveObserver(Observer* observer); |
| 87 | 91 |
| 88 // Returns all UI items. The list contains references to items in the cache | 92 // Returns all UI items. The list contains references to items in the cache |
| 89 // and has to be used synchronously. | 93 // and has to be used synchronously. |
| 90 std::vector<const DownloadUIItem*> GetAllItems() const; | 94 std::vector<const DownloadUIItem*> GetAllItems() const; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 int observers_count_; | 184 int observers_count_; |
| 181 | 185 |
| 182 base::WeakPtrFactory<DownloadUIAdapter> weak_ptr_factory_; | 186 base::WeakPtrFactory<DownloadUIAdapter> weak_ptr_factory_; |
| 183 | 187 |
| 184 DISALLOW_COPY_AND_ASSIGN(DownloadUIAdapter); | 188 DISALLOW_COPY_AND_ASSIGN(DownloadUIAdapter); |
| 185 }; | 189 }; |
| 186 | 190 |
| 187 } // namespace offline_pages | 191 } // namespace offline_pages |
| 188 | 192 |
| 189 #endif // COMPONENTS_OFFLINE_PAGE_DOWNLOADS_DOWNLOAD_UI_ADAPTER_H_ | 193 #endif // COMPONENTS_OFFLINE_PAGE_DOWNLOADS_DOWNLOAD_UI_ADAPTER_H_ |
| OLD | NEW |