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

Side by Side Diff: components/arc/instance_holder.h

Issue 2416633002: Remove FOR_EACH_OBSERVER from arc/ since it's being deprecated (Closed)
Patch Set: remove braces 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #ifndef COMPONENTS_ARC_INSTANCE_HOLDER_H_ 5 #ifndef COMPONENTS_ARC_INSTANCE_HOLDER_H_
6 #define COMPONENTS_ARC_INSTANCE_HOLDER_H_ 6 #define COMPONENTS_ARC_INSTANCE_HOLDER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 DCHECK(instance == nullptr || instance_ == nullptr); 92 DCHECK(instance == nullptr || instance_ == nullptr);
93 93
94 // Note: This can be called with nullptr even if |instance_| is still 94 // Note: This can be called with nullptr even if |instance_| is still
95 // nullptr for just in case clean up purpose. No-op in such a case. 95 // nullptr for just in case clean up purpose. No-op in such a case.
96 if (instance == instance_) 96 if (instance == instance_)
97 return; 97 return;
98 98
99 instance_ = instance; 99 instance_ = instance;
100 version_ = version; 100 version_ = version;
101 if (instance_) { 101 if (instance_) {
102 FOR_EACH_OBSERVER(Observer, observer_list_, OnInstanceReady()); 102 for (auto& observer : observer_list_)
103 observer.OnInstanceReady();
103 } else { 104 } else {
104 FOR_EACH_OBSERVER(Observer, observer_list_, OnInstanceClosed()); 105 for (auto& observer : observer_list_)
106 observer.OnInstanceClosed();
105 } 107 }
106 } 108 }
107 109
108 private: 110 private:
109 // This class does not have ownership. The pointers should be managed by the 111 // This class does not have ownership. The pointers should be managed by the
110 // callee. 112 // callee.
111 T* instance_ = nullptr; 113 T* instance_ = nullptr;
112 uint32_t version_ = 0; 114 uint32_t version_ = 0;
113 115
114 base::ThreadChecker thread_checker_; 116 base::ThreadChecker thread_checker_;
115 base::ObserverList<Observer> observer_list_; 117 base::ObserverList<Observer> observer_list_;
116 118
117 DISALLOW_COPY_AND_ASSIGN(InstanceHolder<T>); 119 DISALLOW_COPY_AND_ASSIGN(InstanceHolder<T>);
118 }; 120 };
119 121
120 } // namespace arc 122 } // namespace arc
121 123
122 #endif // COMPONENTS_ARC_INSTANCE_HOLDER_H_ 124 #endif // COMPONENTS_ARC_INSTANCE_HOLDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698