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

Unified Diff: device/usb/device_manager_impl.cc

Issue 1158323002: Revert of Build a basic Mojo service framework for device/usb (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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/usb/device_manager_impl.h ('k') | device/usb/device_manager_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/usb/device_manager_impl.cc
diff --git a/device/usb/device_manager_impl.cc b/device/usb/device_manager_impl.cc
deleted file mode 100644
index 26332b38472d702c08992a53ea23344f262f84bb..0000000000000000000000000000000000000000
--- a/device/usb/device_manager_impl.cc
+++ /dev/null
@@ -1,79 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "device/usb/device_manager_impl.h"
-
-#include "base/bind.h"
-#include "base/memory/scoped_ptr.h"
-#include "device/core/device_client.h"
-#include "device/usb/device_impl.h"
-#include "device/usb/public/cpp/device_manager_delegate.h"
-#include "device/usb/public/cpp/device_manager_factory.h"
-#include "device/usb/public/interfaces/device.mojom.h"
-#include "device/usb/type_converters.h"
-#include "device/usb/usb_device.h"
-#include "device/usb/usb_device_filter.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/interface_request.h"
-
-namespace device {
-namespace usb {
-
-// static
-void DeviceManagerFactory::Build(mojo::InterfaceRequest<DeviceManager> request,
- scoped_ptr<DeviceManagerDelegate> delegate) {
- // Owned by its MessagePipe.
- new DeviceManagerImpl(request.Pass(), delegate.Pass());
-}
-
-DeviceManagerImpl::DeviceManagerImpl(
- mojo::InterfaceRequest<DeviceManager> request,
- scoped_ptr<DeviceManagerDelegate> delegate)
- : binding_(this, request.Pass()),
- delegate_(delegate.Pass()),
- weak_factory_(this) {
-}
-
-DeviceManagerImpl::~DeviceManagerImpl() {
-}
-
-void DeviceManagerImpl::GetDevices(EnumerationOptionsPtr options,
- const GetDevicesCallback& callback) {
- DCHECK(DeviceClient::Get());
- UsbService* usb_service = DeviceClient::Get()->GetUsbService();
- if (!usb_service) {
- mojo::Array<EnumerationResultPtr> results(0);
- callback.Run(results.Pass());
- return;
- }
- std::vector<UsbDeviceFilter> filters =
- options->filters.To<std::vector<UsbDeviceFilter>>();
- usb_service->GetDevices(base::Bind(&DeviceManagerImpl::OnGetDevices,
- weak_factory_.GetWeakPtr(), callback,
- filters));
-}
-
-void DeviceManagerImpl::OnGetDevices(
- const GetDevicesCallback& callback,
- const std::vector<UsbDeviceFilter>& filters,
- const std::vector<scoped_refptr<UsbDevice>>& devices) {
- mojo::Array<EnumerationResultPtr> results(0);
- for (size_t i = 0; i < devices.size(); ++i) {
- DeviceInfoPtr device_info = DeviceInfo::From(*devices[i]);
- if (UsbDeviceFilter::MatchesAny(devices[i], filters) &&
- delegate_->IsDeviceAllowed(*device_info)) {
- EnumerationResultPtr result = EnumerationResult::New();
- DevicePtr device;
- // Owned by its message pipe.
- new DeviceImpl(devices[i], mojo::GetProxy(&device));
- result->device = device.Pass();
- results.push_back(result.Pass());
- }
- }
- callback.Run(results.Pass());
-}
-
-} // namespace usb
-} // namespace device
« no previous file with comments | « device/usb/device_manager_impl.h ('k') | device/usb/device_manager_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698