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

Side by Side Diff: device/devices_app/usb/device_manager_impl.h

Issue 1682363002: Remove //device/devices_app. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove two files that somehow survived in //device/devices_app. Created 4 years, 10 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef DEVICE_USB_DEVICE_MANAGER_IMPL_H_
6 #define DEVICE_USB_DEVICE_MANAGER_IMPL_H_
7
8 #include <queue>
9 #include <set>
10
11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h"
15 #include "base/scoped_observer.h"
16 #include "device/devices_app/usb/public/interfaces/device_manager.mojom.h"
17 #include "device/devices_app/usb/public/interfaces/permission_provider.mojom.h"
18 #include "device/usb/usb_service.h"
19 #include "mojo/public/cpp/bindings/array.h"
20 #include "mojo/public/cpp/bindings/binding.h"
21 #include "mojo/public/cpp/bindings/interface_request.h"
22
23 namespace base {
24 class SequencedTaskRunner;
25 }
26
27 namespace device {
28
29 class UsbDevice;
30 class UsbDeviceFilter;
31 class UsbDeviceHandle;
32
33 namespace usb {
34
35 class DeviceManagerDelegate;
36
37 // Implementation of the public DeviceManager interface. This interface can be
38 // requested from the devices app located at "mojo:devices", if available.
39 class DeviceManagerImpl : public DeviceManager,
40 public device::UsbService::Observer {
41 public:
42 using DeviceList = std::vector<scoped_refptr<UsbDevice>>;
43 using DeviceMap = std::map<std::string, scoped_refptr<device::UsbDevice>>;
44
45 static void Create(PermissionProviderPtr permission_provider,
46 mojo::InterfaceRequest<DeviceManager> request);
47
48 DeviceManagerImpl(PermissionProviderPtr permission_provider,
49 mojo::InterfaceRequest<DeviceManager> request);
50 ~DeviceManagerImpl() override;
51
52 void set_connection_error_handler(const mojo::Closure& error_handler) {
53 connection_error_handler_ = error_handler;
54 }
55
56 private:
57 // DeviceManager implementation:
58 void GetDevices(EnumerationOptionsPtr options,
59 const GetDevicesCallback& callback) override;
60 void GetDeviceChanges(const GetDeviceChangesCallback& callback) override;
61 void GetDevice(const mojo::String& guid,
62 mojo::InterfaceRequest<Device> device_request) override;
63
64 // Callbacks to handle the async responses from the underlying UsbService.
65 void OnGetDevicePermissionCheckComplete(
66 scoped_refptr<device::UsbDevice> device,
67 mojo::InterfaceRequest<Device> device_request,
68 mojo::Array<mojo::String> allowed_guids);
69 void OnGetDevices(EnumerationOptionsPtr options,
70 const GetDevicesCallback& callback,
71 const DeviceList& devices);
72
73 // UsbService::Observer implementation:
74 void OnDeviceAdded(scoped_refptr<device::UsbDevice> device) override;
75 void OnDeviceRemoved(scoped_refptr<device::UsbDevice> device) override;
76 void WillDestroyUsbService() override;
77
78 void MaybeRunDeviceChangesCallback();
79 void OnEnumerationPermissionCheckComplete(
80 const DeviceMap& devices_added,
81 const DeviceMap& devices_removed,
82 mojo::Array<mojo::String> allowed_guids);
83
84 PermissionProviderPtr permission_provider_;
85
86 // If there are unfinished calls to GetDeviceChanges their callbacks
87 // are stored in |device_change_callbacks_|. Otherwise device changes
88 // are collected in |devices_added_| and |devices_removed_| until the
89 // next call to GetDeviceChanges.
90 std::queue<GetDeviceChangesCallback> device_change_callbacks_;
91 DeviceMap devices_added_;
92 DeviceMap devices_removed_;
93 // To ensure that GetDeviceChangesCallbacks are called in the correct order
94 // only perform a single request to |permission_provider_| at a time.
95 bool permission_request_pending_ = false;
96
97 UsbService* usb_service_;
98 ScopedObserver<device::UsbService, device::UsbService::Observer> observer_;
99
100 mojo::Closure connection_error_handler_;
101
102 mojo::Binding<DeviceManager> binding_;
103 base::WeakPtrFactory<DeviceManagerImpl> weak_factory_;
104
105 DISALLOW_COPY_AND_ASSIGN(DeviceManagerImpl);
106 };
107
108 } // namespace usb
109 } // namespace device
110
111 #endif // DEVICE_USB_DEVICE_MANAGER_IMPL_H_
OLDNEW
« no previous file with comments | « device/devices_app/usb/device_impl_unittest.cc ('k') | device/devices_app/usb/device_manager_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698