Chromium Code Reviews| 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/ntp_snippets/reading_list/reading_list_suggestions_provider .h" | 5 #include "components/ntp_snippets/reading_list/reading_list_suggestions_provider .h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 FetchReadingListInternal(); | 120 FetchReadingListInternal(); |
| 121 } | 121 } |
| 122 | 122 |
| 123 void ReadingListSuggestionsProvider::ReadingListModelBeingDeleted( | 123 void ReadingListSuggestionsProvider::ReadingListModelBeingDeleted( |
| 124 const ReadingListModel* model) { | 124 const ReadingListModel* model) { |
| 125 DCHECK(model == reading_list_model_); | 125 DCHECK(model == reading_list_model_); |
| 126 scoped_observer_.Remove(reading_list_model_); | 126 scoped_observer_.Remove(reading_list_model_); |
| 127 reading_list_model_ = nullptr; | 127 reading_list_model_ = nullptr; |
| 128 } | 128 } |
| 129 | 129 |
| 130 void ReadingListSuggestionsProvider::ReadingListDidApplyChanges( | |
| 131 ReadingListModel* model) { | |
| 132 DCHECK(model == reading_list_model_); | |
| 133 | |
| 134 FetchReadingListInternal(); | |
| 135 } | |
| 136 | |
| 137 void ReadingListSuggestionsProvider::ReadingListModelCompletedBatchUpdates( | |
| 138 const ReadingListModel* model) { | |
| 139 DCHECK(model == reading_list_model_); | |
| 140 | |
| 141 FetchReadingListInternal(); | |
| 142 } | |
| 143 | |
| 130 void ReadingListSuggestionsProvider::FetchReadingListInternal() { | 144 void ReadingListSuggestionsProvider::FetchReadingListInternal() { |
| 131 if (!reading_list_model_) | 145 if (!reading_list_model_) |
| 132 return; | 146 return; |
| 133 | 147 |
| 148 if (reading_list_model_->IsPerformingBatchUpdates()) | |
|
Olivier
2017/04/03 13:13:53
super nit: group with the if above.
Marc Treib
2017/04/04 16:57:49
nit: Braces please, also above
gambard
2017/04/05 08:08:55
Done.
gambard
2017/04/05 08:08:55
Done.
| |
| 149 return; | |
| 150 | |
| 134 DCHECK(reading_list_model_->loaded()); | 151 DCHECK(reading_list_model_->loaded()); |
| 135 std::vector<const ReadingListEntry*> entries; | 152 std::vector<const ReadingListEntry*> entries; |
| 136 for (const GURL& url : reading_list_model_->Keys()) { | 153 for (const GURL& url : reading_list_model_->Keys()) { |
| 137 const ReadingListEntry* entry = reading_list_model_->GetEntryByURL(url); | 154 const ReadingListEntry* entry = reading_list_model_->GetEntryByURL(url); |
| 138 if (!entry->IsRead()) { | 155 if (!entry->IsRead()) { |
| 139 entries.emplace_back(entry); | 156 entries.emplace_back(entry); |
| 140 } | 157 } |
| 141 } | 158 } |
| 142 | 159 |
| 143 if (entries.size() > kMaxEntries) { | 160 if (entries.size() > kMaxEntries) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 185 void ReadingListSuggestionsProvider::NotifyStatusChanged( | 202 void ReadingListSuggestionsProvider::NotifyStatusChanged( |
| 186 CategoryStatus new_status) { | 203 CategoryStatus new_status) { |
| 187 if (category_status_ == new_status) { | 204 if (category_status_ == new_status) { |
| 188 return; | 205 return; |
| 189 } | 206 } |
| 190 category_status_ = new_status; | 207 category_status_ = new_status; |
| 191 observer()->OnCategoryStatusChanged(this, provided_category_, new_status); | 208 observer()->OnCategoryStatusChanged(this, provided_category_, new_status); |
| 192 } | 209 } |
| 193 | 210 |
| 194 } // namespace ntp_snippets | 211 } // namespace ntp_snippets |
| OLD | NEW |