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

Unified Diff: device/devices_app/usb/device_manager_impl.h

Issue 1382383002: Revert of Provide the DeviceManager service to the renderer directly, no app. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@interface_permission
Patch Set: Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/devices_app/public/cpp/devices_app_factory.cc ('k') | device/devices_app/usb/device_manager_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/devices_app/usb/device_manager_impl.h
diff --git a/device/devices_app/usb/device_manager_impl.h b/device/devices_app/usb/device_manager_impl.h
index 24013036b7c4bc88217ba58fcd03c802f1141ce2..31e8173d1eaa6cd9c132bbbd135b524fdba77875 100644
--- a/device/devices_app/usb/device_manager_impl.h
+++ b/device/devices_app/usb/device_manager_impl.h
@@ -13,10 +13,8 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
#include "device/devices_app/usb/public/interfaces/device_manager.mojom.h"
#include "device/devices_app/usb/public/interfaces/permission_provider.mojom.h"
-#include "device/usb/usb_service.h"
#include "third_party/mojo/src/mojo/public/cpp/bindings/array.h"
#include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h"
#include "third_party/mojo/src/mojo/public/cpp/bindings/interface_request.h"
@@ -37,17 +35,15 @@
// Implementation of the public DeviceManager interface. This interface can be
// requested from the devices app located at "mojo:devices", if available.
-class DeviceManagerImpl : public DeviceManager,
- public device::UsbService::Observer {
+class DeviceManagerImpl : public DeviceManager {
public:
using DeviceList = std::vector<scoped_refptr<UsbDevice>>;
using DeviceMap = std::map<std::string, scoped_refptr<device::UsbDevice>>;
- static void Create(PermissionProviderPtr permission_provider,
- mojo::InterfaceRequest<DeviceManager> request);
-
- DeviceManagerImpl(PermissionProviderPtr permission_provider,
- mojo::InterfaceRequest<DeviceManager> request);
+ DeviceManagerImpl(
+ mojo::InterfaceRequest<DeviceManager> request,
+ PermissionProviderPtr permission_provider,
+ scoped_refptr<base::SequencedTaskRunner> service_task_runner);
~DeviceManagerImpl() override;
void set_connection_error_handler(const mojo::Closure& error_handler) {
@@ -55,6 +51,8 @@
}
private:
+ class ServiceThreadHelper;
+
// DeviceManager implementation:
void GetDevices(EnumerationOptionsPtr options,
const GetDevicesCallback& callback) override;
@@ -63,6 +61,8 @@
mojo::InterfaceRequest<Device> device_request) override;
// Callbacks to handle the async responses from the underlying UsbService.
+ void OnGetDevice(mojo::InterfaceRequest<Device> device_request,
+ scoped_refptr<UsbDevice> device);
void OnGetDevicePermissionCheckComplete(
scoped_refptr<device::UsbDevice> device,
mojo::InterfaceRequest<Device> device_request,
@@ -71,11 +71,9 @@
const GetDevicesCallback& callback,
const DeviceList& devices);
- // UsbService::Observer implementation:
- void OnDeviceAdded(scoped_refptr<device::UsbDevice> device) override;
- void OnDeviceRemoved(scoped_refptr<device::UsbDevice> device) override;
- void WillDestroyUsbService() override;
-
+ // Methods called by |helper_| when devices are added or removed.
+ void OnDeviceAdded(scoped_refptr<device::UsbDevice> device);
+ void OnDeviceRemoved(scoped_refptr<device::UsbDevice> device);
void MaybeRunDeviceChangesCallback();
void OnEnumerationPermissionCheckComplete(
const DeviceMap& devices_added,
@@ -83,6 +81,7 @@
mojo::Array<mojo::String> allowed_guids);
PermissionProviderPtr permission_provider_;
+ scoped_refptr<base::SequencedTaskRunner> service_task_runner_;
// If there are unfinished calls to GetDeviceChanges their callbacks
// are stored in |device_change_callbacks_|. Otherwise device changes
@@ -95,8 +94,9 @@
// only perform a single request to |permission_provider_| at a time.
bool permission_request_pending_ = false;
- UsbService* usb_service_;
- ScopedObserver<device::UsbService, device::UsbService::Observer> observer_;
+ // |helper_| is owned by the service thread and holds a weak reference
+ // back to the device manager that created it.
+ ServiceThreadHelper* helper_;
mojo::Closure connection_error_handler_;
« no previous file with comments | « device/devices_app/public/cpp/devices_app_factory.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