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

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

Issue 2850743004: Replace ServiceInfo with BindSourceInfo. (Closed)
Patch Set: . Created 3 years, 7 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 #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 <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 10
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 // 54 //
55 // TODO(rockot): Clean up the connector/connector_request junk. 55 // TODO(rockot): Clean up the connector/connector_request junk.
56 ServiceContext(std::unique_ptr<service_manager::Service> service, 56 ServiceContext(std::unique_ptr<service_manager::Service> service,
57 mojom::ServiceRequest request, 57 mojom::ServiceRequest request,
58 std::unique_ptr<Connector> connector = nullptr, 58 std::unique_ptr<Connector> connector = nullptr,
59 mojom::ConnectorRequest connector_request = nullptr); 59 mojom::ConnectorRequest connector_request = nullptr);
60 60
61 ~ServiceContext() override; 61 ~ServiceContext() override;
62 62
63 Connector* connector() { return connector_.get(); } 63 Connector* connector() { return connector_.get(); }
64 const ServiceInfo& local_info() const { return local_info_; } 64 const Identity& identity() const { return identity_; }
65 const Identity& identity() const { return local_info_.identity; }
66 65
67 // Specify a closure to be run when the Service calls QuitNow(), typically 66 // Specify a closure to be run when the Service calls QuitNow(), typically
68 // in response to Service::OnServiceManagerConnectionLost(). 67 // in response to Service::OnServiceManagerConnectionLost().
69 // 68 //
70 // Note that if the Service has already called QuitNow(), |closure| is run 69 // Note that if the Service has already called QuitNow(), |closure| is run
71 // immediately from this method. 70 // immediately from this method.
72 // 71 //
73 // NOTE: It is acceptable for |closure| to delete this ServiceContext. 72 // NOTE: It is acceptable for |closure| to delete this ServiceContext.
74 void SetQuitClosure(const base::Closure& closure); 73 void SetQuitClosure(const base::Closure& closure);
75 74
(...skipping 26 matching lines...) Expand all
102 // quit closure (see SetQuitClosure() above) if one has been set. 101 // quit closure (see SetQuitClosure() above) if one has been set.
103 // 102 //
104 // See comments on DisconnectFromServiceManager() regarding abrupt 103 // See comments on DisconnectFromServiceManager() regarding abrupt
105 // disconnection from the Service Manager. 104 // disconnection from the Service Manager.
106 void QuitNow(); 105 void QuitNow();
107 106
108 private: 107 private:
109 friend class service_manager::Service; 108 friend class service_manager::Service;
110 109
111 // mojom::Service: 110 // mojom::Service:
112 void OnStart(const ServiceInfo& info, 111 void OnStart(const Identity& info, const OnStartCallback& callback) override;
113 const OnStartCallback& callback) override; 112 void OnBindInterface(const BindSourceInfo& source_info,
114 void OnBindInterface( 113 const std::string& interface_name,
115 const ServiceInfo& source_info, 114 mojo::ScopedMessagePipeHandle interface_pipe,
116 const std::string& interface_name, 115 const OnBindInterfaceCallback& callback) override;
117 mojo::ScopedMessagePipeHandle interface_pipe,
118 const OnBindInterfaceCallback& callback) override;
119 116
120 void OnConnectionError(); 117 void OnConnectionError();
121 118
122 // A pending Connector request which will eventually be passed to the Service 119 // A pending Connector request which will eventually be passed to the Service
123 // Manager. 120 // Manager.
124 mojom::ConnectorRequest pending_connector_request_; 121 mojom::ConnectorRequest pending_connector_request_;
125 122
126 std::unique_ptr<service_manager::Service> service_; 123 std::unique_ptr<service_manager::Service> service_;
127 mojo::Binding<mojom::Service> binding_; 124 mojo::Binding<mojom::Service> binding_;
128 std::unique_ptr<Connector> connector_; 125 std::unique_ptr<Connector> connector_;
129 service_manager::ServiceInfo local_info_; 126 service_manager::Identity identity_;
130 127
131 // This instance's control interface to the service manager. Note that this 128 // This instance's control interface to the service manager. Note that this
132 // is unbound and therefore invalid until OnStart() is called. 129 // is unbound and therefore invalid until OnStart() is called.
133 mojom::ServiceControlAssociatedPtr service_control_; 130 mojom::ServiceControlAssociatedPtr service_control_;
134 131
135 // The Service may call QuitNow() before SetConnectionLostClosure(), and the 132 // The Service may call QuitNow() before SetConnectionLostClosure(), and the
136 // latter is expected to invoke the closure immediately in that case. This is 133 // latter is expected to invoke the closure immediately in that case. This is
137 // used to track that condition. 134 // used to track that condition.
138 // 135 //
139 // TODO(rockot): Figure out who depends on this behavior and make them stop. 136 // TODO(rockot): Figure out who depends on this behavior and make them stop.
140 // It's weird and shouldn't be necessary. 137 // It's weird and shouldn't be necessary.
141 bool service_quit_ = false; 138 bool service_quit_ = false;
142 139
143 // The closure to run when QuitNow() is invoked. May delete |this|. 140 // The closure to run when QuitNow() is invoked. May delete |this|.
144 base::Closure quit_closure_; 141 base::Closure quit_closure_;
145 142
146 base::WeakPtrFactory<ServiceContext> weak_factory_; 143 base::WeakPtrFactory<ServiceContext> weak_factory_;
147 144
148 DISALLOW_COPY_AND_ASSIGN(ServiceContext); 145 DISALLOW_COPY_AND_ASSIGN(ServiceContext);
149 }; 146 };
150 147
151 } // namespace service_manager 148 } // namespace service_manager
152 149
153 #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_SERVICE_CONTEXT_H_ 150 #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_SERVICE_CONTEXT_H_
OLDNEW
« no previous file with comments | « services/service_manager/public/cpp/service.h ('k') | services/service_manager/public/cpp/service_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698