| 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 "ios/chrome/browser/reading_list/reading_list_model.h" | 5 #include "ios/chrome/browser/reading_list/reading_list_model.h" |
| 6 | 6 |
| 7 ReadingListModel::ReadingListModel() : current_batch_updates_count_(0) {} | 7 ReadingListModel::ReadingListModel() : current_batch_updates_count_(0) {} |
| 8 ReadingListModel::~ReadingListModel() {} | 8 ReadingListModel::~ReadingListModel() {} |
| 9 | 9 |
| 10 // Observer methods. | 10 // Observer methods. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 return current_batch_updates_count_ > 0; | 25 return current_batch_updates_count_ > 0; |
| 26 } | 26 } |
| 27 | 27 |
| 28 std::unique_ptr<ReadingListModel::ScopedReadingListBatchUpdate> | 28 std::unique_ptr<ReadingListModel::ScopedReadingListBatchUpdate> |
| 29 ReadingListModel::BeginBatchUpdates() { | 29 ReadingListModel::BeginBatchUpdates() { |
| 30 std::unique_ptr<ReadingListModel::ScopedReadingListBatchUpdate> token( | 30 std::unique_ptr<ReadingListModel::ScopedReadingListBatchUpdate> token( |
| 31 new ReadingListModel::ScopedReadingListBatchUpdate(this)); | 31 new ReadingListModel::ScopedReadingListBatchUpdate(this)); |
| 32 | 32 |
| 33 ++current_batch_updates_count_; | 33 ++current_batch_updates_count_; |
| 34 if (current_batch_updates_count_ == 1) { | 34 if (current_batch_updates_count_ == 1) { |
| 35 FOR_EACH_OBSERVER(ReadingListModelObserver, observers_, | 35 for (auto& observer : observers_) |
| 36 ReadingListModelBeganBatchUpdates(this)); | 36 observer.ReadingListModelBeganBatchUpdates(this); |
| 37 } | 37 } |
| 38 return token; | 38 return token; |
| 39 } | 39 } |
| 40 | 40 |
| 41 void ReadingListModel::EndBatchUpdates() { | 41 void ReadingListModel::EndBatchUpdates() { |
| 42 DCHECK(IsPerformingBatchUpdates()); | 42 DCHECK(IsPerformingBatchUpdates()); |
| 43 --current_batch_updates_count_; | 43 --current_batch_updates_count_; |
| 44 if (current_batch_updates_count_ == 0) { | 44 if (current_batch_updates_count_ == 0) { |
| 45 FOR_EACH_OBSERVER(ReadingListModelObserver, observers_, | 45 for (auto& observer : observers_) |
| 46 ReadingListModelCompletedBatchUpdates(this)); | 46 observer.ReadingListModelCompletedBatchUpdates(this); |
| 47 } | 47 } |
| 48 } | 48 } |
| OLD | NEW |