Skip to content

Commit

Permalink
Rename ServiceProvider to InterfaceProvider.
Browse files Browse the repository at this point in the history
TBR=rockot@chromium.org
R=tsepez@chromium.org

BUG=
CQ_INCLUDE_TRYBOTS=tryserver.chromium.linux:linux_site_isolation

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

Cr-Commit-Position: refs/heads/master@{#374620}
  • Loading branch information
ben authored and Commit bot committed Feb 10, 2016
1 parent 9db5ee8 commit 9578795
Show file tree
Hide file tree
Showing 67 changed files with 365 additions and 406 deletions.
2 changes: 1 addition & 1 deletion components/mus/public/cpp/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "components/mus/public/interfaces/window_tree.mojom.h"
#include "mojo/public/cpp/bindings/array.h"
#include "mojo/public/cpp/system/macros.h"
#include "mojo/shell/public/interfaces/service_provider.mojom.h"
#include "mojo/shell/public/interfaces/interface_provider.mojom.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/geometry/rect.h"

Expand Down
2 changes: 1 addition & 1 deletion components/mus/public/cpp/window_tree_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include "components/mus/public/interfaces/window_tree.mojom.h"
#include "mojo/services/network/public/interfaces/url_loader.mojom.h"
#include "mojo/shell/public/interfaces/service_provider.mojom.h"
#include "mojo/shell/public/interfaces/interface_provider.mojom.h"

namespace mus {

Expand Down
2 changes: 1 addition & 1 deletion components/resource_provider/public/cpp/resource_loader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "mojo/common/common_type_converters.h"
#include "mojo/platform_handle/platform_handle_functions.h"
#include "mojo/shell/public/cpp/shell.h"
#include "mojo/shell/public/interfaces/service_provider.mojom.h"
#include "mojo/shell/public/interfaces/interface_provider.mojom.h"
#include "mojo/shell/public/interfaces/shell.mojom.h"

namespace resource_provider {
Expand Down
6 changes: 3 additions & 3 deletions content/browser/frame_host/frame_mojo_shell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ void FrameMojoShell::BindRequest(
// future we may need to support both.
void FrameMojoShell::ConnectToApplication(
mojo::URLRequestPtr application_url,
mojo::InterfaceRequest<mojo::ServiceProvider> services,
mojo::ServiceProviderPtr /* exposed_services */,
mojo::InterfaceRequest<mojo::InterfaceProvider> services,
mojo::InterfaceProviderPtr /* exposed_services */,
mojo::shell::mojom::CapabilityFilterPtr filter,
const ConnectToApplicationCallback& callback) {
mojo::ServiceProviderPtr frame_services;
mojo::InterfaceProviderPtr frame_services;
service_provider_bindings_.AddBinding(GetServiceRegistry(),
GetProxy(&frame_services));

Expand Down
6 changes: 3 additions & 3 deletions content/browser/frame_host/frame_mojo_shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class FrameMojoShell : public mojo::shell::mojom::Shell {
// mojo::Shell:
void ConnectToApplication(
mojo::URLRequestPtr application_url,
mojo::InterfaceRequest<mojo::ServiceProvider> services,
mojo::ServiceProviderPtr exposed_services,
mojo::InterfaceRequest<mojo::InterfaceProvider> services,
mojo::InterfaceProviderPtr exposed_services,
mojo::shell::mojom::CapabilityFilterPtr filter,
const ConnectToApplicationCallback& callback) override;
void QuitApplication() override;
Expand All @@ -44,7 +44,7 @@ class FrameMojoShell : public mojo::shell::mojom::Shell {

// ServiceRegistry providing browser services to connected applications.
scoped_ptr<ServiceRegistryImpl> service_registry_;
mojo::WeakBindingSet<mojo::ServiceProvider> service_provider_bindings_;
mojo::WeakBindingSet<mojo::InterfaceProvider> service_provider_bindings_;

DISALLOW_COPY_AND_ASSIGN(FrameMojoShell);
};
Expand Down
8 changes: 4 additions & 4 deletions content/browser/frame_host/render_frame_host_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2113,12 +2113,12 @@ void RenderFrameHostImpl::SetUpMojoIfNeeded() {
GetProcess()->GetServiceRegistry()->ConnectToRemoteService(
mojo::GetProxy(&setup));

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

mojo::ServiceProviderPtr services;
setup->ExchangeServiceProviders(routing_id_, GetProxy(&services),
std::move(exposed_services));
mojo::InterfaceProviderPtr services;
setup->ExchangeInterfaceProviders(routing_id_, GetProxy(&services),
std::move(exposed_services));
service_registry_->BindRemoteServiceProvider(std::move(services));

#if defined(OS_ANDROID)
Expand Down
5 changes: 3 additions & 2 deletions content/browser/mojo/mojo_app_connection_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ MojoAppConnectionImpl::MojoAppConnectionImpl(const GURL& url,
const GURL& requestor_url) {
MojoShellContext::ConnectToApplication(
url, requestor_url, mojo::GetProxy(&services_),
mojo::ServiceProviderPtr(), mojo::shell::GetPermissiveCapabilityFilter(),
mojo::InterfaceProviderPtr(),
mojo::shell::GetPermissiveCapabilityFilter(),
base::Bind(&OnGotRemoteIDs));
}

Expand All @@ -41,7 +42,7 @@ MojoAppConnectionImpl::~MojoAppConnectionImpl() {
void MojoAppConnectionImpl::ConnectToService(
const std::string& service_name,
mojo::ScopedMessagePipeHandle handle) {
services_->ConnectToService(service_name, std::move(handle));
services_->GetInterface(service_name, std::move(handle));
}

} // namespace content
4 changes: 2 additions & 2 deletions content/browser/mojo/mojo_app_connection_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include "base/macros.h"
#include "content/public/browser/mojo_app_connection.h"
#include "mojo/shell/public/interfaces/service_provider.mojom.h"
#include "mojo/shell/public/interfaces/interface_provider.mojom.h"

class GURL;

Expand All @@ -24,7 +24,7 @@ class MojoAppConnectionImpl : public MojoAppConnection {
void ConnectToService(const std::string& service_name,
mojo::ScopedMessagePipeHandle handle) override;

mojo::ServiceProviderPtr services_;
mojo::InterfaceProviderPtr services_;

DISALLOW_COPY_AND_ASSIGN(MojoAppConnectionImpl);
};
Expand Down
6 changes: 3 additions & 3 deletions content/browser/mojo/mojo_application_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ class ApplicationSetupImpl : public ApplicationSetup {

private:
// ApplicationSetup implementation.
void ExchangeServiceProviders(
mojo::InterfaceRequest<mojo::ServiceProvider> services,
mojo::ServiceProviderPtr exposed_services) override {
void ExchangeInterfaceProviders(
mojo::InterfaceRequest<mojo::InterfaceProvider> services,
mojo::InterfaceProviderPtr exposed_services) override {
service_registry_->Bind(std::move(services));
service_registry_->BindRemoteServiceProvider(std::move(exposed_services));
}
Expand Down
16 changes: 8 additions & 8 deletions content/browser/mojo/mojo_shell_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ class MojoShellContext::Proxy {
void ConnectToApplication(
const GURL& url,
const GURL& requestor_url,
mojo::InterfaceRequest<mojo::ServiceProvider> request,
mojo::ServiceProviderPtr exposed_services,
mojo::InterfaceRequest<mojo::InterfaceProvider> request,
mojo::InterfaceProviderPtr exposed_services,
const mojo::shell::CapabilityFilter& filter,
const mojo::shell::mojom::Shell::ConnectToApplicationCallback& callback) {
if (task_runner_ == base::ThreadTaskRunnerHandle::Get()) {
Expand Down Expand Up @@ -260,8 +260,8 @@ MojoShellContext::~MojoShellContext() {
void MojoShellContext::ConnectToApplication(
const GURL& url,
const GURL& requestor_url,
mojo::InterfaceRequest<mojo::ServiceProvider> request,
mojo::ServiceProviderPtr exposed_services,
mojo::InterfaceRequest<mojo::InterfaceProvider> request,
mojo::InterfaceProviderPtr exposed_services,
const mojo::shell::CapabilityFilter& filter,
const mojo::shell::mojom::Shell::ConnectToApplicationCallback& callback) {
proxy_.Get()->ConnectToApplication(url, requestor_url, std::move(request),
Expand All @@ -272,8 +272,8 @@ void MojoShellContext::ConnectToApplication(
void MojoShellContext::ConnectToApplicationOnOwnThread(
const GURL& url,
const GURL& requestor_url,
mojo::InterfaceRequest<mojo::ServiceProvider> request,
mojo::ServiceProviderPtr exposed_services,
mojo::InterfaceRequest<mojo::InterfaceProvider> request,
mojo::InterfaceProviderPtr exposed_services,
const mojo::shell::CapabilityFilter& filter,
const mojo::shell::mojom::Shell::ConnectToApplicationCallback& callback) {
scoped_ptr<mojo::shell::ConnectToApplicationParams> params(
Expand All @@ -282,8 +282,8 @@ void MojoShellContext::ConnectToApplicationOnOwnThread(
mojo::shell::Identity(requestor_url, std::string(),
mojo::shell::GetPermissiveCapabilityFilter()));
params->SetTarget(mojo::shell::Identity(url, std::string(), filter));
params->set_services(std::move(request));
params->set_exposed_services(std::move(exposed_services));
params->set_remote_interfaces(std::move(request));
params->set_local_interfaces(std::move(exposed_services));
params->set_on_application_end(base::Bind(&base::DoNothing));
params->set_connect_callback(callback);
application_manager_->ConnectToApplication(std::move(params));
Expand Down
8 changes: 4 additions & 4 deletions content/browser/mojo/mojo_shell_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class CONTENT_EXPORT MojoShellContext {
static void ConnectToApplication(
const GURL& url,
const GURL& requestor_url,
mojo::InterfaceRequest<mojo::ServiceProvider> request,
mojo::ServiceProviderPtr exposed_services,
mojo::InterfaceRequest<mojo::InterfaceProvider> request,
mojo::InterfaceProviderPtr exposed_services,
const mojo::shell::CapabilityFilter& filter,
const mojo::shell::mojom::Shell::ConnectToApplicationCallback& callback);

Expand All @@ -55,8 +55,8 @@ class CONTENT_EXPORT MojoShellContext {
void ConnectToApplicationOnOwnThread(
const GURL& url,
const GURL& requestor_url,
mojo::InterfaceRequest<mojo::ServiceProvider> request,
mojo::ServiceProviderPtr exposed_services,
mojo::InterfaceRequest<mojo::InterfaceProvider> request,
mojo::InterfaceProviderPtr exposed_services,
const mojo::shell::CapabilityFilter& filter,
const mojo::shell::mojom::Shell::ConnectToApplicationCallback& callback);

Expand Down
15 changes: 8 additions & 7 deletions content/browser/service_worker/embedded_worker_instance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,17 @@ void RegisterToWorkerDevToolsManagerOnUI(
void SetupMojoOnUIThread(
int process_id,
int thread_id,
mojo::InterfaceRequest<mojo::ServiceProvider> services,
mojo::InterfacePtrInfo<mojo::ServiceProvider> exposed_services) {
mojo::InterfaceRequest<mojo::InterfaceProvider> services,
mojo::InterfacePtrInfo<mojo::InterfaceProvider> exposed_services) {
RenderProcessHost* rph = RenderProcessHost::FromID(process_id);
// |rph| or its ServiceRegistry may be NULL in unit tests.
if (!rph || !rph->GetServiceRegistry())
return;
EmbeddedWorkerSetupPtr setup;
rph->GetServiceRegistry()->ConnectToRemoteService(mojo::GetProxy(&setup));
setup->ExchangeServiceProviders(thread_id, std::move(services),
mojo::MakeProxy(std::move(exposed_services)));
setup->ExchangeInterfaceProviders(
thread_id, std::move(services),
mojo::MakeProxy(std::move(exposed_services)));
}

} // namespace
Expand Down Expand Up @@ -510,10 +511,10 @@ void EmbeddedWorkerInstance::OnThreadStarted(int thread_id) {
thread_id_ = thread_id;
FOR_EACH_OBSERVER(Listener, listener_list_, OnThreadStarted());

mojo::ServiceProviderPtr exposed_services;
mojo::InterfaceProviderPtr exposed_services;
service_registry_->Bind(GetProxy(&exposed_services));
mojo::ServiceProviderPtr services;
mojo::InterfaceRequest<mojo::ServiceProvider> services_request =
mojo::InterfaceProviderPtr services;
mojo::InterfaceRequest<mojo::InterfaceProvider> services_request =
GetProxy(&services);
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
Expand Down
12 changes: 6 additions & 6 deletions content/browser/service_worker/embedded_worker_test_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ class EmbeddedWorkerTestHelper::MockEmbeddedWorkerSetup
new MockEmbeddedWorkerSetup(helper, std::move(request));
}

void ExchangeServiceProviders(
void ExchangeInterfaceProviders(
int32_t thread_id,
mojo::InterfaceRequest<mojo::ServiceProvider> services,
mojo::ServiceProviderPtr exposed_services) override {
mojo::InterfaceRequest<mojo::InterfaceProvider> services,
mojo::InterfaceProviderPtr exposed_services) override {
if (!helper_)
return;
helper_->OnSetupMojoStub(thread_id, std::move(services),
Expand Down Expand Up @@ -100,7 +100,7 @@ EmbeddedWorkerTestHelper::EmbeddedWorkerTestHelper(
new ServiceRegistryImpl);
render_process_service_registry_.ServiceRegistry::AddService(
base::Bind(&MockEmbeddedWorkerSetup::Create, weak_factory_.GetWeakPtr()));
mojo::ServiceProviderPtr services;
mojo::InterfaceProviderPtr services;
render_process_service_registry_.Bind(mojo::GetProxy(&services));
host_service_registry->BindRemoteServiceProvider(std::move(services));
render_process_host_->SetServiceRegistry(std::move(host_service_registry));
Expand Down Expand Up @@ -384,8 +384,8 @@ void EmbeddedWorkerTestHelper::OnPushEventStub(

void EmbeddedWorkerTestHelper::OnSetupMojoStub(
int thread_id,
mojo::InterfaceRequest<mojo::ServiceProvider> services,
mojo::ServiceProviderPtr exposed_services) {
mojo::InterfaceRequest<mojo::InterfaceProvider> services,
mojo::InterfaceProviderPtr exposed_services) {
scoped_ptr<ServiceRegistryImpl> new_registry(new ServiceRegistryImpl);
new_registry->Bind(std::move(services));
new_registry->BindRemoteServiceProvider(std::move(exposed_services));
Expand Down
4 changes: 2 additions & 2 deletions content/browser/service_worker/embedded_worker_test_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ class EmbeddedWorkerTestHelper : public IPC::Sender,
const ServiceWorkerFetchRequest& request);
void OnPushEventStub(int request_id, const PushEventPayload& payload);
void OnSetupMojoStub(int thread_id,
mojo::InterfaceRequest<mojo::ServiceProvider> services,
mojo::ServiceProviderPtr exposed_services);
mojo::InterfaceRequest<mojo::InterfaceProvider> services,
mojo::InterfaceProviderPtr exposed_services);

MessagePortMessageFilter* NewMessagePortMessageFilter();

Expand Down
8 changes: 4 additions & 4 deletions content/child/mojo/mojo_application.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ void MojoApplication::OnActivate(
application_setup.Bind(
mojo::InterfacePtrInfo<ApplicationSetup>(std::move(pipe), 0u));

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

Expand Down
6 changes: 3 additions & 3 deletions content/common/application_setup.mojom
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

module content;

import "mojo/shell/public/interfaces/service_provider.mojom";
import "mojo/shell/public/interfaces/interface_provider.mojom";

interface ApplicationSetup {
ExchangeServiceProviders(mojo.ServiceProvider& services,
mojo.ServiceProvider exposed_services);
ExchangeInterfaceProviders(mojo.InterfaceProvider& remote_interfaces,
mojo.InterfaceProvider local_interfaces);
};
10 changes: 5 additions & 5 deletions content/common/mojo/service_registry_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ ServiceRegistryImpl::~ServiceRegistryImpl() {
}

void ServiceRegistryImpl::Bind(
mojo::InterfaceRequest<mojo::ServiceProvider> request) {
mojo::InterfaceRequest<mojo::InterfaceProvider> request) {
binding_.Bind(std::move(request));
binding_.set_connection_error_handler(base::Bind(
&ServiceRegistryImpl::OnConnectionError, base::Unretained(this)));
}

void ServiceRegistryImpl::BindRemoteServiceProvider(
mojo::ServiceProviderPtr service_provider) {
mojo::InterfaceProviderPtr service_provider) {
CHECK(!remote_provider_);
remote_provider_ = std::move(service_provider);
while (!pending_connects_.empty()) {
remote_provider_->ConnectToService(
remote_provider_->GetInterface(
mojo::String::From(pending_connects_.front().first),
mojo::ScopedMessagePipeHandle(pending_connects_.front().second));
pending_connects_.pop();
Expand Down Expand Up @@ -68,7 +68,7 @@ void ServiceRegistryImpl::ConnectToRemoteService(
std::make_pair(service_name.as_string(), handle.release()));
return;
}
remote_provider_->ConnectToService(
remote_provider_->GetInterface(
mojo::String::From(service_name.as_string()), std::move(handle));
}

Expand All @@ -80,7 +80,7 @@ base::WeakPtr<ServiceRegistry> ServiceRegistryImpl::GetWeakPtr() {
return weak_factory_.GetWeakPtr();
}

void ServiceRegistryImpl::ConnectToService(
void ServiceRegistryImpl::GetInterface(
const mojo::String& name,
mojo::ScopedMessagePipeHandle client_handle) {
auto it = service_factories_.find(name);
Expand Down
18 changes: 9 additions & 9 deletions content/common/mojo/service_registry_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,27 @@
#include "content/public/common/service_registry.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/system/core.h"
#include "mojo/shell/public/interfaces/service_provider.mojom.h"
#include "mojo/shell/public/interfaces/interface_provider.mojom.h"

namespace content {

class CONTENT_EXPORT ServiceRegistryImpl
: public ServiceRegistry,
public NON_EXPORTED_BASE(mojo::ServiceProvider) {
public NON_EXPORTED_BASE(mojo::InterfaceProvider) {
public:
using ServiceFactory = base::Callback<void(mojo::ScopedMessagePipeHandle)>;

ServiceRegistryImpl();
~ServiceRegistryImpl() override;

// Binds this ServiceProvider implementation to a message pipe endpoint.
void Bind(mojo::InterfaceRequest<mojo::ServiceProvider> request);
void Bind(mojo::InterfaceRequest<mojo::InterfaceProvider> 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::ServiceProviderPtr service_provider);
void BindRemoteServiceProvider(mojo::InterfaceProviderPtr service_provider);

// Registers a local service factory to intercept ConnectToRemoteService
// requests instead of actually connecting to the remote registry. Used only
Expand All @@ -56,14 +56,14 @@ class CONTENT_EXPORT ServiceRegistryImpl
base::WeakPtr<ServiceRegistry> GetWeakPtr();

private:
// mojo::ServiceProvider overrides.
void ConnectToService(const mojo::String& name,
mojo::ScopedMessagePipeHandle client_handle) override;
// mojo::InterfaceProvider overrides.
void GetInterface(const mojo::String& name,
mojo::ScopedMessagePipeHandle client_handle) override;

void OnConnectionError();

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

std::map<std::string, ServiceFactory> service_factories_;
std::queue<std::pair<std::string, mojo::MessagePipeHandle> >
Expand Down
Loading

0 comments on commit 9578795

Please sign in to comment.