| 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 #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  | 
|   11 #include "base/callback.h" |   11 #include "base/callback.h" | 
|   12 #include "base/macros.h" |   12 #include "base/macros.h" | 
|   13 #include "base/memory/weak_ptr.h" |   13 #include "base/memory/weak_ptr.h" | 
|   14 #include "mojo/public/cpp/bindings/binding.h" |   14 #include "mojo/public/cpp/bindings/binding.h" | 
|   15 #include "mojo/public/cpp/system/core.h" |   15 #include "mojo/public/cpp/system/core.h" | 
|   16 #include "services/service_manager/public/cpp/connector.h" |   16 #include "services/service_manager/public/cpp/connector.h" | 
|   17 #include "services/service_manager/public/cpp/service.h" |   17 #include "services/service_manager/public/cpp/service.h" | 
|   18 #include "services/service_manager/public/interfaces/connector.mojom.h" |   18 #include "services/service_manager/public/interfaces/connector.mojom.h" | 
|   19 #include "services/service_manager/public/interfaces/service.mojom.h" |   19 #include "services/service_manager/public/interfaces/service.mojom.h" | 
|   20 #include "services/service_manager/public/interfaces/service_control.mojom.h" |  | 
|   21  |   20  | 
|   22 namespace service_manager { |   21 namespace service_manager { | 
|   23  |   22  | 
|   24 // Encapsulates a connection to the Service Manager in two parts: |   23 // Encapsulates a connection to the Service Manager in two parts: | 
|   25 // - a bound InterfacePtr to mojom::Connector, the primary mechanism |   24 // - a bound InterfacePtr to mojom::Connector, the primary mechanism | 
|   26 //   by which the instantiating service connects to other services, |   25 //   by which the instantiating service connects to other services, | 
|   27 //   brokered by the Service Manager. |   26 //   brokered by the Service Manager. | 
|   28 // - a bound InterfaceRequest of mojom::Service, an interface used by the |   27 // - a bound InterfaceRequest of mojom::Service, an interface used by the | 
|   29 //   Service Manager to inform this service of lifecycle events and |   28 //   Service Manager to inform this service of lifecycle events and | 
|   30 //   inbound connections brokered by it. |   29 //   inbound connections brokered by it. | 
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  103   void DestroyService(); |  102   void DestroyService(); | 
|  104  |  103  | 
|  105  private: |  104  private: | 
|  106   using InterfaceRegistryMap = |  105   using InterfaceRegistryMap = | 
|  107       std::map<InterfaceRegistry*, std::unique_ptr<InterfaceRegistry>>; |  106       std::map<InterfaceRegistry*, std::unique_ptr<InterfaceRegistry>>; | 
|  108  |  107  | 
|  109   // mojom::Service: |  108   // mojom::Service: | 
|  110   void OnStart(const ServiceInfo& info, |  109   void OnStart(const ServiceInfo& info, | 
|  111                const OnStartCallback& callback) override; |  110                const OnStartCallback& callback) override; | 
|  112   void OnConnect(const ServiceInfo& source_info, |  111   void OnConnect(const ServiceInfo& source_info, | 
|  113                  mojom::InterfaceProviderRequest interfaces, |  112                  mojom::InterfaceProviderRequest interfaces) override; | 
|  114                  const OnConnectCallback& callback) override; |  | 
|  115  |  113  | 
|  116   void OnConnectionError(); |  114   void OnConnectionError(); | 
|  117   void OnRegistryConnectionError(InterfaceRegistry* registry); |  115   void OnRegistryConnectionError(InterfaceRegistry* registry); | 
|  118   void DestroyConnectionInterfaceRegistry(InterfaceRegistry* registry); |  116   void DestroyConnectionInterfaceRegistry(InterfaceRegistry* registry); | 
|  119  |  117  | 
|  120   // We track the lifetime of incoming connection registries as a convenience |  118   // We track the lifetime of incoming connection registries as a convenience | 
|  121   // for the client. |  119   // for the client. | 
|  122   InterfaceRegistryMap connection_interface_registries_; |  120   InterfaceRegistryMap connection_interface_registries_; | 
|  123  |  121  | 
|  124   // A pending Connector request which will eventually be passed to the Service |  122   // A pending Connector request which will eventually be passed to the Service | 
|  125   // Manager. |  123   // Manager. | 
|  126   mojom::ConnectorRequest pending_connector_request_; |  124   mojom::ConnectorRequest pending_connector_request_; | 
|  127  |  125  | 
|  128   std::unique_ptr<service_manager::Service> service_; |  126   std::unique_ptr<service_manager::Service> service_; | 
|  129   mojo::Binding<mojom::Service> binding_; |  127   mojo::Binding<mojom::Service> binding_; | 
|  130   std::unique_ptr<Connector> connector_; |  128   std::unique_ptr<Connector> connector_; | 
|  131   service_manager::ServiceInfo local_info_; |  129   service_manager::ServiceInfo local_info_; | 
|  132  |  130  | 
|  133   // This instance's control interface to the service manager. Note that this |  | 
|  134   // is unbound and therefore invalid until OnStart() is called. |  | 
|  135   mojom::ServiceControlAssociatedPtr service_control_; |  | 
|  136  |  | 
|  137   bool service_quit_ = false; |  131   bool service_quit_ = false; | 
|  138  |  132  | 
|  139   base::Closure connection_lost_closure_; |  133   base::Closure connection_lost_closure_; | 
|  140  |  134  | 
|  141   base::WeakPtrFactory<ServiceContext> weak_factory_; |  135   base::WeakPtrFactory<ServiceContext> weak_factory_; | 
|  142  |  136  | 
|  143   DISALLOW_COPY_AND_ASSIGN(ServiceContext); |  137   DISALLOW_COPY_AND_ASSIGN(ServiceContext); | 
|  144 }; |  138 }; | 
|  145  |  139  | 
|  146 }  // namespace service_manager |  140 }  // namespace service_manager | 
|  147  |  141  | 
|  148 #endif  // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_SERVICE_CONTEXT_H_ |  142 #endif  // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_SERVICE_CONTEXT_H_ | 
| OLD | NEW |