| 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 #include "components/ntp_snippets/offline_pages/offline_page_proxy.h" | 5 #include "components/ntp_snippets/offline_pages/offline_page_proxy.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 | 8 |
| 9 using offline_pages::MultipleOfflinePageItemResult; | 9 using offline_pages::MultipleOfflinePageItemResult; |
| 10 using offline_pages::MultipleOfflinePageItemCallback; | 10 using offline_pages::MultipleOfflinePageItemCallback; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 } | 42 } |
| 43 | 43 |
| 44 void OfflinePageProxy::OfflinePageModelChanged(OfflinePageModel* model) { | 44 void OfflinePageProxy::OfflinePageModelChanged(OfflinePageModel* model) { |
| 45 DCHECK_EQ(offline_page_model_, model); | 45 DCHECK_EQ(offline_page_model_, model); |
| 46 FetchOfflinePagesAndNotify(); | 46 FetchOfflinePagesAndNotify(); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void OfflinePageProxy::OfflinePageDeleted( | 49 void OfflinePageProxy::OfflinePageDeleted( |
| 50 int64_t offline_id, | 50 int64_t offline_id, |
| 51 const offline_pages::ClientId& client_id) { | 51 const offline_pages::ClientId& client_id) { |
| 52 FOR_EACH_OBSERVER(Observer, observers_, | 52 for (Observer& observer : observers_) |
| 53 OfflinePageDeleted(offline_id, client_id)); | 53 observer.OfflinePageDeleted(offline_id, client_id); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void OfflinePageProxy::FetchOfflinePagesAndNotify() { | 56 void OfflinePageProxy::FetchOfflinePagesAndNotify() { |
| 57 offline_page_model_->GetAllPages(base::Bind( | 57 offline_page_model_->GetAllPages(base::Bind( |
| 58 &OfflinePageProxy::OnOfflinePagesLoaded, weak_ptr_factory_.GetWeakPtr())); | 58 &OfflinePageProxy::OnOfflinePagesLoaded, weak_ptr_factory_.GetWeakPtr())); |
| 59 } | 59 } |
| 60 | 60 |
| 61 void OfflinePageProxy::OnOfflinePagesLoaded( | 61 void OfflinePageProxy::OnOfflinePagesLoaded( |
| 62 const MultipleOfflinePageItemResult& result) { | 62 const MultipleOfflinePageItemResult& result) { |
| 63 FOR_EACH_OBSERVER(Observer, observers_, OfflinePageModelChanged(result)); | 63 for (Observer& observer : observers_) |
| 64 observer.OfflinePageModelChanged(result); |
| 64 } | 65 } |
| 65 | 66 |
| 66 } // namespace ntp_snippets | 67 } // namespace ntp_snippets |
| OLD | NEW |