summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrockot <rockot@chromium.org>2015-07-07 18:57:26 -0700
committerCommit bot <commit-bot@chromium.org>2015-07-08 01:58:07 +0000
commit50dc5691dca512231732f98043cd181edece239a (patch)
tree9b4d7d6709b707a4b2846836f8cff13bd0c78d2e
parent71ed6cb17d8d5cb570e95b29f916d5f0f576a4f6 (diff)
downloadchromium_src-50dc5691dca512231732f98043cd181edece239a.zip
chromium_src-50dc5691dca512231732f98043cd181edece239a.tar.gz
chromium_src-50dc5691dca512231732f98043cd181edece239a.tar.bz2
Reland: Add a public cpp targets for devices_app
This exposes the bare minimum stuff necessary to build a devices app delegate, hiding the impl details behind a private dependency. Reland corrects a missing include in the app's main.cc. This is a reland of the reland! The reland was reverted due to suspicion of cast_shell_linux breakage, but that was caused by something else. BUG=None TBR=reillyg@chromium.org,sky@chromium.org Review URL: https://codereview.chromium.org/1213613018 Cr-Commit-Position: refs/heads/master@{#337725}
-rw-r--r--chrome/browser/BUILD.gn4
-rw-r--r--chrome/browser/DEPS3
-rw-r--r--chrome/browser/chrome_content_browser_client.cc6
-rw-r--r--chrome/chrome_browser.gypi4
-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
14 files changed, 153 insertions, 31 deletions
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
index 444cea9..ce32356 100644
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
@@ -275,6 +275,7 @@ source_set("browser") {
"//components/web_modal",
"//content/app/resources",
"//media",
+ "//mojo/application/public/cpp",
"//mojo/common",
"//mojo/environment:chromium",
"//net:extras",
@@ -625,7 +626,8 @@ source_set("browser") {
deps += [
"//components/feedback",
"//device/core",
- "//device/devices_app:lib",
+ "//device/devices_app/public/cpp",
+ "//device/devices_app/public/cpp:factory",
"//device/usb",
]
}
diff --git a/chrome/browser/DEPS b/chrome/browser/DEPS
index 5f16e0c..5364d32 100644
--- a/chrome/browser/DEPS
+++ b/chrome/browser/DEPS
@@ -104,7 +104,7 @@ include_rules = [
"+courgette",
"+device/bluetooth",
"+device/core",
- "+device/devices_app",
+ "+device/devices_app/public",
"+device/hid",
"+device/usb",
"+device/media_transfer_protocol",
@@ -122,6 +122,7 @@ include_rules = [
"+jni",
"+media/audio", # For media audio hang monitor.
"+media/base", # For media switches
+ "+mojo/application/public/cpp",
"+policy", # For generated headers and source
"+ppapi/c", # For various types.
"+ppapi/host",
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index 44869b2..672a96d 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -130,8 +130,10 @@
#include "content/public/common/service_registry.h"
#include "content/public/common/url_utils.h"
#include "content/public/common/web_preferences.h"
-#include "device/devices_app/devices_app.h"
+#include "device/devices_app/public/cpp/constants.h"
+#include "device/devices_app/public/cpp/devices_app_factory.h"
#include "gin/v8_initializer.h"
+#include "mojo/application/public/cpp/application_delegate.h"
#include "net/base/mime_util.h"
#include "net/cookies/canonical_cookie.h"
#include "net/cookies/cookie_options.h"
@@ -2423,7 +2425,7 @@ void ChromeContentBrowserClient::RegisterMojoApplications(
StaticMojoApplicationMap* apps) {
#if !defined(OS_ANDROID) && !defined(OS_IOS)
apps->insert(std::make_pair(GURL(device::kDevicesMojoAppUrl),
- base::Bind(&device::DevicesApp::CreateDelegate,
+ base::Bind(&device::DevicesAppFactory::CreateApp,
base::ThreadTaskRunnerHandle::Get())));
#endif
}
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 5ce3e27..ea471e3 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -3279,6 +3279,7 @@
'../content/app/resources/content_resources.gyp:content_resources',
'../media/media.gyp:media',
'../media/mojo/interfaces/mojo_bindings.gyp:platform_verification_api',
+ '../mojo/mojo_base.gyp:mojo_application_base',
'../mojo/mojo_base.gyp:mojo_common_lib',
'../mojo/mojo_base.gyp:mojo_environment_chromium',
'../net/net.gyp:net_extras',
@@ -3643,7 +3644,8 @@
'dependencies': [
'../components/components.gyp:feedback_component',
'../device/core/core.gyp:device_core',
- '../device/devices_app/devices_app.gyp:devices_app_lib',
+ '../device/devices_app/devices_app.gyp:devices_app_public_cpp',
+ '../device/devices_app/devices_app.gyp:devices_app_public_cpp_factory',
'../device/usb/usb.gyp:device_usb',
'../net/net.gyp:net_browser_services',
]
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_