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

Side by Side Diff: components/sessions/core/tab_restore_service_helper.cc

Issue 2430823002: Reduce usage of FOR_EACH_OBSERVER macro in components/ (Closed)
Patch Set: Created 4 years, 2 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/sessions/core/tab_restore_service_helper.h" 5 #include "components/sessions/core/tab_restore_service_helper.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <iterator> 10 #include <iterator>
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 TabRestoreService::TimeFactory* time_factory) 44 TabRestoreService::TimeFactory* time_factory)
45 : tab_restore_service_(tab_restore_service), 45 : tab_restore_service_(tab_restore_service),
46 observer_(observer), 46 observer_(observer),
47 client_(client), 47 client_(client),
48 restoring_(false), 48 restoring_(false),
49 time_factory_(time_factory) { 49 time_factory_(time_factory) {
50 DCHECK(tab_restore_service_); 50 DCHECK(tab_restore_service_);
51 } 51 }
52 52
53 TabRestoreServiceHelper::~TabRestoreServiceHelper() { 53 TabRestoreServiceHelper::~TabRestoreServiceHelper() {
54 FOR_EACH_OBSERVER(TabRestoreServiceObserver, observer_list_, 54 for (auto& observer : observer_list_)
55 TabRestoreServiceDestroyed(tab_restore_service_)); 55 observer.TabRestoreServiceDestroyed(tab_restore_service_);
56 } 56 }
57 57
58 void TabRestoreServiceHelper::AddObserver( 58 void TabRestoreServiceHelper::AddObserver(
59 TabRestoreServiceObserver* observer) { 59 TabRestoreServiceObserver* observer) {
60 observer_list_.AddObserver(observer); 60 observer_list_.AddObserver(observer);
61 } 61 }
62 62
63 void TabRestoreServiceHelper::RemoveObserver( 63 void TabRestoreServiceHelper::RemoveObserver(
64 TabRestoreServiceObserver* observer) { 64 TabRestoreServiceObserver* observer) {
65 observer_list_.RemoveObserver(observer); 65 observer_list_.RemoveObserver(observer);
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 restoring_ = false; 258 restoring_ = false;
259 NotifyTabsChanged(); 259 NotifyTabsChanged();
260 return live_tabs; 260 return live_tabs;
261 } 261 }
262 262
263 bool TabRestoreServiceHelper::IsRestoring() const { 263 bool TabRestoreServiceHelper::IsRestoring() const {
264 return restoring_; 264 return restoring_;
265 } 265 }
266 266
267 void TabRestoreServiceHelper::NotifyTabsChanged() { 267 void TabRestoreServiceHelper::NotifyTabsChanged() {
268 FOR_EACH_OBSERVER(TabRestoreServiceObserver, observer_list_, 268 for (auto& observer : observer_list_)
269 TabRestoreServiceChanged(tab_restore_service_)); 269 observer.TabRestoreServiceChanged(tab_restore_service_);
270 } 270 }
271 271
272 void TabRestoreServiceHelper::NotifyLoaded() { 272 void TabRestoreServiceHelper::NotifyLoaded() {
273 FOR_EACH_OBSERVER(TabRestoreServiceObserver, observer_list_, 273 for (auto& observer : observer_list_)
274 TabRestoreServiceLoaded(tab_restore_service_)); 274 observer.TabRestoreServiceLoaded(tab_restore_service_);
275 } 275 }
276 276
277 void TabRestoreServiceHelper::AddEntry(std::unique_ptr<Entry> entry, 277 void TabRestoreServiceHelper::AddEntry(std::unique_ptr<Entry> entry,
278 bool notify, 278 bool notify,
279 bool to_front) { 279 bool to_front) {
280 if (!FilterEntry(*entry) || (entries_.size() >= kMaxEntries && !to_front)) { 280 if (!FilterEntry(*entry) || (entries_.size() >= kMaxEntries && !to_front)) {
281 return; 281 return;
282 } 282 }
283 283
284 if (to_front) 284 if (to_front)
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 tab.browser_id = new_id; 488 tab.browser_id = new_id;
489 } 489 }
490 } 490 }
491 } 491 }
492 492
493 base::Time TabRestoreServiceHelper::TimeNow() const { 493 base::Time TabRestoreServiceHelper::TimeNow() const {
494 return time_factory_ ? time_factory_->TimeNow() : base::Time::Now(); 494 return time_factory_ ? time_factory_->TimeNow() : base::Time::Now();
495 } 495 }
496 496
497 } // namespace sessions 497 } // namespace sessions
OLDNEW
« no previous file with comments | « components/search_provider_logos/logo_tracker.cc ('k') | components/syncable_prefs/pref_model_associator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698