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

Side by Side Diff: device/usb/usb_service.cc

Issue 2864473002: Declare TaskTraits for blocking USB tasks in a constexpr (Closed)
Patch Set: Rebased Created 3 years, 7 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_service.h ('k') | device/usb/usb_service_impl.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 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"
(...skipping 25 matching lines...) Expand all
36 36
37 void UsbService::Observer::OnDeviceRemoved(scoped_refptr<UsbDevice> device) { 37 void UsbService::Observer::OnDeviceRemoved(scoped_refptr<UsbDevice> device) {
38 } 38 }
39 39
40 void UsbService::Observer::OnDeviceRemovedCleanup( 40 void UsbService::Observer::OnDeviceRemovedCleanup(
41 scoped_refptr<UsbDevice> device) { 41 scoped_refptr<UsbDevice> device) {
42 } 42 }
43 43
44 void UsbService::Observer::WillDestroyUsbService() {} 44 void UsbService::Observer::WillDestroyUsbService() {}
45 45
46 // Declare storage for this constexpr.
47 constexpr base::TaskTraits UsbService::kBlockingTaskTraits;
48
46 // static 49 // static
47 std::unique_ptr<UsbService> UsbService::Create() { 50 std::unique_ptr<UsbService> UsbService::Create() {
48 #if defined(OS_ANDROID) 51 #if defined(OS_ANDROID)
49 return base::WrapUnique(new UsbServiceAndroid()); 52 return base::WrapUnique(new UsbServiceAndroid());
50 #elif defined(USE_UDEV) 53 #elif defined(USE_UDEV)
51 return base::WrapUnique(new UsbServiceLinux()); 54 return base::WrapUnique(new UsbServiceLinux());
52 #elif defined(OS_WIN) 55 #elif defined(OS_WIN)
53 if (base::FeatureList::IsEnabled(kNewUsbBackend)) 56 if (base::FeatureList::IsEnabled(kNewUsbBackend))
54 return base::WrapUnique(new UsbServiceWin()); 57 return base::WrapUnique(new UsbServiceWin());
55 else 58 else
56 return base::WrapUnique(new UsbServiceImpl()); 59 return base::WrapUnique(new UsbServiceImpl());
57 #elif defined(OS_MACOSX) 60 #elif defined(OS_MACOSX)
58 return base::WrapUnique(new UsbServiceImpl()); 61 return base::WrapUnique(new UsbServiceImpl());
59 #else 62 #else
60 return nullptr; 63 return nullptr;
61 #endif 64 #endif
62 } 65 }
63 66
64 // static 67 // static
65 scoped_refptr<base::SequencedTaskRunner> 68 scoped_refptr<base::SequencedTaskRunner>
66 UsbService::CreateBlockingTaskRunner() { 69 UsbService::CreateBlockingTaskRunner() {
67 return base::CreateSequencedTaskRunnerWithTraits( 70 return base::CreateSequencedTaskRunnerWithTraits(kBlockingTaskTraits);
68 {base::MayBlock(), base::TaskPriority::USER_VISIBLE,
69 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN});
70 } 71 }
71 72
72 UsbService::~UsbService() { 73 UsbService::~UsbService() {
73 #if DCHECK_IS_ON() 74 #if DCHECK_IS_ON()
74 DCHECK(did_shutdown_); 75 DCHECK(did_shutdown_);
75 #endif 76 #endif
76 for (const auto& map_entry : devices_) 77 for (const auto& map_entry : devices_)
77 map_entry.second->OnDisconnect(); 78 map_entry.second->OnDisconnect();
78 for (auto& observer : observer_list_) 79 for (auto& observer : observer_list_)
79 observer.WillDestroyUsbService(); 80 observer.WillDestroyUsbService();
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 DCHECK(CalledOnValidThread()); 175 DCHECK(CalledOnValidThread());
175 176
176 for (auto& observer : observer_list_) 177 for (auto& observer : observer_list_)
177 observer.OnDeviceRemoved(device); 178 observer.OnDeviceRemoved(device);
178 device->NotifyDeviceRemoved(); 179 device->NotifyDeviceRemoved();
179 for (auto& observer : observer_list_) 180 for (auto& observer : observer_list_)
180 observer.OnDeviceRemovedCleanup(device); 181 observer.OnDeviceRemovedCleanup(device);
181 } 182 }
182 183
183 } // namespace device 184 } // namespace device
OLDNEW
« no previous file with comments | « device/usb/usb_service.h ('k') | device/usb/usb_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698