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

Side by Side Diff: services/service_manager/public/cpp/service_context.h

Issue 2446313003: Revise InterfaceRegistry API to support filtering interfaces @ Bind() time. (Closed)
Patch Set: . Created 4 years, 1 month 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 #ifndef SERVICES_SERVICE_MANAGER_PUBLIC_CPP_SERVICE_CONTEXT_H_ 5 #ifndef SERVICES_SERVICE_MANAGER_PUBLIC_CPP_SERVICE_CONTEXT_H_
6 #define SERVICES_SERVICE_MANAGER_PUBLIC_CPP_SERVICE_CONTEXT_H_ 6 #define SERVICES_SERVICE_MANAGER_PUBLIC_CPP_SERVICE_CONTEXT_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 // both must be non-null. If both are null, the connection will create its own 49 // both must be non-null. If both are null, the connection will create its own
50 // Connector and request to pass to the Service Manager on initialization. 50 // Connector and request to pass to the Service Manager on initialization.
51 ServiceContext(service_manager::Service* service, 51 ServiceContext(service_manager::Service* service,
52 mojom::ServiceRequest request, 52 mojom::ServiceRequest request,
53 std::unique_ptr<Connector> connector = nullptr, 53 std::unique_ptr<Connector> connector = nullptr,
54 mojom::ConnectorRequest connector_request = nullptr); 54 mojom::ConnectorRequest connector_request = nullptr);
55 55
56 ~ServiceContext() override; 56 ~ServiceContext() override;
57 57
58 Connector* connector() { return connector_.get(); } 58 Connector* connector() { return connector_.get(); }
59 const Identity& identity() { return identity_; } 59 const Identity& identity() { return local_info_.identity; }
60 60
61 // Specify a function to be called when the connection to the service manager 61 // Specify a function to be called when the connection to the service manager
62 // is lost. 62 // is lost.
63 // Note that if connection has already been lost, then |closure| is called 63 // Note that if connection has already been lost, then |closure| is called
64 // immediately. 64 // immediately.
65 void SetConnectionLostClosure(const base::Closure& closure); 65 void SetConnectionLostClosure(const base::Closure& closure);
66 66
67 private: 67 private:
68 // mojom::Service: 68 // mojom::Service:
69 void OnStart(const ServiceInfo& info, 69 void OnStart(const ServiceInfo& info,
70 const OnStartCallback& callback) override; 70 const OnStartCallback& callback) override;
71 void OnConnect(const ServiceInfo& source_info, 71 void OnConnect(const ServiceInfo& source_info,
72 mojom::InterfaceProviderRequest interfaces, 72 mojom::InterfaceProviderRequest interfaces) override;
73 const InterfaceSet& allowed_interfaces,
74 const CapabilitySet& allowed_capabilities) override;
75 73
76 void OnConnectionError(); 74 void OnConnectionError();
77 75
78 // A callback called when OnStart() is run. 76 // A callback called when OnStart() is run.
79 base::Closure initialize_handler_; 77 base::Closure initialize_handler_;
80 78
81 // We track the lifetime of incoming connection registries as it more 79 // We track the lifetime of incoming connection registries as it more
82 // convenient for the client. 80 // convenient for the client.
83 std::vector<std::unique_ptr<InterfaceRegistry>> incoming_connections_; 81 std::vector<std::unique_ptr<InterfaceRegistry>> incoming_connections_;
84 82
85 // A pending Connector request which will eventually be passed to the Service 83 // A pending Connector request which will eventually be passed to the Service
86 // Manager. 84 // Manager.
87 mojom::ConnectorRequest pending_connector_request_; 85 mojom::ConnectorRequest pending_connector_request_;
88 86
89 service_manager::Service* service_; 87 service_manager::Service* service_;
90 mojo::Binding<mojom::Service> binding_; 88 mojo::Binding<mojom::Service> binding_;
91 std::unique_ptr<Connector> connector_; 89 std::unique_ptr<Connector> connector_;
92 service_manager::Identity identity_; 90 service_manager::ServiceInfo local_info_;
93 bool should_run_connection_lost_closure_ = false; 91 bool should_run_connection_lost_closure_ = false;
94 92
95 base::Closure connection_lost_closure_; 93 base::Closure connection_lost_closure_;
96 94
97 DISALLOW_COPY_AND_ASSIGN(ServiceContext); 95 DISALLOW_COPY_AND_ASSIGN(ServiceContext);
98 }; 96 };
99 97
100 } // namespace service_manager 98 } // namespace service_manager
101 99
102 #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_SERVICE_CONTEXT_H_ 100 #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_SERVICE_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698