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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 protected: | 76 protected: |
77 virtual ~Observer() = default; | 77 virtual ~Observer() = default; |
78 }; | 78 }; |
79 | 79 |
80 DownloadUIAdapter(OfflinePageModel* model, | 80 DownloadUIAdapter(OfflinePageModel* model, |
81 RequestCoordinator* coordinator, | 81 RequestCoordinator* coordinator, |
82 std::unique_ptr<Delegate> delegate); | 82 std::unique_ptr<Delegate> delegate); |
83 ~DownloadUIAdapter() override; | 83 ~DownloadUIAdapter() override; |
84 | 84 |
85 static DownloadUIAdapter* FromOfflinePageModel(OfflinePageModel* model); | 85 static DownloadUIAdapter* FromOfflinePageModel(OfflinePageModel* model); |
86 static void AttachToOfflinePageModel(DownloadUIAdapter* adapter, | 86 static void AttachToOfflinePageModel( |
87 OfflinePageModel* model); | 87 std::unique_ptr<DownloadUIAdapter> adapter, |
| 88 OfflinePageModel* model); |
88 | 89 |
89 // This adapter is potentially shared by UI elements, each of which adds | 90 // This adapter is potentially shared by UI elements, each of which adds |
90 // itself as an observer. | 91 // itself as an observer. |
91 // When the last observer is removed, cached list of items is destroyed and | 92 // When the last observer is removed, cached list of items is destroyed and |
92 // next time the initial loading will take longer. | 93 // next time the initial loading will take longer. |
93 void AddObserver(Observer* observer); | 94 void AddObserver(Observer* observer); |
94 void RemoveObserver(Observer* observer); | 95 void RemoveObserver(Observer* observer); |
95 | 96 |
96 // Returns all UI items. The list contains references to items in the cache | 97 // Returns all UI items. The list contains references to items in the cache |
97 // and has to be used synchronously. | 98 // and has to be used synchronously. |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 int observers_count_; | 197 int observers_count_; |
197 | 198 |
198 base::WeakPtrFactory<DownloadUIAdapter> weak_ptr_factory_; | 199 base::WeakPtrFactory<DownloadUIAdapter> weak_ptr_factory_; |
199 | 200 |
200 DISALLOW_COPY_AND_ASSIGN(DownloadUIAdapter); | 201 DISALLOW_COPY_AND_ASSIGN(DownloadUIAdapter); |
201 }; | 202 }; |
202 | 203 |
203 } // namespace offline_pages | 204 } // namespace offline_pages |
204 | 205 |
205 #endif // COMPONENTS_OFFLINE_PAGE_DOWNLOADS_DOWNLOAD_UI_ADAPTER_H_ | 206 #endif // COMPONENTS_OFFLINE_PAGE_DOWNLOADS_DOWNLOAD_UI_ADAPTER_H_ |
OLD | NEW |