diff options
-rw-r--r-- | components/clipboard/BUILD.gn | 13 | ||||
-rw-r--r-- | components/clipboard/OWNERS | 1 | ||||
-rw-r--r-- | components/core_services/BUILD.gn | 26 | ||||
-rw-r--r-- | components/core_services/DEPS | 7 | ||||
-rw-r--r-- | components/core_services/OWNERS | 2 | ||||
-rw-r--r-- | components/core_services/core_services_application_delegate.cc | 57 | ||||
-rw-r--r-- | components/core_services/core_services_application_delegate.h | 47 | ||||
-rw-r--r-- | components/core_services/main.cc | 13 | ||||
-rw-r--r-- | components/html_viewer/blink_platform_impl.cc | 5 | ||||
-rw-r--r-- | mojo/services/BUILD.gn | 2 |
10 files changed, 169 insertions, 4 deletions
diff --git a/components/clipboard/BUILD.gn b/components/clipboard/BUILD.gn index 2aaae77..c7caccf 100644 --- a/components/clipboard/BUILD.gn +++ b/components/clipboard/BUILD.gn @@ -4,16 +4,25 @@ import("//third_party/mojo/src/mojo/public/mojo_application.gni") -mojo_native_application("clipboard") { +source_set("lib") { sources = [ "clipboard_standalone_impl.cc", "clipboard_standalone_impl.h", + ] + + deps = [ + "//components/clipboard/public/interfaces", + ] +} + +mojo_native_application("clipboard") { + sources = [ "main.cc", ] deps = [ + ":lib", "//base", - "//components/clipboard/public/interfaces", "//mojo/application", "//mojo/common", "//mojo/environment:chromium", diff --git a/components/clipboard/OWNERS b/components/clipboard/OWNERS new file mode 100644 index 0000000..4733a4f --- /dev/null +++ b/components/clipboard/OWNERS @@ -0,0 +1 @@ +erg@chromium.org diff --git a/components/core_services/BUILD.gn b/components/core_services/BUILD.gn new file mode 100644 index 0000000..b82d36e --- /dev/null +++ b/components/core_services/BUILD.gn @@ -0,0 +1,26 @@ +# 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("//build/config/ui.gni") +import("//third_party/mojo/src/mojo/public/mojo_application.gni") +import("//testing/test.gni") + +# core_services should be thought of as a bundle of many of the services which +# we ship with. +mojo_native_application("core_services") { + sources = [ + "core_services_application_delegate.cc", + "main.cc", + ] + + deps = [ + "//base", + "//components/clipboard:lib", + "//mojo/application", + "//mojo/common", + "//mojo/environment:chromium", + "//third_party/mojo/src/mojo/public/interfaces/application", + "//third_party/mojo/src/mojo/public/cpp/bindings:bindings", + ] +} diff --git a/components/core_services/DEPS b/components/core_services/DEPS new file mode 100644 index 0000000..213f11f --- /dev/null +++ b/components/core_services/DEPS @@ -0,0 +1,7 @@ +include_rules = [ + "+components/clipboard", + "+mojo/application", + "+mojo/common", + "+third_party/mojo_services/src/clipboard", + "+third_party/mojo/src/mojo/public", +] diff --git a/components/core_services/OWNERS b/components/core_services/OWNERS new file mode 100644 index 0000000..a4e2d8f --- /dev/null +++ b/components/core_services/OWNERS @@ -0,0 +1,2 @@ +erg@chromium.org +sky@chromium.org diff --git a/components/core_services/core_services_application_delegate.cc b/components/core_services/core_services_application_delegate.cc new file mode 100644 index 0000000..2966950 --- /dev/null +++ b/components/core_services/core_services_application_delegate.cc @@ -0,0 +1,57 @@ +// 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 "components/core_services/core_services_application_delegate.h" + +#include "components/clipboard/clipboard_standalone_impl.h" +#include "third_party/mojo/src/mojo/public/cpp/application/application_connection.h" + +namespace core_services { + +CoreServicesApplicationDelegate::CoreServicesApplicationDelegate() {} + +CoreServicesApplicationDelegate::~CoreServicesApplicationDelegate() {} + +bool CoreServicesApplicationDelegate::ConfigureIncomingConnection( + mojo::ApplicationConnection* connection) { + // TODO(erg): For version one, we'll just say that all incoming connections + // get access to the same objects, which imply that there will be one + // instance of the service in its own process. However, in the long run, + // we'll want this to be more configurable. Some services are singletons, + // while we'll want to spawn a new process with multiple instances for other + // services. + connection->AddService<mojo::ServiceProvider>(this); + return true; +} + +void CoreServicesApplicationDelegate::Create( + mojo::ApplicationConnection* connection, + mojo::InterfaceRequest<ServiceProvider> request) { + provider_bindings_.AddBinding(this, request.Pass()); +} + +void CoreServicesApplicationDelegate::ConnectToService( + const mojo::String& service_name, + mojo::ScopedMessagePipeHandle client_handle) { + if (service_name == mojo::Clipboard::Name_) { + // TODO(erg): So what we do here probably doesn't look like the + // InProcessNativeRunner / NativeApplicationSupport. + // native_application_support.cc does the whole SetThunks() stuff. This has + // already happened since Core Services is a mojo application. So we want + // some sort of lightweight runner here. + // + // But...the actual child process stuff is its own mojom! (Also, it's + // entangled with mojo::Shell::ChildProcessMain().) All concept of app + // paths are the things which are used to execute the application in + // child_process.cc. + + // TODO(erg): The lifetime of ClipboardStandaloneImpl is wrong. Right now, + // a new object is made for each request, but we obviously want there to be + // one clipboard across all callers. + new clipboard::ClipboardStandaloneImpl( + mojo::MakeRequest<mojo::Clipboard>(client_handle.Pass())); + } +} + +} // namespace core_services diff --git a/components/core_services/core_services_application_delegate.h b/components/core_services/core_services_application_delegate.h new file mode 100644 index 0000000..2662e41 --- /dev/null +++ b/components/core_services/core_services_application_delegate.h @@ -0,0 +1,47 @@ +// 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 COMPONENTS_CORE_SERVICES_APPLICATION_DELEGATE_H_ +#define COMPONENTS_CORE_SERVICES_APPLICATION_DELEGATE_H_ + +#include "base/macros.h" +#include "mojo/common/weak_binding_set.h" +#include "third_party/mojo/src/mojo/public/cpp/application/application_delegate.h" +#include "third_party/mojo/src/mojo/public/cpp/application/interface_factory_impl.h" +#include "third_party/mojo/src/mojo/public/interfaces/application/service_provider.mojom.h" + +namespace core_services { + +// The CoreServices application is a singleton ServiceProvider. There is one +// instance of the CoreServices ServiceProvider. +class CoreServicesApplicationDelegate + : public mojo::ApplicationDelegate, + public mojo::InterfaceFactory<mojo::ServiceProvider>, + public mojo::ServiceProvider { + public: + CoreServicesApplicationDelegate(); + ~CoreServicesApplicationDelegate() override; + + private: + // Overridden from mojo::ApplicationDelegate: + bool ConfigureIncomingConnection( + mojo::ApplicationConnection* connection) override; + + // Overridden from mojo::InterfaceFactory<ServiceProvider>: + void Create(mojo::ApplicationConnection* connection, + mojo::InterfaceRequest<ServiceProvider> request) override; + + // Overridden from ServiceProvider: + void ConnectToService(const mojo::String& service_name, + mojo::ScopedMessagePipeHandle client_handle) override; + + // Bindings for all of our connections. + mojo::WeakBindingSet<ServiceProvider> provider_bindings_; + + DISALLOW_COPY_AND_ASSIGN(CoreServicesApplicationDelegate); +}; + +} // namespace core_services + +#endif // COMPONENTS_CORE_SERVICES_APPLICATION_DELEGATE_H_ diff --git a/components/core_services/main.cc b/components/core_services/main.cc new file mode 100644 index 0000000..1f664c8 --- /dev/null +++ b/components/core_services/main.cc @@ -0,0 +1,13 @@ +// 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 "components/core_services/core_services_application_delegate.h" +#include "mojo/application/application_runner_chromium.h" +#include "third_party/mojo/src/mojo/public/c/system/main.h" + +MojoResult MojoMain(MojoHandle shell_handle) { + mojo::ApplicationRunnerChromium runner( + new core_services::CoreServicesApplicationDelegate); + return runner.Run(shell_handle); +} diff --git a/components/html_viewer/blink_platform_impl.cc b/components/html_viewer/blink_platform_impl.cc index 4c4ff85..4f71823 100644 --- a/components/html_viewer/blink_platform_impl.cc +++ b/components/html_viewer/blink_platform_impl.cc @@ -25,6 +25,7 @@ #include "net/base/net_util.h" #include "third_party/WebKit/public/platform/WebWaitableEvent.h" #include "third_party/mojo/src/mojo/public/cpp/application/application_impl.h" +#include "third_party/mojo/src/mojo/public/cpp/application/connect.h" #include "ui/events/gestures/blink/web_gesture_curve_impl.h" namespace html_viewer { @@ -72,8 +73,10 @@ BlinkPlatformImpl::BlinkPlatformImpl(mojo::ApplicationImpl* app) network_service_->GetCookieStore(GetProxy(&cookie_store)); cookie_jar_.reset(new WebCookieJarImpl(cookie_store.Pass())); + mojo::ServiceProviderPtr service_provider; + app->ConnectToService("mojo:core_services", &service_provider); mojo::ClipboardPtr clipboard; - app->ConnectToService("mojo:clipboard", &clipboard); + mojo::ConnectToService(service_provider.get(), &clipboard); clipboard_.reset(new WebClipboardImpl(clipboard.Pass())); } } diff --git a/mojo/services/BUILD.gn b/mojo/services/BUILD.gn index c18feb4..cb6c9e5b 100644 --- a/mojo/services/BUILD.gn +++ b/mojo/services/BUILD.gn @@ -19,7 +19,7 @@ group("services") { if (!is_component_build) { deps += [ - "//components/clipboard", + "//components/core_services", "//components/html_viewer", "//components/kiosk_wm:window_manager", "//components/native_viewport", |