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

Side by Side Diff: chromeos/dbus/metronome_client.cc

Issue 1162943002: Replace more ObserverList with base::ObserverList. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@observer
Patch Set: Created 5 years, 6 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 | « chromeos/dbus/leadership_daemon_manager_client.cc ('k') | chromeos/dbus/nfc_adapter_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chromeos/dbus/metronome_client.h" 5 #include "chromeos/dbus/metronome_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/rand_util.h" 8 #include "base/rand_util.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 void OnSignalConnected(const std::string& interface, 58 void OnSignalConnected(const std::string& interface,
59 const std::string& signal, 59 const std::string& signal,
60 bool succeeded); 60 bool succeeded);
61 61
62 dbus::ObjectProxy* proxy_; 62 dbus::ObjectProxy* proxy_;
63 63
64 // True when |proxy_| has been connected. 64 // True when |proxy_| has been connected.
65 bool signal_connected_; 65 bool signal_connected_;
66 66
67 // List of observers interested in event notifications from us. 67 // List of observers interested in event notifications from us.
68 ObserverList<Observer> observers_; 68 base::ObserverList<Observer> observers_;
69 69
70 // Note: This should remain the last member so it'll be destroyed and 70 // Note: This should remain the last member so it'll be destroyed and
71 // invalidate its weak pointers before any other members are destroyed. 71 // invalidate its weak pointers before any other members are destroyed.
72 base::WeakPtrFactory<MetronomeClientImpl> weak_ptr_factory_; 72 base::WeakPtrFactory<MetronomeClientImpl> weak_ptr_factory_;
73 73
74 DISALLOW_COPY_AND_ASSIGN(MetronomeClientImpl); 74 DISALLOW_COPY_AND_ASSIGN(MetronomeClientImpl);
75 }; 75 };
76 76
77 void MetronomeClientImpl::AddObserver(Observer* observer) { 77 void MetronomeClientImpl::AddObserver(Observer* observer) {
78 DCHECK(observer); 78 DCHECK(observer);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 base::RandInt(-1000, 1000); 159 base::RandInt(-1000, 1000);
160 FOR_EACH_OBSERVER( 160 FOR_EACH_OBSERVER(
161 Observer, observers_, 161 Observer, observers_,
162 OnTimestampUpdated(fake_beacon_timestamp, fake_local_timestamp)); 162 OnTimestampUpdated(fake_beacon_timestamp, fake_local_timestamp));
163 } 163 }
164 164
165 int64 random_offset_; 165 int64 random_offset_;
166 base::RepeatingTimer<MetronomeClientFakeImpl> beacon_timer_; 166 base::RepeatingTimer<MetronomeClientFakeImpl> beacon_timer_;
167 167
168 // List of observers interested in event notifications from us. 168 // List of observers interested in event notifications from us.
169 ObserverList<Observer> observers_; 169 base::ObserverList<Observer> observers_;
170 170
171 DISALLOW_COPY_AND_ASSIGN(MetronomeClientFakeImpl); 171 DISALLOW_COPY_AND_ASSIGN(MetronomeClientFakeImpl);
172 }; 172 };
173 173
174 //////////////////////////////////////////////////////////////////////////////// 174 ////////////////////////////////////////////////////////////////////////////////
175 175
176 // A stub implementation of MetronomeClient. It allows unit tests to complete. 176 // A stub implementation of MetronomeClient. It allows unit tests to complete.
177 class MetronomeClientStubImpl : public MetronomeClient { 177 class MetronomeClientStubImpl : public MetronomeClient {
178 public: 178 public:
179 MetronomeClientStubImpl() {} 179 MetronomeClientStubImpl() {}
(...skipping 27 matching lines...) Expand all
207 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); 207 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type);
208 208
209 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 209 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
210 switches::kTestMetronomeTimer)) { 210 switches::kTestMetronomeTimer)) {
211 return new MetronomeClientFakeImpl(); 211 return new MetronomeClientFakeImpl();
212 } 212 }
213 return new MetronomeClientStubImpl(); 213 return new MetronomeClientStubImpl();
214 } 214 }
215 215
216 } // namespace chromeos 216 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/leadership_daemon_manager_client.cc ('k') | chromeos/dbus/nfc_adapter_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698