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

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

Issue 1371793004: Provide the DeviceManager service to the renderer directly, no app. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@interface_permission
Patch Set: Fix header inclusion in chrome_content_browser_client.cc. Created 5 years, 3 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
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 31e8173d1eaa6cd9c132bbbd135b524fdba77875..4337a2ef11268544b6cced584abffc624c548e42 100644
--- a/device/devices_app/usb/device_manager_impl.h
+++ b/device/devices_app/usb/device_manager_impl.h
@@ -13,8 +13,10 @@
#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"
@@ -35,15 +37,17 @@ class DeviceManagerDelegate;
// 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 {
+class DeviceManagerImpl : public DeviceManager,
+ public device::UsbService::Observer {
public:
using DeviceList = std::vector<scoped_refptr<UsbDevice>>;
using DeviceMap = std::map<std::string, scoped_refptr<device::UsbDevice>>;
- DeviceManagerImpl(
- mojo::InterfaceRequest<DeviceManager> request,
- PermissionProviderPtr permission_provider,
- scoped_refptr<base::SequencedTaskRunner> service_task_runner);
+ static void Create(PermissionProviderPtr permission_provider,
+ mojo::InterfaceRequest<DeviceManager> request);
+
+ DeviceManagerImpl(PermissionProviderPtr permission_provider,
+ mojo::InterfaceRequest<DeviceManager> request);
~DeviceManagerImpl() override;
void set_connection_error_handler(const mojo::Closure& error_handler) {
@@ -51,8 +55,6 @@ class DeviceManagerImpl : public DeviceManager {
}
private:
- class ServiceThreadHelper;
-
// DeviceManager implementation:
void GetDevices(EnumerationOptionsPtr options,
const GetDevicesCallback& callback) override;
@@ -61,8 +63,6 @@ class DeviceManagerImpl : public DeviceManager {
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,9 +71,11 @@ class DeviceManagerImpl : public DeviceManager {
const GetDevicesCallback& callback,
const DeviceList& devices);
- // Methods called by |helper_| when devices are added or removed.
- void OnDeviceAdded(scoped_refptr<device::UsbDevice> device);
- void OnDeviceRemoved(scoped_refptr<device::UsbDevice> device);
+ // UsbService::Observer implementation:
+ void OnDeviceAdded(scoped_refptr<device::UsbDevice> device) override;
+ void OnDeviceRemoved(scoped_refptr<device::UsbDevice> device) override;
+ void WillDestroyUsbService() override;
+
void MaybeRunDeviceChangesCallback();
void OnEnumerationPermissionCheckComplete(
const DeviceMap& devices_added,
@@ -81,7 +83,6 @@ class DeviceManagerImpl : public DeviceManager {
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
@@ -94,9 +95,7 @@ class DeviceManagerImpl : public DeviceManager {
// only perform a single request to |permission_provider_| at a time.
bool permission_request_pending_ = false;
- // |helper_| is owned by the service thread and holds a weak reference
- // back to the device manager that created it.
- ServiceThreadHelper* helper_;
+ ScopedObserver<device::UsbService, device::UsbService::Observer> observer_;
mojo::Closure connection_error_handler_;

Powered by Google App Engine
This is Rietveld 408576698