| OLD | NEW |
| 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/feature_list.h" | 8 #include "base/feature_list.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "base/task_scheduler/post_task.h" |
| 11 #include "base/threading/thread_task_runner_handle.h" | 12 #include "base/threading/thread_task_runner_handle.h" |
| 12 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 13 #include "components/device_event_log/device_event_log.h" | 14 #include "components/device_event_log/device_event_log.h" |
| 14 #include "device/base/features.h" | 15 #include "device/base/features.h" |
| 15 #include "device/usb/usb_device.h" | 16 #include "device/usb/usb_device.h" |
| 16 #include "device/usb/usb_device_handle.h" | 17 #include "device/usb/usb_device_handle.h" |
| 17 | 18 |
| 18 #if defined(OS_ANDROID) | 19 #if defined(OS_ANDROID) |
| 19 #include "device/usb/usb_service_android.h" | 20 #include "device/usb/usb_service_android.h" |
| 20 #elif defined(USE_UDEV) | 21 #elif defined(USE_UDEV) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 41 } | 42 } |
| 42 | 43 |
| 43 void UsbService::Observer::WillDestroyUsbService() {} | 44 void UsbService::Observer::WillDestroyUsbService() {} |
| 44 | 45 |
| 45 // static | 46 // static |
| 46 std::unique_ptr<UsbService> UsbService::Create( | 47 std::unique_ptr<UsbService> UsbService::Create( |
| 47 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner) { | 48 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner) { |
| 48 #if defined(OS_ANDROID) | 49 #if defined(OS_ANDROID) |
| 49 return base::WrapUnique(new UsbServiceAndroid(blocking_task_runner)); | 50 return base::WrapUnique(new UsbServiceAndroid(blocking_task_runner)); |
| 50 #elif defined(USE_UDEV) | 51 #elif defined(USE_UDEV) |
| 51 return base::WrapUnique(new UsbServiceLinux(blocking_task_runner)); | 52 return base::WrapUnique( |
| 53 new UsbServiceLinux(base::CreateSequencedTaskRunnerWithTraits( |
| 54 base::TaskTraits() |
| 55 .MayBlock() |
| 56 .WithPriority(base::TaskPriority::USER_VISIBLE) |
| 57 .WithShutdownBehavior( |
| 58 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN)))); |
| 52 #elif defined(OS_WIN) | 59 #elif defined(OS_WIN) |
| 53 if (base::FeatureList::IsEnabled(kNewUsbBackend)) | 60 if (base::FeatureList::IsEnabled(kNewUsbBackend)) |
| 54 return base::WrapUnique(new UsbServiceWin(blocking_task_runner)); | 61 return base::WrapUnique(new UsbServiceWin(blocking_task_runner)); |
| 55 else | 62 else |
| 56 return base::WrapUnique(new UsbServiceImpl(blocking_task_runner)); | 63 return base::WrapUnique(new UsbServiceImpl(blocking_task_runner)); |
| 57 #elif defined(OS_MACOSX) | 64 #elif defined(OS_MACOSX) |
| 58 return base::WrapUnique(new UsbServiceImpl(blocking_task_runner)); | 65 return base::WrapUnique(new UsbServiceImpl(blocking_task_runner)); |
| 59 #else | 66 #else |
| 60 return nullptr; | 67 return nullptr; |
| 61 #endif | 68 #endif |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 DCHECK(CalledOnValidThread()); | 173 DCHECK(CalledOnValidThread()); |
| 167 | 174 |
| 168 for (auto& observer : observer_list_) | 175 for (auto& observer : observer_list_) |
| 169 observer.OnDeviceRemoved(device); | 176 observer.OnDeviceRemoved(device); |
| 170 device->NotifyDeviceRemoved(); | 177 device->NotifyDeviceRemoved(); |
| 171 for (auto& observer : observer_list_) | 178 for (auto& observer : observer_list_) |
| 172 observer.OnDeviceRemovedCleanup(device); | 179 observer.OnDeviceRemovedCleanup(device); |
| 173 } | 180 } |
| 174 | 181 |
| 175 } // namespace device | 182 } // namespace device |
| OLD | NEW |