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

Side by Side Diff: services/shell/public/cpp/lib/service_context.cc

Issue 2209943002: Eliminate outgoing InterfaceProvider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tracing
Patch Set: . Created 4 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "services/shell/public/cpp/service_context.h" 5 #include "services/shell/public/cpp/service_context.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "mojo/public/cpp/bindings/interface_ptr.h" 10 #include "mojo/public/cpp/bindings/interface_ptr.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 DCHECK(binding_.is_bound()); 59 DCHECK(binding_.is_bound());
60 binding_.set_connection_error_handler( 60 binding_.set_connection_error_handler(
61 base::Bind(&ServiceContext::OnConnectionError, base::Unretained(this))); 61 base::Bind(&ServiceContext::OnConnectionError, base::Unretained(this)));
62 62
63 service_->OnStart(identity_); 63 service_->OnStart(identity_);
64 } 64 }
65 65
66 void ServiceContext::OnConnect( 66 void ServiceContext::OnConnect(
67 mojom::IdentityPtr source, 67 mojom::IdentityPtr source,
68 uint32_t source_id, 68 uint32_t source_id,
69 mojom::InterfaceProviderRequest local_interfaces, 69 mojom::InterfaceProviderRequest interfaces,
70 mojom::InterfaceProviderPtr remote_interfaces,
71 mojom::CapabilityRequestPtr allowed_capabilities, 70 mojom::CapabilityRequestPtr allowed_capabilities,
72 const mojo::String& name) { 71 const mojo::String& name) {
73 std::unique_ptr<internal::ConnectionImpl> registry( 72 std::unique_ptr<internal::ConnectionImpl> connection(
74 new internal::ConnectionImpl(name, source.To<Identity>(), source_id, 73 new internal::ConnectionImpl(name, source.To<Identity>(), source_id,
75 allowed_capabilities.To<CapabilityRequest>(), 74 allowed_capabilities.To<CapabilityRequest>(),
76 Connection::State::CONNECTED)); 75 Connection::State::CONNECTED));
77 76
78 std::unique_ptr<InterfaceRegistry> exposed_interfaces( 77 std::unique_ptr<InterfaceRegistry> exposed_interfaces(
79 new InterfaceRegistry(registry.get())); 78 new InterfaceRegistry(connection.get()));
80 exposed_interfaces->Bind(std::move(local_interfaces)); 79 exposed_interfaces->Bind(std::move(interfaces));
81 registry->SetExposedInterfaces(std::move(exposed_interfaces)); 80 connection->SetExposedInterfaces(std::move(exposed_interfaces));
82 81
83 std::unique_ptr<InterfaceProvider> interfaces(new InterfaceProvider); 82 if (!service_->OnConnect(connection.get()))
84 interfaces->Bind(std::move(remote_interfaces));
85 registry->SetRemoteInterfaces(std::move(interfaces));
86
87 if (!service_->OnConnect(registry.get()))
88 return; 83 return;
89 84
90 // TODO(beng): it appears we never prune this list. We should, when the 85 // TODO(beng): it appears we never prune this list. We should, when the
91 // connection's remote service provider pipe breaks. 86 // connection's remote service provider pipe breaks.
92 incoming_connections_.push_back(std::move(registry)); 87 incoming_connections_.push_back(std::move(connection));
93 } 88 }
94 89
95 //////////////////////////////////////////////////////////////////////////////// 90 ////////////////////////////////////////////////////////////////////////////////
96 // ServiceContext, private: 91 // ServiceContext, private:
97 92
98 void ServiceContext::OnConnectionError() { 93 void ServiceContext::OnConnectionError() {
99 // Note that the Service doesn't technically have to quit now, it may live 94 // Note that the Service doesn't technically have to quit now, it may live
100 // on to service existing connections. All existing Connectors however are 95 // on to service existing connections. All existing Connectors however are
101 // invalid. 96 // invalid.
102 should_run_connection_lost_closure_ = service_->OnStop(); 97 should_run_connection_lost_closure_ = service_->OnStop();
103 if (should_run_connection_lost_closure_ && 98 if (should_run_connection_lost_closure_ &&
104 !connection_lost_closure_.is_null()) 99 !connection_lost_closure_.is_null())
105 connection_lost_closure_.Run(); 100 connection_lost_closure_.Run();
106 // We don't reset the connector as clients may have taken a raw pointer to it. 101 // We don't reset the connector as clients may have taken a raw pointer to it.
107 // Connect() will return nullptr if they try to connect to anything. 102 // Connect() will return nullptr if they try to connect to anything.
108 } 103 }
109 104
110 } // namespace shell 105 } // namespace shell
OLDNEW
« no previous file with comments | « services/shell/public/cpp/lib/interface_registry.cc ('k') | services/shell/public/cpp/service_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698