Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1283)

Side by Side Diff: components/ntp_snippets/reading_list/reading_list_suggestions_provider.cc

Issue 2794853004: Update provider on Reading List model update (Closed)
Patch Set: Address comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/ntp_snippets/reading_list/reading_list_suggestions_provider.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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_ || reading_list_model_->IsPerformingBatchUpdates()) {
132 return; 146 return;
147 }
133 148
134 DCHECK(reading_list_model_->loaded()); 149 DCHECK(reading_list_model_->loaded());
135 std::vector<const ReadingListEntry*> entries; 150 std::vector<const ReadingListEntry*> entries;
136 for (const GURL& url : reading_list_model_->Keys()) { 151 for (const GURL& url : reading_list_model_->Keys()) {
137 const ReadingListEntry* entry = reading_list_model_->GetEntryByURL(url); 152 const ReadingListEntry* entry = reading_list_model_->GetEntryByURL(url);
138 if (!entry->IsRead()) { 153 if (!entry->IsRead()) {
139 entries.emplace_back(entry); 154 entries.emplace_back(entry);
140 } 155 }
141 } 156 }
142 157
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 void ReadingListSuggestionsProvider::NotifyStatusChanged( 200 void ReadingListSuggestionsProvider::NotifyStatusChanged(
186 CategoryStatus new_status) { 201 CategoryStatus new_status) {
187 if (category_status_ == new_status) { 202 if (category_status_ == new_status) {
188 return; 203 return;
189 } 204 }
190 category_status_ = new_status; 205 category_status_ = new_status;
191 observer()->OnCategoryStatusChanged(this, provided_category_, new_status); 206 observer()->OnCategoryStatusChanged(this, provided_category_, new_status);
192 } 207 }
193 208
194 } // namespace ntp_snippets 209 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « components/ntp_snippets/reading_list/reading_list_suggestions_provider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698