| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_linux.h" | 5 #include "device/usb/usb_service_linux.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/files/file.h" | 12 #include "base/files/file.h" |
| 13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 14 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
| 15 #include "base/location.h" | 15 #include "base/location.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/memory/ptr_util.h" | 17 #include "base/memory/ptr_util.h" |
| 18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 19 #include "base/scoped_observer.h" | 19 #include "base/scoped_observer.h" |
| 20 #include "base/single_thread_task_runner.h" | 20 #include "base/single_thread_task_runner.h" |
| 21 #include "base/stl_util.h" | 21 #include "base/stl_util.h" |
| 22 #include "base/strings/string_number_conversions.h" | 22 #include "base/strings/string_number_conversions.h" |
| 23 #include "base/strings/utf_string_conversions.h" | 23 #include "base/strings/utf_string_conversions.h" |
| 24 #include "base/threading/thread_restrictions.h" | 24 #include "base/threading/thread_restrictions.h" |
| 25 #include "base/threading/thread_task_runner_handle.h" | |
| 26 #include "build/build_config.h" | 25 #include "build/build_config.h" |
| 27 #include "components/device_event_log/device_event_log.h" | 26 #include "components/device_event_log/device_event_log.h" |
| 28 #include "device/base/device_monitor_linux.h" | 27 #include "device/base/device_monitor_linux.h" |
| 29 #include "device/usb/usb_device_handle.h" | 28 #include "device/usb/usb_device_handle.h" |
| 30 #include "device/usb/usb_device_linux.h" | 29 #include "device/usb/usb_device_linux.h" |
| 31 #include "device/usb/webusb_descriptors.h" | 30 #include "device/usb/webusb_descriptors.h" |
| 32 | 31 |
| 33 namespace device { | 32 namespace device { |
| 34 | 33 |
| 35 namespace { | 34 namespace { |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 const char* device_path = udev_device_get_devnode(device); | 177 const char* device_path = udev_device_get_devnode(device); |
| 179 if (device_path) { | 178 if (device_path) { |
| 180 task_runner_->PostTask( | 179 task_runner_->PostTask( |
| 181 FROM_HERE, base::Bind(&UsbServiceLinux::OnDeviceRemoved, service_, | 180 FROM_HERE, base::Bind(&UsbServiceLinux::OnDeviceRemoved, service_, |
| 182 std::string(device_path))); | 181 std::string(device_path))); |
| 183 } | 182 } |
| 184 } | 183 } |
| 185 | 184 |
| 186 UsbServiceLinux::UsbServiceLinux( | 185 UsbServiceLinux::UsbServiceLinux( |
| 187 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_in) | 186 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_in) |
| 188 : UsbService(base::ThreadTaskRunnerHandle::Get(), | 187 : UsbService(std::move(blocking_task_runner_in)), weak_factory_(this) { |
| 189 std::move(blocking_task_runner_in)), | |
| 190 weak_factory_(this) { | |
| 191 helper_ = base::MakeUnique<FileThreadHelper>(weak_factory_.GetWeakPtr(), | 188 helper_ = base::MakeUnique<FileThreadHelper>(weak_factory_.GetWeakPtr(), |
| 192 task_runner()); | 189 task_runner()); |
| 193 blocking_task_runner()->PostTask( | 190 blocking_task_runner()->PostTask( |
| 194 FROM_HERE, | 191 FROM_HERE, |
| 195 base::Bind(&FileThreadHelper::Start, base::Unretained(helper_.get()))); | 192 base::Bind(&FileThreadHelper::Start, base::Unretained(helper_.get()))); |
| 196 } | 193 } |
| 197 | 194 |
| 198 UsbServiceLinux::~UsbServiceLinux() { | 195 UsbServiceLinux::~UsbServiceLinux() { |
| 199 DCHECK(!helper_); | 196 DCHECK(!helper_); |
| 200 } | 197 } |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 result.reserve(devices().size()); | 315 result.reserve(devices().size()); |
| 319 for (const auto& map_entry : devices()) | 316 for (const auto& map_entry : devices()) |
| 320 result.push_back(map_entry.second); | 317 result.push_back(map_entry.second); |
| 321 for (const auto& callback : enumeration_callbacks_) | 318 for (const auto& callback : enumeration_callbacks_) |
| 322 callback.Run(result); | 319 callback.Run(result); |
| 323 enumeration_callbacks_.clear(); | 320 enumeration_callbacks_.clear(); |
| 324 } | 321 } |
| 325 } | 322 } |
| 326 | 323 |
| 327 } // namespace device | 324 } // namespace device |
| OLD | NEW |