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

Side by Side Diff: device/hid/hid_service.cc

Issue 2423793002: Remove usage of FOR_EACH_OBSERVER macro in device/ (Closed)
Patch Set: rebase 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
« no previous file with comments | « device/generic_sensor/platform_sensor.cc ('k') | device/hid/input_service_linux.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "device/hid/hid_service.h" 5 #include "device/hid/hid_service.h"
6 6
7 #include "base/at_exit.h" 7 #include "base/at_exit.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 96
97 HID_LOG(USER) << "HID device " 97 HID_LOG(USER) << "HID device "
98 << (enumeration_ready_ ? "added" : "detected") 98 << (enumeration_ready_ ? "added" : "detected")
99 << ": vendorId=" << device_info->vendor_id() 99 << ": vendorId=" << device_info->vendor_id()
100 << ", productId=" << device_info->product_id() << ", name='" 100 << ", productId=" << device_info->product_id() << ", name='"
101 << device_info->product_name() << "', serial='" 101 << device_info->product_name() << "', serial='"
102 << device_info->serial_number() << "', deviceId='" 102 << device_info->serial_number() << "', deviceId='"
103 << device_info->device_id() << "'"; 103 << device_info->device_id() << "'";
104 104
105 if (enumeration_ready_) { 105 if (enumeration_ready_) {
106 FOR_EACH_OBSERVER(Observer, observer_list_, OnDeviceAdded(device_info)); 106 for (auto& observer : observer_list_)
107 observer.OnDeviceAdded(device_info);
107 } 108 }
108 } 109 }
109 } 110 }
110 111
111 void HidService::RemoveDevice(const HidDeviceId& device_id) { 112 void HidService::RemoveDevice(const HidDeviceId& device_id) {
112 DCHECK(thread_checker_.CalledOnValidThread()); 113 DCHECK(thread_checker_.CalledOnValidThread());
113 DeviceMap::iterator it = devices_.find(device_id); 114 DeviceMap::iterator it = devices_.find(device_id);
114 if (it != devices_.end()) { 115 if (it != devices_.end()) {
115 HID_LOG(USER) << "HID device removed: deviceId='" << device_id << "'"; 116 HID_LOG(USER) << "HID device removed: deviceId='" << device_id << "'";
116 117
117 scoped_refptr<HidDeviceInfo> device = it->second; 118 scoped_refptr<HidDeviceInfo> device = it->second;
118 if (enumeration_ready_) { 119 if (enumeration_ready_) {
119 FOR_EACH_OBSERVER(Observer, observer_list_, OnDeviceRemoved(device)); 120 for (auto& observer : observer_list_)
121 observer.OnDeviceRemoved(device);
120 } 122 }
121 devices_.erase(it); 123 devices_.erase(it);
122 if (enumeration_ready_) { 124 if (enumeration_ready_) {
123 FOR_EACH_OBSERVER(Observer, observer_list_, 125 for (auto& observer : observer_list_)
124 OnDeviceRemovedCleanup(device)); 126 observer.OnDeviceRemovedCleanup(device);
125 } 127 }
126 } 128 }
127 } 129 }
128 130
129 void HidService::FirstEnumerationComplete() { 131 void HidService::FirstEnumerationComplete() {
130 enumeration_ready_ = true; 132 enumeration_ready_ = true;
131 133
132 if (!pending_enumerations_.empty()) { 134 if (!pending_enumerations_.empty()) {
133 std::vector<scoped_refptr<HidDeviceInfo>> devices; 135 std::vector<scoped_refptr<HidDeviceInfo>> devices;
134 for (const auto& map_entry : devices_) { 136 for (const auto& map_entry : devices_) {
135 devices.push_back(map_entry.second); 137 devices.push_back(map_entry.second);
136 } 138 }
137 139
138 for (const GetDevicesCallback& callback : pending_enumerations_) { 140 for (const GetDevicesCallback& callback : pending_enumerations_) {
139 callback.Run(devices); 141 callback.Run(devices);
140 } 142 }
141 pending_enumerations_.clear(); 143 pending_enumerations_.clear();
142 } 144 }
143 } 145 }
144 146
145 } // namespace device 147 } // namespace device
OLDNEW
« no previous file with comments | « device/generic_sensor/platform_sensor.cc ('k') | device/hid/input_service_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698