OLD | NEW |
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 callback.Run(std::move(pending_connector_request_)); | 58 callback.Run(std::move(pending_connector_request_)); |
59 | 59 |
60 service_->OnStart(identity_); | 60 service_->OnStart(identity_); |
61 } | 61 } |
62 | 62 |
63 void ServiceContext::OnConnect( | 63 void ServiceContext::OnConnect( |
64 const Identity& source, | 64 const Identity& source, |
65 mojom::InterfaceProviderRequest interfaces, | 65 mojom::InterfaceProviderRequest interfaces, |
66 const CapabilityRequest& allowed_capabilities) { | 66 const CapabilityRequest& allowed_capabilities) { |
67 std::unique_ptr<InterfaceRegistry> registry( | 67 std::unique_ptr<InterfaceRegistry> registry( |
68 new InterfaceRegistry(source, allowed_capabilities)); | 68 new InterfaceRegistry(identity_, source, allowed_capabilities)); |
69 registry->Bind(std::move(interfaces)); | 69 registry->Bind(std::move(interfaces)); |
70 | 70 |
71 if (!service_->OnConnect(source, registry.get())) | 71 if (!service_->OnConnect(source, registry.get())) |
72 return; | 72 return; |
73 | 73 |
74 // TODO(beng): it appears we never prune this list. We should, when the | 74 // TODO(beng): it appears we never prune this list. We should, when the |
75 // registry's remote interface provider pipe breaks. | 75 // registry's remote interface provider pipe breaks. |
76 incoming_connections_.push_back(std::move(registry)); | 76 incoming_connections_.push_back(std::move(registry)); |
77 } | 77 } |
78 | 78 |
79 //////////////////////////////////////////////////////////////////////////////// | 79 //////////////////////////////////////////////////////////////////////////////// |
80 // ServiceContext, private: | 80 // ServiceContext, private: |
81 | 81 |
82 void ServiceContext::OnConnectionError() { | 82 void ServiceContext::OnConnectionError() { |
83 // Note that the Service doesn't technically have to quit now, it may live | 83 // Note that the Service doesn't technically have to quit now, it may live |
84 // on to service existing connections. All existing Connectors however are | 84 // on to service existing connections. All existing Connectors however are |
85 // invalid. | 85 // invalid. |
86 should_run_connection_lost_closure_ = service_->OnStop(); | 86 should_run_connection_lost_closure_ = service_->OnStop(); |
87 if (should_run_connection_lost_closure_ && | 87 if (should_run_connection_lost_closure_ && |
88 !connection_lost_closure_.is_null()) | 88 !connection_lost_closure_.is_null()) |
89 connection_lost_closure_.Run(); | 89 connection_lost_closure_.Run(); |
90 // We don't reset the connector as clients may have taken a raw pointer to it. | 90 // We don't reset the connector as clients may have taken a raw pointer to it. |
91 // Connect() will return nullptr if they try to connect to anything. | 91 // Connect() will return nullptr if they try to connect to anything. |
92 } | 92 } |
93 | 93 |
94 } // namespace shell | 94 } // namespace shell |
OLD | NEW |