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

Side by Side Diff: device/usb/usb_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/usb/usb_device.cc ('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 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 "device/usb/usb_service.h" 5 #include "device/usb/usb_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #elif defined(OS_WIN) || defined(OS_MACOSX) 46 #elif defined(OS_WIN) || defined(OS_MACOSX)
47 return base::WrapUnique(new UsbServiceImpl(blocking_task_runner)); 47 return base::WrapUnique(new UsbServiceImpl(blocking_task_runner));
48 #else 48 #else
49 return nullptr; 49 return nullptr;
50 #endif 50 #endif
51 } 51 }
52 52
53 UsbService::~UsbService() { 53 UsbService::~UsbService() {
54 for (const auto& map_entry : devices_) 54 for (const auto& map_entry : devices_)
55 map_entry.second->OnDisconnect(); 55 map_entry.second->OnDisconnect();
56 FOR_EACH_OBSERVER(Observer, observer_list_, WillDestroyUsbService()); 56 for (auto& observer : observer_list_)
57 observer.WillDestroyUsbService();
57 } 58 }
58 59
59 UsbService::UsbService( 60 UsbService::UsbService(
60 scoped_refptr<base::SingleThreadTaskRunner> task_runner, 61 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
61 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner) 62 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner)
62 : task_runner_(task_runner), blocking_task_runner_(blocking_task_runner) {} 63 : task_runner_(task_runner), blocking_task_runner_(blocking_task_runner) {}
63 64
64 scoped_refptr<UsbDevice> UsbService::GetDevice(const std::string& guid) { 65 scoped_refptr<UsbDevice> UsbService::GetDevice(const std::string& guid) {
65 DCHECK(CalledOnValidThread()); 66 DCHECK(CalledOnValidThread());
66 auto it = devices_.find(guid); 67 auto it = devices_.find(guid);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 for (const std::string& guid : testing_devices_) { 121 for (const std::string& guid : testing_devices_) {
121 auto it = devices_.find(guid); 122 auto it = devices_.find(guid);
122 DCHECK(it != devices_.end()); 123 DCHECK(it != devices_.end());
123 devices->push_back(it->second); 124 devices->push_back(it->second);
124 } 125 }
125 } 126 }
126 127
127 void UsbService::NotifyDeviceAdded(scoped_refptr<UsbDevice> device) { 128 void UsbService::NotifyDeviceAdded(scoped_refptr<UsbDevice> device) {
128 DCHECK(CalledOnValidThread()); 129 DCHECK(CalledOnValidThread());
129 130
130 FOR_EACH_OBSERVER(Observer, observer_list_, OnDeviceAdded(device)); 131 for (auto& observer : observer_list_)
132 observer.OnDeviceAdded(device);
131 } 133 }
132 134
133 void UsbService::NotifyDeviceRemoved(scoped_refptr<UsbDevice> device) { 135 void UsbService::NotifyDeviceRemoved(scoped_refptr<UsbDevice> device) {
134 DCHECK(CalledOnValidThread()); 136 DCHECK(CalledOnValidThread());
135 137
136 FOR_EACH_OBSERVER(Observer, observer_list_, OnDeviceRemoved(device)); 138 for (auto& observer : observer_list_)
139 observer.OnDeviceRemoved(device);
137 device->NotifyDeviceRemoved(); 140 device->NotifyDeviceRemoved();
138 FOR_EACH_OBSERVER(Observer, observer_list_, OnDeviceRemovedCleanup(device)); 141 for (auto& observer : observer_list_)
142 observer.OnDeviceRemovedCleanup(device);
139 } 143 }
140 144
141 } // namespace device 145 } // namespace device
OLDNEW
« no previous file with comments | « device/usb/usb_device.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698