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 #include "components/offline_pages/core/downloads/download_ui_adapter.h" | 5 #include "components/offline_pages/core/downloads/download_ui_adapter.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/guid.h" | 8 #include "base/guid.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 // static | 26 // static |
27 DownloadUIAdapter* DownloadUIAdapter::FromOfflinePageModel( | 27 DownloadUIAdapter* DownloadUIAdapter::FromOfflinePageModel( |
28 OfflinePageModel* model) { | 28 OfflinePageModel* model) { |
29 DCHECK(model); | 29 DCHECK(model); |
30 return static_cast<DownloadUIAdapter*>( | 30 return static_cast<DownloadUIAdapter*>( |
31 model->GetUserData(kDownloadUIAdapterKey)); | 31 model->GetUserData(kDownloadUIAdapterKey)); |
32 } | 32 } |
33 | 33 |
34 // static | 34 // static |
35 void DownloadUIAdapter::AttachToOfflinePageModel(DownloadUIAdapter* adapter, | 35 void DownloadUIAdapter::AttachToOfflinePageModel( |
36 OfflinePageModel* model) { | 36 std::unique_ptr<DownloadUIAdapter> adapter, |
| 37 OfflinePageModel* model) { |
37 DCHECK(adapter); | 38 DCHECK(adapter); |
38 DCHECK(model); | 39 DCHECK(model); |
39 model->SetUserData(kDownloadUIAdapterKey, adapter); | 40 model->SetUserData(kDownloadUIAdapterKey, std::move(adapter)); |
40 } | 41 } |
41 | 42 |
42 DownloadUIAdapter::ItemInfo::ItemInfo(const OfflinePageItem& page, | 43 DownloadUIAdapter::ItemInfo::ItemInfo(const OfflinePageItem& page, |
43 bool temporarily_hidden) | 44 bool temporarily_hidden) |
44 : ui_item(base::MakeUnique<DownloadUIItem>(page)), | 45 : ui_item(base::MakeUnique<DownloadUIItem>(page)), |
45 is_request(false), | 46 is_request(false), |
46 offline_id(page.offline_id), | 47 offline_id(page.offline_id), |
47 client_id(page.client_id), | 48 client_id(page.client_id), |
48 temporarily_hidden(temporarily_hidden) {} | 49 temporarily_hidden(temporarily_hidden) {} |
49 | 50 |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 | 364 |
364 if (!deleting_item_->temporarily_hidden && state_ == State::LOADED) { | 365 if (!deleting_item_->temporarily_hidden && state_ == State::LOADED) { |
365 for (Observer& observer : observers_) | 366 for (Observer& observer : observers_) |
366 observer.ItemDeleted(guid); | 367 observer.ItemDeleted(guid); |
367 } | 368 } |
368 | 369 |
369 deleting_item_.reset(); | 370 deleting_item_.reset(); |
370 } | 371 } |
371 | 372 |
372 } // namespace offline_pages | 373 } // namespace offline_pages |
OLD | NEW |