| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_SHELL_PUBLIC_CPP_SHELL_H_ | 5 #ifndef MOJO_SHELL_PUBLIC_CPP_SHELL_H_ |
| 6 #define MOJO_SHELL_PUBLIC_CPP_SHELL_H_ | 6 #define MOJO_SHELL_PUBLIC_CPP_SHELL_H_ |
| 7 | 7 |
| 8 #include "mojo/shell/public/cpp/app_lifetime_helper.h" | 8 #include "mojo/shell/public/cpp/app_lifetime_helper.h" |
| 9 #include "mojo/shell/public/cpp/connection.h" | 9 #include "mojo/shell/public/cpp/connection.h" |
| 10 #include "mojo/shell/public/interfaces/shell.mojom.h" | 10 #include "mojo/shell/public/interfaces/shell.mojom.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 // Requests a new connection to an application. Returns a pointer to the | 42 // Requests a new connection to an application. Returns a pointer to the |
| 43 // connection if the connection is permitted by this application's delegate, | 43 // connection if the connection is permitted by this application's delegate, |
| 44 // or nullptr otherwise. Caller takes ownership. | 44 // or nullptr otherwise. Caller takes ownership. |
| 45 virtual scoped_ptr<Connection> Connect(const std::string& url) = 0; | 45 virtual scoped_ptr<Connection> Connect(const std::string& url) = 0; |
| 46 virtual scoped_ptr<Connection> Connect(ConnectParams* params) = 0; | 46 virtual scoped_ptr<Connection> Connect(ConnectParams* params) = 0; |
| 47 | 47 |
| 48 // Connect to application identified by |request->url| and connect to the | 48 // Connect to application identified by |request->url| and connect to the |
| 49 // service implementation of the interface identified by |Interface|. | 49 // service implementation of the interface identified by |Interface|. |
| 50 template <typename Interface> | 50 template <typename Interface> |
| 51 void ConnectToService(ConnectParams* params, InterfacePtr<Interface>* ptr) { | 51 void ConnectToInterface(ConnectParams* params, InterfacePtr<Interface>* ptr) { |
| 52 scoped_ptr<Connection> connection = Connect(params); | 52 scoped_ptr<Connection> connection = Connect(params); |
| 53 if (connection) | 53 if (connection) |
| 54 connection->GetInterface(ptr); | 54 connection->GetInterface(ptr); |
| 55 } | 55 } |
| 56 template <typename Interface> | 56 template <typename Interface> |
| 57 void ConnectToService(const std::string& url, InterfacePtr<Interface>* ptr) { | 57 void ConnectToInterface(const std::string& url, |
| 58 InterfacePtr<Interface>* ptr) { |
| 58 ConnectParams params(url); | 59 ConnectParams params(url); |
| 59 params.set_filter(CreatePermissiveCapabilityFilter()); | 60 params.set_filter(CreatePermissiveCapabilityFilter()); |
| 60 return ConnectToService(¶ms, ptr); | 61 return ConnectToInterface(¶ms, ptr); |
| 61 } | 62 } |
| 62 | 63 |
| 63 // Initiate shutdown of this application. This may involve a round trip to the | 64 // Initiate shutdown of this application. This may involve a round trip to the |
| 64 // Shell to ensure there are no inbound service requests. | 65 // Shell to ensure there are no inbound service requests. |
| 65 virtual void Quit() = 0; | 66 virtual void Quit() = 0; |
| 66 | 67 |
| 67 // Create an object that can be used to refcount the lifetime of the | 68 // Create an object that can be used to refcount the lifetime of the |
| 68 // application. The returned object may be cloned, and when the refcount falls | 69 // application. The returned object may be cloned, and when the refcount falls |
| 69 // to zero Quit() is called. | 70 // to zero Quit() is called. |
| 70 virtual scoped_ptr<AppRefCount> CreateAppRefCount() = 0; | 71 virtual scoped_ptr<AppRefCount> CreateAppRefCount() = 0; |
| 71 }; | 72 }; |
| 72 | 73 |
| 73 } // namespace mojo | 74 } // namespace mojo |
| 74 | 75 |
| 75 #endif // MOJO_SHELL_PUBLIC_CPP_SHELL_H_ | 76 #endif // MOJO_SHELL_PUBLIC_CPP_SHELL_H_ |
| OLD | NEW |