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

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

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/usb/mock_usb_service.cc ('k') | device/usb/usb_service.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 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 #ifndef DEVICE_USB_USB_SERVICE_H_ 5 #ifndef DEVICE_USB_USB_SERVICE_H_
6 #define DEVICE_USB_USB_SERVICE_H_ 6 #define DEVICE_USB_USB_SERVICE_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <unordered_map> 10 #include <unordered_map>
11 #include <unordered_set> 11 #include <unordered_set>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/bind_helpers.h" 14 #include "base/bind_helpers.h"
15 #include "base/logging.h"
15 #include "base/macros.h" 16 #include "base/macros.h"
16 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
17 #include "base/observer_list.h" 18 #include "base/observer_list.h"
18 #include "base/sequenced_task_runner.h" 19 #include "base/sequenced_task_runner.h"
19 #include "base/single_thread_task_runner.h" 20 #include "base/single_thread_task_runner.h"
20 #include "base/threading/non_thread_safe.h" 21 #include "base/threading/non_thread_safe.h"
21 22
22 namespace device { 23 namespace device {
23 24
24 class UsbDevice; 25 class UsbDevice;
(...skipping 25 matching lines...) Expand all
50 51
51 // The file task runner reference is used for blocking I/O operations. 52 // The file task runner reference is used for blocking I/O operations.
52 // Returns nullptr when initialization fails. 53 // Returns nullptr when initialization fails.
53 static std::unique_ptr<UsbService> Create( 54 static std::unique_ptr<UsbService> Create(
54 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner); 55 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner);
55 56
56 virtual ~UsbService(); 57 virtual ~UsbService();
57 58
58 scoped_refptr<UsbDevice> GetDevice(const std::string& guid); 59 scoped_refptr<UsbDevice> GetDevice(const std::string& guid);
59 60
61 // Shuts down the UsbService. Must be called before destroying the UsbService
62 // when tasks can still be posted to the |blocking_task_runner| provided to
63 // Create().
64 virtual void Shutdown();
65
60 // Enumerates available devices. 66 // Enumerates available devices.
61 virtual void GetDevices(const GetDevicesCallback& callback); 67 virtual void GetDevices(const GetDevicesCallback& callback);
62 68
63 void AddObserver(Observer* observer); 69 void AddObserver(Observer* observer);
64 void RemoveObserver(Observer* observer); 70 void RemoveObserver(Observer* observer);
65 71
66 // Methods to add and remove devices for testing purposes. Only a device added 72 // Methods to add and remove devices for testing purposes. Only a device added
67 // by this method can be removed by RemoveDeviceForTesting(). 73 // by this method can be removed by RemoveDeviceForTesting().
68 void AddDeviceForTesting(scoped_refptr<UsbDevice> device); 74 void AddDeviceForTesting(scoped_refptr<UsbDevice> device);
69 void RemoveDeviceForTesting(const std::string& device_guid); 75 void RemoveDeviceForTesting(const std::string& device_guid);
(...skipping 12 matching lines...) Expand all
82 88
83 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner() { 89 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner() {
84 return blocking_task_runner_; 90 return blocking_task_runner_;
85 } 91 }
86 92
87 std::unordered_map<std::string, scoped_refptr<UsbDevice>>& devices() { 93 std::unordered_map<std::string, scoped_refptr<UsbDevice>>& devices() {
88 return devices_; 94 return devices_;
89 } 95 }
90 96
91 private: 97 private:
92 friend void base::DeletePointer<UsbService>(UsbService* service);
93
94 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 98 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
95 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; 99 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
96 std::unordered_map<std::string, scoped_refptr<UsbDevice>> devices_; 100 std::unordered_map<std::string, scoped_refptr<UsbDevice>> devices_;
97 std::unordered_set<std::string> testing_devices_; 101 std::unordered_set<std::string> testing_devices_;
98 base::ObserverList<Observer, true> observer_list_; 102 base::ObserverList<Observer, true> observer_list_;
99 103
104 #if DCHECK_IS_ON()
105 bool did_shutdown_ = false;
106 #endif
107
100 DISALLOW_COPY_AND_ASSIGN(UsbService); 108 DISALLOW_COPY_AND_ASSIGN(UsbService);
101 }; 109 };
102 110
103 } // namespace device 111 } // namespace device
104 112
105 #endif // DEVICE_USB_USB_SERVICE_H_ 113 #endif // DEVICE_USB_USB_SERVICE_H_
OLDNEW
« no previous file with comments | « device/usb/mock_usb_service.cc ('k') | device/usb/usb_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698