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

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

Issue 2482463002: Remove DeviceMonitorLinux::WillDestroyCurrentMessageLoop(). (Closed)
Patch Set: CR achuithb #24 Created 4 years, 1 month 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/hid/hid_service.h ('k') | device/hid/hid_service_linux.h » ('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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 return base::WrapUnique(new HidServiceLinux(file_task_runner)); 42 return base::WrapUnique(new HidServiceLinux(file_task_runner));
43 #elif defined(OS_MACOSX) 43 #elif defined(OS_MACOSX)
44 return base::WrapUnique(new HidServiceMac(file_task_runner)); 44 return base::WrapUnique(new HidServiceMac(file_task_runner));
45 #elif defined(OS_WIN) 45 #elif defined(OS_WIN)
46 return base::WrapUnique(new HidServiceWin(file_task_runner)); 46 return base::WrapUnique(new HidServiceWin(file_task_runner));
47 #else 47 #else
48 return nullptr; 48 return nullptr;
49 #endif 49 #endif
50 } 50 }
51 51
52 void HidService::Shutdown() {
53 #if DCHECK_IS_ON()
54 DCHECK(!did_shutdown_);
55 did_shutdown_ = true;
56 #endif
57 }
58
52 void HidService::GetDevices(const GetDevicesCallback& callback) { 59 void HidService::GetDevices(const GetDevicesCallback& callback) {
53 DCHECK(thread_checker_.CalledOnValidThread()); 60 DCHECK(thread_checker_.CalledOnValidThread());
54 if (enumeration_ready_) { 61 if (enumeration_ready_) {
55 std::vector<scoped_refptr<HidDeviceInfo>> devices; 62 std::vector<scoped_refptr<HidDeviceInfo>> devices;
56 for (const auto& map_entry : devices_) { 63 for (const auto& map_entry : devices_) {
57 devices.push_back(map_entry.second); 64 devices.push_back(map_entry.second);
58 } 65 }
59 base::ThreadTaskRunnerHandle::Get()->PostTask( 66 base::ThreadTaskRunnerHandle::Get()->PostTask(
60 FROM_HERE, base::Bind(callback, devices)); 67 FROM_HERE, base::Bind(callback, devices));
61 } else { 68 } else {
(...skipping 13 matching lines...) Expand all
75 scoped_refptr<HidDeviceInfo> HidService::GetDeviceInfo( 82 scoped_refptr<HidDeviceInfo> HidService::GetDeviceInfo(
76 const HidDeviceId& device_id) const { 83 const HidDeviceId& device_id) const {
77 DCHECK(thread_checker_.CalledOnValidThread()); 84 DCHECK(thread_checker_.CalledOnValidThread());
78 DeviceMap::const_iterator it = devices_.find(device_id); 85 DeviceMap::const_iterator it = devices_.find(device_id);
79 if (it == devices_.end()) { 86 if (it == devices_.end()) {
80 return nullptr; 87 return nullptr;
81 } 88 }
82 return it->second; 89 return it->second;
83 } 90 }
84 91
85 HidService::HidService() : enumeration_ready_(false) { 92 HidService::HidService() = default;
86 }
87 93
88 HidService::~HidService() { 94 HidService::~HidService() {
89 DCHECK(thread_checker_.CalledOnValidThread()); 95 DCHECK(thread_checker_.CalledOnValidThread());
96 #if DCHECK_IS_ON()
97 DCHECK(did_shutdown_);
98 #endif
90 } 99 }
91 100
92 void HidService::AddDevice(scoped_refptr<HidDeviceInfo> device_info) { 101 void HidService::AddDevice(scoped_refptr<HidDeviceInfo> device_info) {
93 DCHECK(thread_checker_.CalledOnValidThread()); 102 DCHECK(thread_checker_.CalledOnValidThread());
94 if (!base::ContainsKey(devices_, device_info->device_id())) { 103 if (!base::ContainsKey(devices_, device_info->device_id())) {
95 devices_[device_info->device_id()] = device_info; 104 devices_[device_info->device_id()] = device_info;
96 105
97 HID_LOG(USER) << "HID device " 106 HID_LOG(USER) << "HID device "
98 << (enumeration_ready_ ? "added" : "detected") 107 << (enumeration_ready_ ? "added" : "detected")
99 << ": vendorId=" << device_info->vendor_id() 108 << ": vendorId=" << device_info->vendor_id()
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 } 147 }
139 148
140 for (const GetDevicesCallback& callback : pending_enumerations_) { 149 for (const GetDevicesCallback& callback : pending_enumerations_) {
141 callback.Run(devices); 150 callback.Run(devices);
142 } 151 }
143 pending_enumerations_.clear(); 152 pending_enumerations_.clear();
144 } 153 }
145 } 154 }
146 155
147 } // namespace device 156 } // namespace device
OLDNEW
« no previous file with comments | « device/hid/hid_service.h ('k') | device/hid/hid_service_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698