diff options
author | reillyg <reillyg@chromium.org> | 2016-02-10 15:29:20 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-10 23:31:02 +0000 |
commit | 64c8f4f25d9fbd2233e476d6276b4c63bcc4813c (patch) | |
tree | 6b493ace49c49e995601c33d9ef14a94ccfe2f85 /device | |
parent | d1a4b660eb29113ef2a08f8544ebf1f2b212e6ec (diff) | |
download | chromium_src-64c8f4f25d9fbd2233e476d6276b4c63bcc4813c.zip chromium_src-64c8f4f25d9fbd2233e476d6276b4c63bcc4813c.tar.gz chromium_src-64c8f4f25d9fbd2233e476d6276b4c63bcc4813c.tar.bz2 |
Remove //device/devices_app.
This change removes the code to create a Mojo app containing device
services (currently only USB) and instead makes the Mojo bindings for
//device/usb part of that directory.
The Mojo service implementation is still in a separate //device/usb/mojo
target but this will eventually merge into its parent directory as the
Mojo interface becomes the only public interface for //device/usb.
BUG=None
Review URL: https://codereview.chromium.org/1682363002
Cr-Commit-Position: refs/heads/master@{#374778}
Diffstat (limited to 'device')
-rw-r--r-- | device/BUILD.gn | 12 | ||||
-rw-r--r-- | device/device_tests.gyp | 11 | ||||
-rw-r--r-- | device/devices_app/BUILD.gn | 77 | ||||
-rw-r--r-- | device/devices_app/OWNERS | 2 | ||||
-rw-r--r-- | device/devices_app/devices_app.cc | 139 | ||||
-rw-r--r-- | device/devices_app/devices_app.gyp | 85 | ||||
-rw-r--r-- | device/devices_app/devices_app.h | 67 | ||||
-rw-r--r-- | device/devices_app/devices_apptest.cc | 55 | ||||
-rw-r--r-- | device/devices_app/main.cc | 15 | ||||
-rw-r--r-- | device/devices_app/public/cpp/BUILD.gn | 29 | ||||
-rw-r--r-- | device/devices_app/public/cpp/constants.cc | 11 | ||||
-rw-r--r-- | device/devices_app/public/cpp/constants.h | 14 | ||||
-rw-r--r-- | device/devices_app/public/cpp/devices_app_factory.cc | 16 | ||||
-rw-r--r-- | device/devices_app/public/cpp/devices_app_factory.h | 28 | ||||
-rw-r--r-- | device/devices_app/usb/DEPS | 4 | ||||
-rw-r--r-- | device/usb/mojo/BUILD.gn | 24 | ||||
-rw-r--r-- | device/usb/mojo/DEPS (renamed from device/devices_app/DEPS) | 1 | ||||
-rw-r--r-- | device/usb/mojo/device_impl.cc (renamed from device/devices_app/usb/device_impl.cc) | 4 | ||||
-rw-r--r-- | device/usb/mojo/device_impl.h (renamed from device/devices_app/usb/device_impl.h) | 10 | ||||
-rw-r--r-- | device/usb/mojo/device_impl_unittest.cc (renamed from device/devices_app/usb/device_impl_unittest.cc) | 8 | ||||
-rw-r--r-- | device/usb/mojo/device_manager_impl.cc (renamed from device/devices_app/usb/device_manager_impl.cc) | 8 | ||||
-rw-r--r-- | device/usb/mojo/device_manager_impl.h (renamed from device/devices_app/usb/device_manager_impl.h) | 10 | ||||
-rw-r--r-- | device/usb/mojo/device_manager_impl_unittest.cc (renamed from device/devices_app/usb/device_manager_impl_unittest.cc) | 6 | ||||
-rw-r--r-- | device/usb/mojo/fake_permission_provider.cc (renamed from device/devices_app/usb/fake_permission_provider.cc) | 2 | ||||
-rw-r--r-- | device/usb/mojo/fake_permission_provider.h (renamed from device/devices_app/usb/fake_permission_provider.h) | 2 | ||||
-rw-r--r-- | device/usb/mojo/type_converters.cc (renamed from device/devices_app/usb/type_converters.cc) | 8 | ||||
-rw-r--r-- | device/usb/mojo/type_converters.h (renamed from device/devices_app/usb/type_converters.h) | 8 | ||||
-rw-r--r-- | device/usb/public/interfaces/BUILD.gn (renamed from device/devices_app/usb/public/interfaces/BUILD.gn) | 0 | ||||
-rw-r--r-- | device/usb/public/interfaces/device.mojom (renamed from device/devices_app/usb/public/interfaces/device.mojom) | 0 | ||||
-rw-r--r-- | device/usb/public/interfaces/device_manager.mojom (renamed from device/devices_app/usb/public/interfaces/device_manager.mojom) | 0 | ||||
-rw-r--r-- | device/usb/public/interfaces/permission_provider.mojom (renamed from device/devices_app/usb/public/interfaces/permission_provider.mojom) | 0 | ||||
-rw-r--r-- | device/usb/usb.gyp | 18 |
32 files changed, 88 insertions, 586 deletions
diff --git a/device/BUILD.gn b/device/BUILD.gn index 463e77f..4b52e52 100644 --- a/device/BUILD.gn +++ b/device/BUILD.gn @@ -103,13 +103,13 @@ test("device_unittests") { # USB does not compile on iOS. if (!is_ios) { sources += [ - "devices_app/usb/device_impl_unittest.cc", - "devices_app/usb/device_manager_impl_unittest.cc", - "devices_app/usb/fake_permission_provider.cc", - "devices_app/usb/fake_permission_provider.h", "test/test_device_client.cc", "test/test_device_client.h", "test/usb_test_gadget_impl.cc", + "usb/mojo/device_impl_unittest.cc", + "usb/mojo/device_manager_impl_unittest.cc", + "usb/mojo/fake_permission_provider.cc", + "usb/mojo/fake_permission_provider.h", "usb/usb_descriptors_unittest.cc", "usb/usb_device_filter_unittest.cc", "usb/usb_device_handle_unittest.cc", @@ -120,10 +120,10 @@ test("device_unittests") { deps += [ "//device/core", "//device/core:mocks", - "//device/devices_app:lib", - "//device/devices_app/usb/public/interfaces", "//device/usb", "//device/usb:mocks", + "//device/usb/mojo", + "//device/usb/public/interfaces", ] } diff --git a/device/device_tests.gyp b/device/device_tests.gyp index 4503e12..c4ad2d8 100644 --- a/device/device_tests.gyp +++ b/device/device_tests.gyp @@ -12,6 +12,7 @@ 'type': '<(gtest_target_type)', 'dependencies': [ '../base/base.gyp:test_support_base', + '../mojo/mojo_base.gyp:mojo_url_type_converters', '../mojo/mojo_base.gyp:mojo_environment_chromium', '../mojo/mojo_edk.gyp:mojo_system_impl', '../mojo/mojo_public.gyp:mojo_cpp_bindings', @@ -24,10 +25,10 @@ 'bluetooth/bluetooth.gyp:device_bluetooth_mocks', 'core/core.gyp:device_core', 'core/core.gyp:device_core_mocks', - 'devices_app/devices_app.gyp:devices_app_lib', 'nfc/nfc.gyp:device_nfc', 'usb/usb.gyp:device_usb', 'usb/usb.gyp:device_usb_mocks', + 'usb/usb.gyp:device_usb_mojo_bindings', 'hid/hid.gyp:device_hid', 'hid/hid.gyp:device_hid_mocks', 'serial/serial.gyp:device_serial', @@ -61,10 +62,6 @@ 'bluetooth/test/bluetooth_test_win.cc', 'bluetooth/test/test_bluetooth_adapter_observer.cc', 'bluetooth/test/test_bluetooth_adapter_observer.h', - 'devices_app/usb/device_impl_unittest.cc', - 'devices_app/usb/device_manager_impl_unittest.cc', - 'devices_app/usb/fake_permission_provider.cc', - 'devices_app/usb/fake_permission_provider.h', 'hid/hid_connection_unittest.cc', 'hid/hid_device_filter_unittest.cc', 'hid/hid_report_descriptor_unittest.cc', @@ -82,6 +79,10 @@ 'test/test_device_client.cc', 'test/test_device_client.h', 'test/usb_test_gadget_impl.cc', + 'usb/mojo/device_impl_unittest.cc', + 'usb/mojo/device_manager_impl_unittest.cc', + 'usb/mojo/fake_permission_provider.cc', + 'usb/mojo/fake_permission_provider.h', 'usb/usb_descriptors_unittest.cc', 'usb/usb_device_filter_unittest.cc', 'usb/usb_device_handle_unittest.cc', diff --git a/device/devices_app/BUILD.gn b/device/devices_app/BUILD.gn deleted file mode 100644 index f189e6b..0000000 --- a/device/devices_app/BUILD.gn +++ /dev/null @@ -1,77 +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. - -import("//mojo/public/mojo_application.gni") - -source_set("lib") { - sources = [ - "devices_app.cc", - "devices_app.h", - "usb/device_impl.cc", - "usb/device_impl.h", - "usb/device_manager_impl.cc", - "usb/device_manager_impl.h", - "usb/type_converters.cc", - "usb/type_converters.h", - ] - - deps = [ - "//device/core", - "//device/devices_app/usb/public/interfaces", - "//device/usb", - "//mojo/common", - "//mojo/public/cpp/bindings", - "//mojo/public/cpp/bindings:callback", - "//net", - "//url", - ] - - public_deps = [ - "//base", - "//mojo/shell/public/cpp", - "//mojo/shell/public/interfaces", - ] -} - -if (!is_component_build) { - mojo_native_application("devices") { - sources = [ - "main.cc", - ] - - deps = [ - "//base", - "//device/devices_app/public/cpp:factory", - "//mojo/shell/public/cpp", - ] - - public_deps = [ - ":lib", - ] - } - - mojo_native_application("apptests") { - output_name = "devices_apptests" - - testonly = true - - sources = [ - "devices_apptest.cc", - ] - - deps = [ - "//base", - "//mojo/shell/public/cpp:test_support", - ] - - public_deps = [ - ":lib", - "//device/devices_app/usb/public/interfaces", - ] - - data_deps = [ - ":devices", - ] - } -} diff --git a/device/devices_app/OWNERS b/device/devices_app/OWNERS deleted file mode 100644 index b16946a..0000000 --- a/device/devices_app/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -reillyg@chromium.org -rockot@chromium.org diff --git a/device/devices_app/devices_app.cc b/device/devices_app/devices_app.cc deleted file mode 100644 index 8bb9ab9..0000000 --- a/device/devices_app/devices_app.cc +++ /dev/null @@ -1,139 +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/devices_app/devices_app.h" - -#include <stdint.h> -#include <utility> - -#include "base/bind.h" -#include "base/callback.h" -#include "base/macros.h" -#include "base/sequenced_task_runner.h" -#include "base/thread_task_runner_handle.h" -#include "base/threading/thread.h" -#include "base/time/time.h" -#include "device/core/device_client.h" -#include "device/devices_app/usb/device_manager_impl.h" -#include "device/usb/usb_service.h" -#include "mojo/public/cpp/bindings/interface_request.h" -#include "mojo/shell/public/cpp/connection.h" -#include "mojo/shell/public/cpp/shell.h" -#include "url/gurl.h" - -namespace device { - -namespace { - -// The number of seconds to wait without any bound DeviceManagers before -// exiting the app. -const int64_t kIdleTimeoutInSeconds = 10; - -// A DeviceClient implementation to be constructed iff the app is not running -// in an embedder that provides a DeviceClient (i.e. running as a standalone -// Mojo app, not in Chrome). -class AppDeviceClient : public DeviceClient { - public: - explicit AppDeviceClient( - scoped_refptr<base::SequencedTaskRunner> blocking_task_runner) - : blocking_task_runner_(blocking_task_runner) {} - ~AppDeviceClient() override {} - - private: - // DeviceClient: - UsbService* GetUsbService() override { - if (!usb_service_) { - usb_service_ = UsbService::Create(blocking_task_runner_); - } - return usb_service_.get(); - } - - scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; - scoped_ptr<UsbService> usb_service_; -}; - -} // namespace - -// This class insures that a UsbService has been initialized and is accessible -// via the DeviceClient interface. -class DevicesApp::USBServiceInitializer { - public: - USBServiceInitializer() - : blocking_thread_("USB service blocking I/O thread") { - blocking_thread_.Start(); - app_device_client_.reset( - new AppDeviceClient(blocking_thread_.task_runner())); - } - - ~USBServiceInitializer() {} - - private: - scoped_ptr<AppDeviceClient> app_device_client_; - base::Thread blocking_thread_; - - DISALLOW_COPY_AND_ASSIGN(USBServiceInitializer); -}; - -DevicesApp::DevicesApp() : shell_(nullptr), active_device_manager_count_(0) {} - -DevicesApp::~DevicesApp() { -} - -void DevicesApp::Initialize(mojo::Shell* shell, - const std::string& url, - uint32_t id) { - shell_ = shell; - service_initializer_.reset(new USBServiceInitializer); - StartIdleTimer(); -} - -bool DevicesApp::AcceptConnection(mojo::Connection* connection) { - connection->AddInterface<usb::DeviceManager>(this); - return true; -} - -void DevicesApp::Quit() { - service_initializer_.reset(); - shell_ = nullptr; -} - -void DevicesApp::Create(mojo::Connection* connection, - mojo::InterfaceRequest<usb::DeviceManager> request) { - // Bind the new device manager to the connecting application's permission - // provider. - usb::PermissionProviderPtr permission_provider; - connection->GetInterface(&permission_provider); - - // Owned by its message pipe. - usb::DeviceManagerImpl* device_manager = new usb::DeviceManagerImpl( - std::move(permission_provider), std::move(request)); - device_manager->set_connection_error_handler( - base::Bind(&DevicesApp::OnConnectionError, base::Unretained(this))); - - active_device_manager_count_++; - idle_timeout_callback_.Cancel(); -} - -void DevicesApp::OnConnectionError() { - DCHECK_GE(active_device_manager_count_, 0u); - active_device_manager_count_--; - if (active_device_manager_count_ == 0) { - // If the last DeviceManager connection has been dropped, kick off an idle - // timeout to shut ourselves down. - StartIdleTimer(); - } -} - -void DevicesApp::StartIdleTimer() { - // Passing unretained |shell_| is safe here because |shell_| is - // guaranteed to outlive |this|, and the callback is canceled if |this| is - // destroyed. - idle_timeout_callback_.Reset( - base::Bind(&mojo::Shell::Quit, base::Unretained(shell_))); - base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( - FROM_HERE, idle_timeout_callback_.callback(), - base::TimeDelta::FromSeconds(kIdleTimeoutInSeconds)); -} - -} // namespace device diff --git a/device/devices_app/devices_app.gyp b/device/devices_app/devices_app.gyp deleted file mode 100644 index 6027a85..0000000 --- a/device/devices_app/devices_app.gyp +++ /dev/null @@ -1,85 +0,0 @@ -# Copyright 2014 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. - -{ - 'variables': { - 'chromium_code': 1, - }, - 'targets': [ - { - 'target_name': 'devices_app_lib', - 'type': 'static_library', - 'include_dirs': [ - '../..', - ], - 'sources': [ - 'devices_app.cc', - 'devices_app.h', - 'usb/device_impl.cc', - 'usb/device_impl.h', - 'usb/device_manager_impl.cc', - 'usb/device_manager_impl.h', - 'usb/type_converters.cc', - 'usb/type_converters.h', - ], - 'dependencies': [ - 'device_usb_mojo_bindings_lib', - '<(DEPTH)/device/core/core.gyp:device_core', - '<(DEPTH)/device/usb/usb.gyp:device_usb', - '<(DEPTH)/mojo/mojo_base.gyp:mojo_application_base', - '<(DEPTH)/mojo/mojo_base.gyp:mojo_application_bindings', - '<(DEPTH)/mojo/mojo_base.gyp:mojo_url_type_converters', - '<(DEPTH)/mojo/mojo_public.gyp:mojo_cpp_bindings', - ], - 'export_dependent_settings': [ - '<(DEPTH)/mojo/mojo_base.gyp:mojo_application_base', - '<(DEPTH)/mojo/mojo_base.gyp:mojo_application_bindings', - '<(DEPTH)/mojo/mojo_public.gyp:mojo_cpp_bindings', - ], - }, - { - 'target_name': 'device_usb_mojo_bindings', - 'type': 'none', - 'variables': { - 'mojom_files': [ - 'usb/public/interfaces/device.mojom', - 'usb/public/interfaces/device_manager.mojom', - 'usb/public/interfaces/permission_provider.mojom', - ], - }, - 'includes': [ - '../../mojo/mojom_bindings_generator_explicit.gypi', - ], - }, - { - 'target_name': 'device_usb_mojo_bindings_lib', - 'type': 'static_library', - 'dependencies': [ - 'device_usb_mojo_bindings', - ], - }, - { - 'target_name': 'devices_app_public_cpp', - 'type': 'static_library', - 'sources': [ - 'public/cpp/constants.cc', - 'public/cpp/constants.h', - ], - 'dependencies': [ - 'devices_app_lib', - ], - }, - { - 'target_name': 'devices_app_public_cpp_factory', - 'type': 'static_library', - 'sources': [ - 'public/cpp/devices_app_factory.cc', - 'public/cpp/devices_app_factory.h', - ], - 'dependencies': [ - 'devices_app_lib', - ], - }, - ], -} diff --git a/device/devices_app/devices_app.h b/device/devices_app/devices_app.h deleted file mode 100644 index 0fecb42..0000000 --- a/device/devices_app/devices_app.h +++ /dev/null @@ -1,67 +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. - -#ifndef DEVICE_DEVICES_DEVICES_APP_H_ -#define DEVICE_DEVICES_DEVICES_APP_H_ - -#include <stddef.h> - -#include "base/cancelable_callback.h" -#include "base/macros.h" -#include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" -#include "mojo/shell/public/cpp/interface_factory.h" -#include "mojo/shell/public/cpp/shell_client.h" - -namespace mojo { -class Shell; -} - -namespace device { - -namespace usb { -class DeviceManager; -} - -class DevicesApp : public mojo::ShellClient, - public mojo::InterfaceFactory<usb::DeviceManager> { - public: - DevicesApp(); - ~DevicesApp() override; - - private: - class USBServiceInitializer; - - // mojo::ShellClient: - void Initialize(mojo::Shell* shell, - const std::string& url, - uint32_t id) override; - bool AcceptConnection(mojo::Connection* connection) override; - void Quit() override; - - // mojo::InterfaceFactory<usb::DeviceManager>: - void Create(mojo::Connection* connection, - mojo::InterfaceRequest<usb::DeviceManager> request) override; - - // Mojo error handler to track device manager count. - void OnConnectionError(); - - // Sets the app for destruction after a period of idle time. If any top-level - // services (e.g. usb::DeviceManager) are bound before the timeout elapses, - // it's canceled. - void StartIdleTimer(); - - mojo::Shell* shell_; - scoped_ptr<USBServiceInitializer> service_initializer_; - size_t active_device_manager_count_; - - // Callback used to shut down the app after a period of inactivity. - base::CancelableClosure idle_timeout_callback_; - - DISALLOW_COPY_AND_ASSIGN(DevicesApp); -}; - -} // naespace device - -#endif // DEVICE_DEVICES_DEVICES_APP_H_ diff --git a/device/devices_app/devices_apptest.cc b/device/devices_app/devices_apptest.cc deleted file mode 100644 index 1ac56ae..0000000 --- a/device/devices_app/devices_apptest.cc +++ /dev/null @@ -1,55 +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 <utility> - -#include "base/bind.h" -#include "base/callback.h" -#include "base/macros.h" -#include "base/run_loop.h" -#include "device/devices_app/devices_app.h" -#include "device/devices_app/usb/public/interfaces/device_manager.mojom.h" -#include "mojo/shell/public/cpp/application_test_base.h" - -namespace device { -namespace { - -class DevicesAppTest : public mojo::test::ApplicationTestBase { - public: - DevicesAppTest() {} - ~DevicesAppTest() override {} - - void SetUp() override { - ApplicationTestBase::SetUp(); - shell()->ConnectToInterface("mojo:devices", &usb_device_manager_); - } - - usb::DeviceManager* usb_device_manager() { return usb_device_manager_.get(); } - - private: - usb::DeviceManagerPtr usb_device_manager_; - - DISALLOW_COPY_AND_ASSIGN(DevicesAppTest); -}; - -void OnGetDevices(const base::Closure& continuation, - mojo::Array<usb::DeviceInfoPtr> devices) { - continuation.Run(); -} - -} // namespace - -// Simple test to verify that we can connect to the USB DeviceManager and get -// a response. -TEST_F(DevicesAppTest, GetUSBDevices) { - base::RunLoop loop; - usb::EnumerationOptionsPtr options = usb::EnumerationOptions::New(); - options->filters = mojo::Array<usb::DeviceFilterPtr>(1); - options->filters[0] = usb::DeviceFilter::New(); - usb_device_manager()->GetDevices( - std::move(options), base::Bind(&OnGetDevices, loop.QuitClosure())); - loop.Run(); -} - -} // namespace device diff --git a/device/devices_app/main.cc b/device/devices_app/main.cc deleted file mode 100644 index 1694aac..0000000 --- a/device/devices_app/main.cc +++ /dev/null @@ -1,15 +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 "base/sequenced_task_runner.h" -#include "device/devices_app/public/cpp/devices_app_factory.h" -#include "mojo/public/c/system/main.h" -#include "mojo/shell/public/cpp/application_runner.h" -#include "mojo/shell/public/cpp/shell_client.h" - -MojoResult MojoMain(MojoHandle shell_handle) { - mojo::ApplicationRunner runner( - device::DevicesAppFactory::CreateApp().release()); - return runner.Run(shell_handle); -} diff --git a/device/devices_app/public/cpp/BUILD.gn b/device/devices_app/public/cpp/BUILD.gn deleted file mode 100644 index 301d20f..0000000 --- a/device/devices_app/public/cpp/BUILD.gn +++ /dev/null @@ -1,29 +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. - -source_set("cpp") { - sources = [ - "constants.cc", - "constants.h", - ] - - public_deps = [ - "//base", - ] -} - -source_set("factory") { - sources = [ - "devices_app_factory.cc", - "devices_app_factory.h", - ] - - deps = [ - "//device/devices_app:lib", - ] - - public_deps = [ - "//base", - ] -} diff --git a/device/devices_app/public/cpp/constants.cc b/device/devices_app/public/cpp/constants.cc deleted file mode 100644 index 3bf4e01..0000000 --- a/device/devices_app/public/cpp/constants.cc +++ /dev/null @@ -1,11 +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/devices_app/public/cpp/constants.h" - -namespace device { - -const char kDevicesMojoAppUrl[] = "mojo:devices"; - -} // namespace device diff --git a/device/devices_app/public/cpp/constants.h b/device/devices_app/public/cpp/constants.h deleted file mode 100644 index dfe242a..0000000 --- a/device/devices_app/public/cpp/constants.h +++ /dev/null @@ -1,14 +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. - -#ifndef DEVICE_DEVICES_APP_PUBLIC_CPP_CONSTANTS_H_ -#define DEVICE_DEVICES_APP_PUBLIC_CPP_CONSTANTS_H_ - -namespace device { - -extern const char kDevicesMojoAppUrl[]; - -} // namespace device - -#endif // DEVICE_DEVICES_APP_PUBLIC_CPP_CONSTANTS_H_ diff --git a/device/devices_app/public/cpp/devices_app_factory.cc b/device/devices_app/public/cpp/devices_app_factory.cc deleted file mode 100644 index 154f67c..0000000 --- a/device/devices_app/public/cpp/devices_app_factory.cc +++ /dev/null @@ -1,16 +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/devices_app/public/cpp/devices_app_factory.h" - -#include "device/devices_app/devices_app.h" - -namespace device { - -// static -scoped_ptr<mojo::ShellClient> DevicesAppFactory::CreateApp() { - return scoped_ptr<mojo::ShellClient>(new DevicesApp()); -} - -} // namespace device diff --git a/device/devices_app/public/cpp/devices_app_factory.h b/device/devices_app/public/cpp/devices_app_factory.h deleted file mode 100644 index 6ba7447..0000000 --- a/device/devices_app/public/cpp/devices_app_factory.h +++ /dev/null @@ -1,28 +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. - -#ifndef DEVICE_DEVICES_APP_PUBLIC_CPP_DEVICES_APP_FACTORY_H_ -#define DEVICE_DEVICES_APP_PUBLIC_CPP_DEVICES_APP_FACTORY_H_ - -#include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" - -namespace mojo { -class ShellClient; -} - -namespace device { - -// Public factory for creating new instances of the devices app. -class DevicesAppFactory { - public: - // Creates a DevicesApp delegate which can be used to launch a new instance - // of the devices app on a mojo application runner. The caller owns the - // delegate. - static scoped_ptr<mojo::ShellClient> CreateApp(); -}; - -} // namespace device - -#endif // DEVICE_DEVICES_APP_PUBLIC_CPP_DEVICES_APP_FACTORY_H_ diff --git a/device/devices_app/usb/DEPS b/device/devices_app/usb/DEPS deleted file mode 100644 index 134e14a..0000000 --- a/device/devices_app/usb/DEPS +++ /dev/null @@ -1,4 +0,0 @@ -include_rules = [ - "-net", - "+net/base", -] diff --git a/device/usb/mojo/BUILD.gn b/device/usb/mojo/BUILD.gn new file mode 100644 index 0000000..d48cf37 --- /dev/null +++ b/device/usb/mojo/BUILD.gn @@ -0,0 +1,24 @@ +# Copyright 2016 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. + +source_set("mojo") { + sources = [ + "device_impl.cc", + "device_impl.h", + "device_manager_impl.cc", + "device_manager_impl.h", + "type_converters.cc", + "type_converters.h", + ] + + deps = [ + "//device/core", + "//device/usb", + "//device/usb/public/interfaces", + "//mojo/common", + "//mojo/public/cpp/bindings", + "//mojo/public/cpp/bindings:callback", + "//net", + ] +} diff --git a/device/devices_app/DEPS b/device/usb/mojo/DEPS index 7256f77..6cfa565 100644 --- a/device/devices_app/DEPS +++ b/device/usb/mojo/DEPS @@ -1,4 +1,3 @@ include_rules = [ - "+mojo/shell/public", "+mojo/common", ] diff --git a/device/devices_app/usb/device_impl.cc b/device/usb/mojo/device_impl.cc index 2eb3ed5..724e911 100644 --- a/device/devices_app/usb/device_impl.cc +++ b/device/usb/mojo/device_impl.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "device/devices_app/usb/device_impl.h" +#include "device/usb/mojo/device_impl.h" #include <stddef.h> @@ -14,7 +14,7 @@ #include "base/bind.h" #include "base/callback.h" #include "base/stl_util.h" -#include "device/devices_app/usb/type_converters.h" +#include "device/usb/mojo/type_converters.h" #include "device/usb/usb_descriptors.h" #include "device/usb/usb_device.h" #include "net/base/io_buffer.h" diff --git a/device/devices_app/usb/device_impl.h b/device/usb/mojo/device_impl.h index 2b438c8..e19feef 100644 --- a/device/devices_app/usb/device_impl.h +++ b/device/usb/mojo/device_impl.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef DEVICE_DEVICES_APP_USB_DEVICE_IMPL_H_ -#define DEVICE_DEVICES_APP_USB_DEVICE_IMPL_H_ +#ifndef DEVICE_USB_MOJO_DEVICE_IMPL_H_ +#define DEVICE_USB_MOJO_DEVICE_IMPL_H_ #include <stdint.h> @@ -11,8 +11,8 @@ #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" -#include "device/devices_app/usb/public/interfaces/device.mojom.h" -#include "device/devices_app/usb/public/interfaces/permission_provider.mojom.h" +#include "device/usb/public/interfaces/device.mojom.h" +#include "device/usb/public/interfaces/permission_provider.mojom.h" #include "device/usb/usb_device_handle.h" #include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/cpp/bindings/callback.h" @@ -110,4 +110,4 @@ class DeviceImpl : public Device { } // namespace usb } // namespace device -#endif // DEVICE_DEVICES_APP_USB_DEVICE_IMPL_H_ +#endif // DEVICE_USB_MOJO_DEVICE_IMPL_H_ diff --git a/device/devices_app/usb/device_impl_unittest.cc b/device/usb/mojo/device_impl_unittest.cc index b98d330..626edd9 100644 --- a/device/devices_app/usb/device_impl_unittest.cc +++ b/device/usb/mojo/device_impl_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "device/devices_app/usb/device_impl.h" +#include "device/usb/mojo/device_impl.h" #include <stddef.h> #include <stdint.h> @@ -20,9 +20,9 @@ #include "base/message_loop/message_loop.h" #include "base/run_loop.h" #include "base/stl_util.h" -#include "device/devices_app/usb/fake_permission_provider.h" #include "device/usb/mock_usb_device.h" #include "device/usb/mock_usb_device_handle.h" +#include "device/usb/mojo/fake_permission_provider.h" #include "mojo/public/cpp/bindings/interface_request.h" #include "net/base/io_buffer.h" #include "testing/gtest/include/gtest/gtest.h" @@ -337,8 +337,8 @@ class USBDeviceImplTest : public testing::Test { const std::vector<uint8_t>& bytes = mock_outbound_data_.front(); ASSERT_EQ(bytes.size(), length); for (size_t i = 0; i < length; ++i) { - EXPECT_EQ(bytes[i], buffer->data()[i]) - << "Contents differ at index: " << i; + EXPECT_EQ(bytes[i], buffer->data()[i]) << "Contents differ at index: " + << i; } mock_outbound_data_.pop(); callback.Run(USB_TRANSFER_COMPLETED, buffer, length); diff --git a/device/devices_app/usb/device_manager_impl.cc b/device/usb/mojo/device_manager_impl.cc index b3f7784..fdb4d5c 100644 --- a/device/devices_app/usb/device_manager_impl.cc +++ b/device/usb/mojo/device_manager_impl.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "device/devices_app/usb/device_manager_impl.h" +#include "device/usb/mojo/device_manager_impl.h" #include <stddef.h> #include <utility> @@ -12,9 +12,9 @@ #include "base/memory/scoped_ptr.h" #include "base/stl_util.h" #include "device/core/device_client.h" -#include "device/devices_app/usb/device_impl.h" -#include "device/devices_app/usb/public/interfaces/device.mojom.h" -#include "device/devices_app/usb/type_converters.h" +#include "device/usb/mojo/device_impl.h" +#include "device/usb/mojo/type_converters.h" +#include "device/usb/public/interfaces/device.mojom.h" #include "device/usb/usb_device.h" #include "device/usb/usb_device_filter.h" #include "device/usb/usb_service.h" diff --git a/device/devices_app/usb/device_manager_impl.h b/device/usb/mojo/device_manager_impl.h index 4e9578d..85e46ce 100644 --- a/device/devices_app/usb/device_manager_impl.h +++ b/device/usb/mojo/device_manager_impl.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef DEVICE_USB_DEVICE_MANAGER_IMPL_H_ -#define DEVICE_USB_DEVICE_MANAGER_IMPL_H_ +#ifndef DEVICE_USB_MOJO_DEVICE_MANAGER_IMPL_H_ +#define DEVICE_USB_MOJO_DEVICE_MANAGER_IMPL_H_ #include <queue> #include <set> @@ -13,8 +13,8 @@ #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/public/interfaces/device_manager.mojom.h" +#include "device/usb/public/interfaces/permission_provider.mojom.h" #include "device/usb/usb_service.h" #include "mojo/public/cpp/bindings/array.h" #include "mojo/public/cpp/bindings/binding.h" @@ -108,4 +108,4 @@ class DeviceManagerImpl : public DeviceManager, } // namespace usb } // namespace device -#endif // DEVICE_USB_DEVICE_MANAGER_IMPL_H_ +#endif // DEVICE_USB_MOJO_DEVICE_MANAGER_IMPL_H_ diff --git a/device/devices_app/usb/device_manager_impl_unittest.cc b/device/usb/mojo/device_manager_impl_unittest.cc index 720c811..139f5a03 100644 --- a/device/devices_app/usb/device_manager_impl_unittest.cc +++ b/device/usb/mojo/device_manager_impl_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "device/devices_app/usb/device_manager_impl.h" +#include "device/usb/mojo/device_manager_impl.h" #include <stddef.h> #include <set> @@ -16,11 +16,11 @@ #include "base/run_loop.h" #include "base/thread_task_runner_handle.h" #include "device/core/mock_device_client.h" -#include "device/devices_app/usb/device_impl.h" -#include "device/devices_app/usb/fake_permission_provider.h" #include "device/usb/mock_usb_device.h" #include "device/usb/mock_usb_device_handle.h" #include "device/usb/mock_usb_service.h" +#include "device/usb/mojo/device_impl.h" +#include "device/usb/mojo/fake_permission_provider.h" #include "testing/gtest/include/gtest/gtest.h" using ::testing::Invoke; diff --git a/device/devices_app/usb/fake_permission_provider.cc b/device/usb/mojo/fake_permission_provider.cc index 3a774a8..9dd7b4f 100644 --- a/device/devices_app/usb/fake_permission_provider.cc +++ b/device/usb/mojo/fake_permission_provider.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "device/devices_app/usb/fake_permission_provider.h" +#include "device/usb/mojo/fake_permission_provider.h" #include <stddef.h> #include <utility> diff --git a/device/devices_app/usb/fake_permission_provider.h b/device/usb/mojo/fake_permission_provider.h index 62947b4..22292ee 100644 --- a/device/devices_app/usb/fake_permission_provider.h +++ b/device/usb/mojo/fake_permission_provider.h @@ -7,7 +7,7 @@ #include <stdint.h> -#include "device/devices_app/usb/public/interfaces/permission_provider.mojom.h" +#include "device/usb/public/interfaces/permission_provider.mojom.h" #include "mojo/common/weak_binding_set.h" #include "mojo/public/cpp/bindings/array.h" #include "mojo/public/cpp/bindings/interface_request.h" diff --git a/device/devices_app/usb/type_converters.cc b/device/usb/mojo/type_converters.cc index 709b0ca..0145abd 100644 --- a/device/devices_app/usb/type_converters.cc +++ b/device/usb/mojo/type_converters.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "device/devices_app/usb/type_converters.h" +#include "device/usb/mojo/type_converters.h" #include <stddef.h> #include <stdint.h> @@ -185,8 +185,10 @@ TypeConverter<mojo::Array<device::usb::InterfaceInfoPtr>, // This is the first time we're seeing an alternate with this interface // number, so add a new InterfaceInfo to the array and map the number. auto info = device::usb::InterfaceInfo::New(); - iter = interface_map.insert(std::make_pair(interfaces[i].interface_number, - info.get())).first; + iter = interface_map + .insert( + std::make_pair(interfaces[i].interface_number, info.get())) + .first; infos.push_back(std::move(info)); } iter->second->alternates.push_back(std::move(alternate)); diff --git a/device/devices_app/usb/type_converters.h b/device/usb/mojo/type_converters.h index 15484ea..4984c6e 100644 --- a/device/devices_app/usb/type_converters.h +++ b/device/usb/mojo/type_converters.h @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef DEVICE_DEVICES_APP_USB_TYPE_CONVERTERS_H_ -#define DEVICE_DEVICES_APP_USB_TYPE_CONVERTERS_H_ +#ifndef DEVICE_USB_MOJO_TYPE_CONVERTERS_H_ +#define DEVICE_USB_MOJO_TYPE_CONVERTERS_H_ #include <vector> -#include "device/devices_app/usb/public/interfaces/device.mojom.h" -#include "device/devices_app/usb/public/interfaces/device_manager.mojom.h" +#include "device/usb/public/interfaces/device.mojom.h" +#include "device/usb/public/interfaces/device_manager.mojom.h" #include "device/usb/usb_descriptors.h" #include "device/usb/usb_device_filter.h" #include "device/usb/usb_device_handle.h" diff --git a/device/devices_app/usb/public/interfaces/BUILD.gn b/device/usb/public/interfaces/BUILD.gn index f9d6e0c..f9d6e0c 100644 --- a/device/devices_app/usb/public/interfaces/BUILD.gn +++ b/device/usb/public/interfaces/BUILD.gn diff --git a/device/devices_app/usb/public/interfaces/device.mojom b/device/usb/public/interfaces/device.mojom index 25addb2..25addb2 100644 --- a/device/devices_app/usb/public/interfaces/device.mojom +++ b/device/usb/public/interfaces/device.mojom diff --git a/device/devices_app/usb/public/interfaces/device_manager.mojom b/device/usb/public/interfaces/device_manager.mojom index fa8bb75..fa8bb75 100644 --- a/device/devices_app/usb/public/interfaces/device_manager.mojom +++ b/device/usb/public/interfaces/device_manager.mojom diff --git a/device/devices_app/usb/public/interfaces/permission_provider.mojom b/device/usb/public/interfaces/permission_provider.mojom index f5d7111..f5d7111 100644 --- a/device/devices_app/usb/public/interfaces/permission_provider.mojom +++ b/device/usb/public/interfaces/permission_provider.mojom diff --git a/device/usb/usb.gyp b/device/usb/usb.gyp index a68b187..7f5e676 100644 --- a/device/usb/usb.gyp +++ b/device/usb/usb.gyp @@ -22,6 +22,12 @@ 'sources': [ 'android/usb_jni_registrar.cc', 'android/usb_jni_registrar.h', + 'mojo/device_impl.cc', + 'mojo/device_impl.h', + 'mojo/device_manager_impl.cc', + 'mojo/device_manager_impl.h', + 'mojo/type_converters.cc', + 'mojo/type_converters.h', 'usb_configuration_android.cc', 'usb_configuration_android.h', 'usb_context.cc', @@ -116,6 +122,18 @@ ] }, { + 'target_name': 'device_usb_mojo_bindings', + 'type': 'static_library', + 'sources': [ + 'public/interfaces/device.mojom', + 'public/interfaces/device_manager.mojom', + 'public/interfaces/permission_provider.mojom', + ], + 'includes': [ + '../../mojo/mojom_bindings_generator.gypi', + ], + }, + { 'target_name': 'device_usb_mocks', 'type': 'static_library', 'include_dirs': [ |