Chromium Code Reviews| 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 MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_CONNECTION_H_ | 5 #ifndef MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_CONNECTION_H_ |
| 6 #define MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_CONNECTION_H_ | 6 #define MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_CONNECTION_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "mojo/application/public/cpp/lib/interface_factory_connector.h" | 10 #include "mojo/application/public/cpp/lib/interface_factory_connector.h" |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 // connection->AddService<Bar>(&my_foo_and_bar_factory_); | 33 // connection->AddService<Bar>(&my_foo_and_bar_factory_); |
| 34 // | 34 // |
| 35 // The InterfaceFactory must outlive the ApplicationConnection. | 35 // The InterfaceFactory must outlive the ApplicationConnection. |
| 36 // | 36 // |
| 37 // Additionally you specify a ServiceConnector. If a ServiceConnector has | 37 // Additionally you specify a ServiceConnector. If a ServiceConnector has |
| 38 // been set and an InterfaceFactory has not been registered for the interface | 38 // been set and an InterfaceFactory has not been registered for the interface |
| 39 // request, than the interface request is sent to the ServiceConnector. | 39 // request, than the interface request is sent to the ServiceConnector. |
| 40 // | 40 // |
| 41 // Just as with InterfaceFactory, ServiceConnector must outlive | 41 // Just as with InterfaceFactory, ServiceConnector must outlive |
| 42 // ApplicationConnection. | 42 // ApplicationConnection. |
| 43 class ApplicationConnection { | 43 class ApplicationConnection { |
|
sky
2015/06/19 19:22:19
I would add a description of lifetime here too.
Fady Samuel
2015/06/26 22:41:19
Done.
| |
| 44 public: | 44 public: |
| 45 virtual ~ApplicationConnection(); | 45 virtual ~ApplicationConnection(); |
| 46 | 46 |
| 47 // Closes the connection. | |
| 48 virtual void CloseConnection() = 0; | |
| 49 | |
| 47 // See class description for details. | 50 // See class description for details. |
| 48 virtual void SetServiceConnector(ServiceConnector* connector) = 0; | 51 virtual void SetServiceConnector(ServiceConnector* connector) = 0; |
| 49 | 52 |
| 50 // Makes Interface available as a service to the remote application. | 53 // Makes Interface available as a service to the remote application. |
| 51 // |factory| will create implementations of Interface on demand. | 54 // |factory| will create implementations of Interface on demand. |
| 52 template <typename Interface> | 55 template <typename Interface> |
| 53 void AddService(InterfaceFactory<Interface>* factory) { | 56 void AddService(InterfaceFactory<Interface>* factory) { |
| 54 SetServiceConnectorForName( | 57 SetServiceConnectorForName( |
| 55 new internal::InterfaceFactoryConnector<Interface>(factory), | 58 new internal::InterfaceFactoryConnector<Interface>(factory), |
| 56 Interface::Name_); | 59 Interface::Name_); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 virtual ServiceProvider* GetServiceProvider() = 0; | 92 virtual ServiceProvider* GetServiceProvider() = 0; |
| 90 | 93 |
| 91 private: | 94 private: |
| 92 virtual void SetServiceConnectorForName(ServiceConnector* service_connector, | 95 virtual void SetServiceConnectorForName(ServiceConnector* service_connector, |
| 93 const std::string& name) = 0; | 96 const std::string& name) = 0; |
| 94 }; | 97 }; |
| 95 | 98 |
| 96 } // namespace mojo | 99 } // namespace mojo |
| 97 | 100 |
| 98 #endif // MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_CONNECTION_H_ | 101 #endif // MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_CONNECTION_H_ |
| OLD | NEW |