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

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

Issue 1316203006: Convert DeviceManagerDelegate to PermissionProvider mojo interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 69b991e99a284afee050132d55565159ac47d6cd..b7d97eccad94e122ebe02d375efc109cb5149d0e 100644
--- a/device/devices_app/usb/device_manager_impl.h
+++ b/device/devices_app/usb/device_manager_impl.h
@@ -14,6 +14,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "device/devices_app/usb/public/interfaces/device_manager.mojom.h"
+#include "device/devices_app/usb/public/interfaces/permission_provider.mojom.h"
#include "third_party/mojo/src/mojo/public/cpp/bindings/array.h"
#include "third_party/mojo/src/mojo/public/cpp/bindings/interface_request.h"
#include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h"
@@ -38,7 +39,7 @@ class DeviceManagerImpl : public DeviceManager {
public:
DeviceManagerImpl(
mojo::InterfaceRequest<DeviceManager> request,
- scoped_ptr<DeviceManagerDelegate> delegate,
+ PermissionProviderPtr permission_provider,
scoped_refptr<base::SequencedTaskRunner> service_task_runner);
~DeviceManagerImpl() override;
@@ -58,17 +59,19 @@ class DeviceManagerImpl : public DeviceManager {
// Callbacks to handle the async responses from the underlying UsbService.
void OnGetDevices(const GetDevicesCallback& callback,
mojo::Array<DeviceInfoPtr> devices);
- void OnGetInitialDevices(const GetDeviceChangesCallback& callback,
- mojo::Array<DeviceInfoPtr> devices);
+ void OnGetInitialDevices(mojo::Array<DeviceInfoPtr> devices);
// Methods called by |helper_| when devices are added or removed.
void OnDeviceAdded(DeviceInfoPtr device);
void OnDeviceRemoved(std::string device_guid);
void MaybeRunDeviceChangesCallback();
+ void OnPermissionCheckComplete(mojo::Array<DeviceInfoPtr> devices_added,
+ const std::set<std::string>& devices_removed,
+ mojo::Array<mojo::String> allowed_guids);
mojo::StrongBinding<DeviceManager> binding_;
Ken Rockot(use gerrit already) 2015/09/02 22:42:33 as discussed offline, this can become a mojo::Bind
Ken Rockot(use gerrit already) 2015/09/02 23:07:18 to preserve what was also just discussed offline,
Reilly Grant (use Gerrit) 2015/09/02 23:58:19 Done.
- scoped_ptr<DeviceManagerDelegate> delegate_;
+ PermissionProviderPtr permission_provider_;
scoped_refptr<base::SequencedTaskRunner> service_task_runner_;
// If there are unfinished calls to GetDeviceChanges their callbacks
@@ -78,6 +81,11 @@ class DeviceManagerImpl : public DeviceManager {
std::queue<GetDeviceChangesCallback> device_change_callbacks_;
mojo::Array<DeviceInfoPtr> devices_added_;
std::set<std::string> devices_removed_;
+ // To ensure that GetDeviceChangesCallbacks are called in the correct order
+ // only perform a single request to |permission_provider_| at a time.
+ bool permission_request_pending_ = false;
+ // The first notification is allowed to be empty. All others are not.
+ bool first_notification_ = true;
// |helper_| is owned by the service thread and holds a weak reference
// back to the device manager that created it.

Powered by Google App Engine
This is Rietveld 408576698