Skip to content

Commit

Permalink
Update mojo sdk to rev a85a2cea82d816de115e15253742b0f88a9924eb
Browse files Browse the repository at this point in the history
BUG=None
TBR=aa@chromium.org for html_viewer
TBR=darin@chromium.org

Review URL: https://codereview.chromium.org/866263004

Cr-Commit-Position: refs/heads/master@{#313314}
  • Loading branch information
krockot authored and Commit bot committed Jan 27, 2015
1 parent da4f04d commit 775ce0d
Show file tree
Hide file tree
Showing 67 changed files with 784 additions and 398 deletions.
13 changes: 8 additions & 5 deletions content/browser/frame_host/render_frame_host_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1545,11 +1545,14 @@ void RenderFrameHostImpl::SetUpMojoIfNeeded() {
RegisterMojoServices();
RenderFrameSetupPtr setup;
GetProcess()->GetServiceRegistry()->ConnectToRemoteService(&setup);
mojo::ServiceProviderPtr service_provider;
setup->GetServiceProviderForFrame(routing_id_,
mojo::GetProxy(&service_provider));
service_registry_->BindRemoteServiceProvider(
service_provider.PassMessagePipe());

mojo::ServiceProviderPtr exposed_services;
service_registry_->Bind(GetProxy(&exposed_services));

mojo::ServiceProviderPtr services;
setup->ExchangeServiceProviders(routing_id_, GetProxy(&services),
exposed_services.Pass());
service_registry_->BindRemoteServiceProvider(services.Pass());

#if defined(OS_ANDROID)
service_registry_android_.reset(
Expand Down
31 changes: 29 additions & 2 deletions content/browser/mojo/mojo_application_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,34 @@ base::PlatformFile PlatformFileFromScopedPlatformHandle(
#endif
}

class ApplicationSetupImpl : public ApplicationSetup {
public:
ApplicationSetupImpl(ServiceRegistryImpl* service_registry,
mojo::InterfaceRequest<ApplicationSetup> request)
: binding_(this, request.Pass()),
service_registry_(service_registry) {
}

~ApplicationSetupImpl() override {
}

private:
// ApplicationSetup implementation.
void ExchangeServiceProviders(
mojo::InterfaceRequest<mojo::ServiceProvider> services,
mojo::ServiceProviderPtr exposed_services) override {
service_registry_->Bind(services.Pass());
service_registry_->BindRemoteServiceProvider(exposed_services.Pass());
}

mojo::Binding<ApplicationSetup> binding_;
ServiceRegistryImpl* service_registry_;
};

} // namespace

MojoApplicationHost::MojoApplicationHost() : did_activate_(false) {
MojoApplicationHost::MojoApplicationHost()
: did_activate_(false) {
#if defined(OS_ANDROID)
service_registry_android_.reset(
new ServiceRegistryAndroid(&service_registry_));
Expand All @@ -47,7 +72,9 @@ bool MojoApplicationHost::Init() {
// Forward this to the client once we know its process handle.
client_handle_ = channel_pair.PassClientHandle();

service_registry_.BindRemoteServiceProvider(message_pipe.Pass());
application_setup_.reset(new ApplicationSetupImpl(
&service_registry_,
mojo::MakeRequest<ApplicationSetup>(message_pipe.Pass())));
return true;
}

Expand Down
4 changes: 3 additions & 1 deletion content/browser/mojo/mojo_application_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "base/memory/scoped_ptr.h"
#include "base/process/process_handle.h"
#include "content/common/application_setup.mojom.h"
#include "content/common/mojo/service_registry_impl.h"
#include "third_party/mojo/src/mojo/edk/embedder/channel_init.h"
#include "third_party/mojo/src/mojo/edk/embedder/scoped_platform_handle.h"
Expand All @@ -29,7 +30,7 @@ namespace content {
class CONTENT_EXPORT MojoApplicationHost {
public:
MojoApplicationHost();
virtual ~MojoApplicationHost();
~MojoApplicationHost();

// Two-phase initialization:
// 1- Init makes service_registry() available synchronously.
Expand All @@ -53,6 +54,7 @@ class CONTENT_EXPORT MojoApplicationHost {

bool did_activate_;

scoped_ptr<ApplicationSetup> application_setup_;
ServiceRegistryImpl service_registry_;

#if defined(OS_ANDROID)
Expand Down
1 change: 1 addition & 0 deletions content/child/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ source_set("child") {
deps = [
"//base",
"//components/tracing",
"//content/common:mojo_bindings",
"//mojo/common",
"//mojo/environment:chromium",
"//skia",
Expand Down
13 changes: 12 additions & 1 deletion content/child/mojo/mojo_application.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
#include "content/child/mojo/mojo_application.h"

#include "content/child/child_process.h"
#include "content/common/application_setup.mojom.h"
#include "content/common/mojo/mojo_messages.h"
#include "ipc/ipc_message.h"
#include "third_party/mojo/src/mojo/public/cpp/bindings/interface_ptr.h"

namespace content {

Expand Down Expand Up @@ -36,7 +38,16 @@ void MojoApplication::OnActivate(
channel_init_.Init(handle,
ChildProcess::current()->io_message_loop_proxy());
DCHECK(message_pipe.is_valid());
service_registry_.BindRemoteServiceProvider(message_pipe.Pass());

ApplicationSetupPtr application_setup;
application_setup.Bind(message_pipe.Pass());

mojo::ServiceProviderPtr services;
mojo::ServiceProviderPtr exposed_services;
service_registry_.Bind(GetProxy(&exposed_services));
application_setup->ExchangeServiceProviders(GetProxy(&services),
exposed_services.Pass());
service_registry_.BindRemoteServiceProvider(services.Pass());
}

} // namespace content
1 change: 1 addition & 0 deletions content/common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ source_set("common") {

mojom("mojo_bindings") {
sources = [
"application_setup.mojom",
"geolocation_service.mojom",
"permission_service.mojom",
"render_frame_setup.mojom",
Expand Down
12 changes: 12 additions & 0 deletions content/common/application_setup.mojom
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// 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.

module content;

import "third_party/mojo/src/mojo/public/interfaces/application/service_provider.mojom";

interface ApplicationSetup {
ExchangeServiceProviders(mojo.ServiceProvider& services,
mojo.ServiceProvider exposed_services);
};
30 changes: 13 additions & 17 deletions content/common/mojo/service_registry_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@
namespace content {

ServiceRegistryImpl::ServiceRegistryImpl()
: bound_(false), weak_factory_(this) {
}

ServiceRegistryImpl::ServiceRegistryImpl(mojo::ScopedMessagePipeHandle handle)
: bound_(false), weak_factory_(this) {
BindRemoteServiceProvider(handle.Pass());
: binding_(this), weak_factory_(this) {
}

ServiceRegistryImpl::~ServiceRegistryImpl() {
Expand All @@ -24,23 +19,23 @@ ServiceRegistryImpl::~ServiceRegistryImpl() {
}
}

void ServiceRegistryImpl::Bind(
mojo::InterfaceRequest<mojo::ServiceProvider> request) {
binding_.Bind(request.Pass());
}

void ServiceRegistryImpl::BindRemoteServiceProvider(
mojo::ScopedMessagePipeHandle handle) {
CHECK(!bound_);
bound_ = true;
mojo::WeakBindToPipe(this, handle.Pass());
mojo::ServiceProviderPtr service_provider) {
CHECK(!remote_provider_);
remote_provider_ = service_provider.Pass();
while (!pending_connects_.empty()) {
client()->ConnectToService(
remote_provider_->ConnectToService(
mojo::String::From(pending_connects_.front().first),
mojo::ScopedMessagePipeHandle(pending_connects_.front().second));
pending_connects_.pop();
}
}

void ServiceRegistryImpl::OnConnectionError() {
// TODO(sammc): Support reporting this to our owner.
}

void ServiceRegistryImpl::AddService(
const std::string& service_name,
const base::Callback<void(mojo::ScopedMessagePipeHandle)> service_factory) {
Expand All @@ -54,12 +49,13 @@ void ServiceRegistryImpl::RemoveService(const std::string& service_name) {
void ServiceRegistryImpl::ConnectToRemoteService(
const base::StringPiece& service_name,
mojo::ScopedMessagePipeHandle handle) {
if (!bound_) {
if (!remote_provider_) {
pending_connects_.push(
std::make_pair(service_name.as_string(), handle.release()));
return;
}
client()->ConnectToService(mojo::String::From(service_name), handle.Pass());
remote_provider_->ConnectToService(mojo::String::From(service_name),
handle.Pass());
}

base::WeakPtr<ServiceRegistry> ServiceRegistryImpl::GetWeakPtr() {
Expand Down
17 changes: 10 additions & 7 deletions content/common/mojo/service_registry_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,27 @@
#include "base/compiler_specific.h"
#include "base/memory/weak_ptr.h"
#include "content/public/common/service_registry.h"
#include "third_party/mojo/src/mojo/public/cpp/bindings/interface_impl.h"
#include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h"
#include "third_party/mojo/src/mojo/public/cpp/system/core.h"
#include "third_party/mojo/src/mojo/public/interfaces/application/service_provider.mojom.h"

namespace content {

class CONTENT_EXPORT ServiceRegistryImpl
: public ServiceRegistry,
public NON_EXPORTED_BASE(mojo::InterfaceImpl<mojo::ServiceProvider>) {
public NON_EXPORTED_BASE(mojo::ServiceProvider) {
public:
ServiceRegistryImpl();
explicit ServiceRegistryImpl(mojo::ScopedMessagePipeHandle handle);
~ServiceRegistryImpl() override;

// Binds this ServiceProvider implementation to a message pipe endpoint.
void Bind(mojo::InterfaceRequest<mojo::ServiceProvider> request);

// Binds to a remote ServiceProvider. This will expose added services to the
// remote ServiceProvider with the corresponding handle and enable
// ConnectToRemoteService to provide access to services exposed by the remote
// ServiceProvider.
void BindRemoteServiceProvider(mojo::ScopedMessagePipeHandle handle);
void BindRemoteServiceProvider(mojo::ServiceProviderPtr service_provider);

// ServiceRegistry overrides.
void AddService(const std::string& service_name,
Expand All @@ -45,16 +47,17 @@ class CONTENT_EXPORT ServiceRegistryImpl
base::WeakPtr<ServiceRegistry> GetWeakPtr();

private:
// mojo::InterfaceImpl<mojo::ServiceProvider> overrides.
// mojo::ServiceProvider overrides.
void ConnectToService(const mojo::String& name,
mojo::ScopedMessagePipeHandle client_handle) override;
void OnConnectionError() override;

mojo::Binding<mojo::ServiceProvider> binding_;
mojo::ServiceProviderPtr remote_provider_;

std::map<std::string, base::Callback<void(mojo::ScopedMessagePipeHandle)> >
service_factories_;
std::queue<std::pair<std::string, mojo::MessagePipeHandle> >
pending_connects_;
bool bound_;

base::WeakPtrFactory<ServiceRegistry> weak_factory_;
};
Expand Down
5 changes: 3 additions & 2 deletions content/common/render_frame_setup.mojom
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module content;
import "third_party/mojo/src/mojo/public/interfaces/application/service_provider.mojom";

interface RenderFrameSetup {
GetServiceProviderForFrame(int32 frame_routing_id,
mojo.ServiceProvider& service_provider);
ExchangeServiceProviders(int32 frame_routing_id,
mojo.ServiceProvider& services,
mojo.ServiceProvider exposed_services);
};
1 change: 1 addition & 0 deletions content/content_common_mojo_bindings.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
'variables': {
'mojom_files': [
# NOTE: Sources duplicated in //content/common/BUILD.gn:mojo_bindings.
'common/application_setup.mojom',
'common/geolocation_service.mojom',
'common/permission_service.mojom',
'common/render_frame_setup.mojom',
Expand Down
6 changes: 4 additions & 2 deletions content/renderer/render_frame_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1177,8 +1177,10 @@ void RenderFrameImpl::NavigateToSwappedOutURL() {
}

void RenderFrameImpl::BindServiceRegistry(
mojo::ScopedMessagePipeHandle service_provider_handle) {
service_registry_.BindRemoteServiceProvider(service_provider_handle.Pass());
mojo::InterfaceRequest<mojo::ServiceProvider> services,
mojo::ServiceProviderPtr exposed_services) {
service_registry_.Bind(services.Pass());
service_registry_.BindRemoteServiceProvider(exposed_services.Pass());
}

ManifestManager* RenderFrameImpl::manifest_manager() {
Expand Down
6 changes: 3 additions & 3 deletions content/renderer/render_frame_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -534,10 +534,10 @@ class CONTENT_EXPORT RenderFrameImpl
// TODO(nasko): Remove this method once swapped out state is no longer used.
void NavigateToSwappedOutURL();

// Binds this render frame's service registry to a handle to the remote
// service registry.
// Binds this render frame's service registry.
void BindServiceRegistry(
mojo::ScopedMessagePipeHandle service_provider_handle);
mojo::InterfaceRequest<mojo::ServiceProvider> services,
mojo::ServiceProviderPtr exposed_services);

ManifestManager* manifest_manager();

Expand Down
Loading

0 comments on commit 775ce0d

Please sign in to comment.