summaryrefslogtreecommitdiffstats
path: root/device/devices_app
diff options
context:
space:
mode:
Diffstat (limited to 'device/devices_app')
-rw-r--r--device/devices_app/BUILD.gn2
-rw-r--r--device/devices_app/devices_app.cc15
-rw-r--r--device/devices_app/devices_app.gyp22
-rw-r--r--device/devices_app/devices_app.h13
-rw-r--r--device/devices_app/main.cc5
-rw-r--r--device/devices_app/public/cpp/BUILD.gn29
-rw-r--r--device/devices_app/public/cpp/constants.cc11
-rw-r--r--device/devices_app/public/cpp/constants.h14
-rw-r--r--device/devices_app/public/cpp/devices_app_factory.cc18
-rw-r--r--device/devices_app/public/cpp/devices_app_factory.h38
10 files changed, 141 insertions, 26 deletions
diff --git a/device/devices_app/BUILD.gn b/device/devices_app/BUILD.gn
index 233d263..1621e11 100644
--- a/device/devices_app/BUILD.gn
+++ b/device/devices_app/BUILD.gn
@@ -40,8 +40,8 @@ mojo_native_application("devices") {
]
deps = [
- ":lib",
"//base",
+ "//device/devices_app/public/cpp:factory",
"//mojo/application/public/cpp",
]
diff --git a/device/devices_app/devices_app.cc b/device/devices_app/devices_app.cc
index 318ebf6..0aab6cb 100644
--- a/device/devices_app/devices_app.cc
+++ b/device/devices_app/devices_app.cc
@@ -23,8 +23,6 @@
namespace device {
-const char kDevicesMojoAppUrl[] = "system:devices";
-
namespace {
// The number of seconds to wait without any bound DeviceManagers before
@@ -100,16 +98,6 @@ class DevicesApp::USBServiceInitializer {
DISALLOW_COPY_AND_ASSIGN(USBServiceInitializer);
};
-DevicesApp::~DevicesApp() {
-}
-
-// static
-scoped_ptr<mojo::ApplicationDelegate> DevicesApp::CreateDelegate(
- scoped_refptr<base::SequencedTaskRunner> service_task_runner) {
- return scoped_ptr<mojo::ApplicationDelegate>(
- new DevicesApp(service_task_runner));
-}
-
DevicesApp::DevicesApp(
scoped_refptr<base::SequencedTaskRunner> service_task_runner)
: app_impl_(nullptr),
@@ -117,6 +105,9 @@ DevicesApp::DevicesApp(
active_device_manager_count_(0) {
}
+DevicesApp::~DevicesApp() {
+}
+
void DevicesApp::Initialize(mojo::ApplicationImpl* app) {
app_impl_ = app;
if (!service_task_runner_) {
diff --git a/device/devices_app/devices_app.gyp b/device/devices_app/devices_app.gyp
index 8cf952d..c983893 100644
--- a/device/devices_app/devices_app.gyp
+++ b/device/devices_app/devices_app.gyp
@@ -57,5 +57,27 @@
'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
index 4b04568..eda8d4c 100644
--- a/device/devices_app/devices_app.h
+++ b/device/devices_app/devices_app.h
@@ -27,26 +27,17 @@ namespace usb {
class DeviceManager;
}
-extern const char kDevicesMojoAppUrl[];
-
class DevicesApp : public mojo::ApplicationDelegate,
public mojo::InterfaceFactory<usb::DeviceManager>,
public mojo::ErrorHandler {
public:
- ~DevicesApp() override;
-
- // |service_task_runner| is the thread TaskRunner on which the UsbService
- // lives. This argument should be removed once UsbService is owned by the
- // USB device manager and no longer part of the public device API. If null,
- // the app will construct its own DeviceClient and UsbService.
- static scoped_ptr<mojo::ApplicationDelegate> CreateDelegate(
+ explicit DevicesApp(
scoped_refptr<base::SequencedTaskRunner> service_task_runner);
+ ~DevicesApp() override;
private:
class USBServiceInitializer;
- DevicesApp(scoped_refptr<base::SequencedTaskRunner> service_task_runner);
-
// mojo::ApplicationDelegate:
void Initialize(mojo::ApplicationImpl* app) override;
bool ConfigureIncomingConnection(
diff --git a/device/devices_app/main.cc b/device/devices_app/main.cc
index e82edb3..4c8e61b 100644
--- a/device/devices_app/main.cc
+++ b/device/devices_app/main.cc
@@ -3,12 +3,13 @@
// found in the LICENSE file.
#include "base/sequenced_task_runner.h"
-#include "device/devices_app/devices_app.h"
+#include "device/devices_app/public/cpp/devices_app_factory.h"
+#include "mojo/application/public/cpp/application_delegate.h"
#include "mojo/application/public/cpp/application_runner.h"
#include "third_party/mojo/src/mojo/public/c/system/main.h"
MojoResult MojoMain(MojoHandle shell_handle) {
mojo::ApplicationRunner runner(
- device::DevicesApp::CreateDelegate(nullptr).release());
+ device::DevicesAppFactory::CreateApp(nullptr).release());
return runner.Run(shell_handle);
}
diff --git a/device/devices_app/public/cpp/BUILD.gn b/device/devices_app/public/cpp/BUILD.gn
new file mode 100644
index 0000000..301d20f
--- /dev/null
+++ b/device/devices_app/public/cpp/BUILD.gn
@@ -0,0 +1,29 @@
+# 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
new file mode 100644
index 0000000..211017b
--- /dev/null
+++ b/device/devices_app/public/cpp/constants.cc
@@ -0,0 +1,11 @@
+// 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[] = "system:devices";
+
+} // namespace device
diff --git a/device/devices_app/public/cpp/constants.h b/device/devices_app/public/cpp/constants.h
new file mode 100644
index 0000000..dfe242a
--- /dev/null
+++ b/device/devices_app/public/cpp/constants.h
@@ -0,0 +1,14 @@
+// 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
new file mode 100644
index 0000000..ee85c09
--- /dev/null
+++ b/device/devices_app/public/cpp/devices_app_factory.cc
@@ -0,0 +1,18 @@
+// 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::ApplicationDelegate> DevicesAppFactory::CreateApp(
+ scoped_refptr<base::SequencedTaskRunner> service_task_runner) {
+ return scoped_ptr<mojo::ApplicationDelegate>(
+ new DevicesApp(service_task_runner));
+}
+
+} // namespace device
diff --git a/device/devices_app/public/cpp/devices_app_factory.h b/device/devices_app/public/cpp/devices_app_factory.h
new file mode 100644
index 0000000..5642741
--- /dev/null
+++ b/device/devices_app/public/cpp/devices_app_factory.h
@@ -0,0 +1,38 @@
+// 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 base {
+class SequencedTaskRunner;
+}
+
+namespace mojo {
+class ApplicationDelegate;
+}
+
+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.
+ //
+ // |service_task_runner| is the thread TaskRunner on which the UsbService
+ // lives. This argument should be removed once UsbService is owned by the
+ // USB device manager and no longer part of the public device API. If null,
+ // the app will construct its own DeviceClient and UsbService.
+ static scoped_ptr<mojo::ApplicationDelegate> CreateApp(
+ scoped_refptr<base::SequencedTaskRunner> service_task_runner);
+};
+
+} // namespace device
+
+#endif // DEVICE_DEVICES_APP_PUBLIC_CPP_DEVICES_APP_FACTORY_H_