Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(515)

Unified Diff: services/service_manager/public/cpp/lib/connector_impl.cc

Issue 2610173003: Add RegisterService, split out of Connect(). (Closed)
Patch Set: . Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: services/service_manager/public/cpp/lib/connector_impl.cc
diff --git a/services/service_manager/public/cpp/lib/connector_impl.cc b/services/service_manager/public/cpp/lib/connector_impl.cc
index 9d66a1cfd358d60e924525a7e55bda5d2807b77d..3038e45b299bee8560ce32c98eb6d52a7add463b 100644
--- a/services/service_manager/public/cpp/lib/connector_impl.cc
+++ b/services/service_manager/public/cpp/lib/connector_impl.cc
@@ -10,14 +10,6 @@
namespace service_manager {
-Connector::ConnectParams::ConnectParams(const Identity& target)
- : target_(target) {}
-
-Connector::ConnectParams::ConnectParams(const std::string& name)
- : target_(name, mojom::kInheritUserID) {}
-
-Connector::ConnectParams::~ConnectParams() {}
-
ConnectorImpl::ConnectorImpl(mojom::ConnectorPtrInfo unbound_state)
: unbound_state_(std::move(unbound_state)) {
thread_checker_.DetachFromThread();
@@ -36,51 +28,40 @@ void ConnectorImpl::OnConnectionError() {
connector_.reset();
}
+void ConnectorImpl::RegisterService(
+ const Identity& identity,
+ mojom::ServicePtr service,
+ mojom::PIDReceiverRequest pid_receiver_request) {
+ DCHECK(service.is_bound() && pid_receiver_request.is_pending());
+ mojom::ClientProcessConnectionPtr client_process_connection =
+ mojom::ClientProcessConnection::New();
+ client_process_connection->service = service.PassInterface().PassHandle();
+ client_process_connection->pid_receiver_request =
+ pid_receiver_request.PassMessagePipe();
+ connector_->RegisterService(identity, std::move(client_process_connection));
+}
+
std::unique_ptr<Connection> ConnectorImpl::Connect(const std::string& name) {
- ConnectParams params(name);
- return Connect(&params);
+ return Connect(Identity(name, mojom::kInheritUserID));
}
-std::unique_ptr<Connection> ConnectorImpl::Connect(ConnectParams* params) {
+std::unique_ptr<Connection> ConnectorImpl::Connect(const Identity& target) {
if (!BindIfNecessary())
return nullptr;
DCHECK(thread_checker_.CalledOnValidThread());
- DCHECK(params);
mojom::InterfaceProviderPtr remote_interfaces;
mojom::InterfaceProviderRequest remote_request(&remote_interfaces);
std::unique_ptr<internal::ConnectionImpl> connection(
- new internal::ConnectionImpl(params->target(),
- Connection::State::PENDING));
- if (params->remote_interfaces()) {
- params->remote_interfaces()->Bind(std::move(remote_interfaces));
- connection->set_remote_interfaces(params->remote_interfaces());
- } else {
- std::unique_ptr<InterfaceProvider> remote_interface_provider(
- new InterfaceProvider);
- remote_interface_provider->Bind(std::move(remote_interfaces));
- connection->SetRemoteInterfaces(std::move(remote_interface_provider));
- }
-
- mojom::ServicePtr service;
- mojom::PIDReceiverRequest pid_receiver_request;
- params->TakeClientProcessConnection(&service, &pid_receiver_request);
- mojom::ClientProcessConnectionPtr client_process_connection;
- if (service.is_bound() && pid_receiver_request.is_pending()) {
- client_process_connection = mojom::ClientProcessConnection::New();
- client_process_connection->service =
- service.PassInterface().PassHandle();
- client_process_connection->pid_receiver_request =
- pid_receiver_request.PassMessagePipe();
- } else if (service.is_bound() || pid_receiver_request.is_pending()) {
- NOTREACHED() << "If one of service or pid_receiver_request is valid, "
- << "both must be valid.";
- return std::move(connection);
- }
- connector_->Connect(params->target(), std::move(remote_request),
- std::move(client_process_connection),
- connection->GetConnectCallback());
+ new internal::ConnectionImpl(target, Connection::State::PENDING));
+ std::unique_ptr<InterfaceProvider> remote_interface_provider(
+ new InterfaceProvider);
+ remote_interface_provider->Bind(std::move(remote_interfaces));
+ connection->SetRemoteInterfaces(std::move(remote_interface_provider));
+
+ connector_->Connect(target, std::move(remote_request),
+ nullptr, connection->GetConnectCallback());
return std::move(connection);
}

Powered by Google App Engine
This is Rietveld 408576698