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_IMPL_H_ | 5 #ifndef MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_IMPL_H_ |
| 6 #define MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_IMPL_H_ | 6 #define MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_IMPL_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "mojo/application/public/cpp/application_connection.h" | 10 #include "mojo/application/public/cpp/application_connection.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 InterfaceRequest<Application> request); | 57 InterfaceRequest<Application> request); |
| 58 ~ApplicationImpl() override; | 58 ~ApplicationImpl() override; |
| 59 | 59 |
| 60 // The Mojo shell. This will return a valid pointer after Initialize() has | 60 // The Mojo shell. This will return a valid pointer after Initialize() has |
| 61 // been invoked. It will remain valid until UnbindConnections() is invoked or | 61 // been invoked. It will remain valid until UnbindConnections() is invoked or |
| 62 // the ApplicationImpl is destroyed. | 62 // the ApplicationImpl is destroyed. |
| 63 Shell* shell() const { return shell_.get(); } | 63 Shell* shell() const { return shell_.get(); } |
| 64 | 64 |
| 65 const std::string& url() const { return url_; } | 65 const std::string& url() const { return url_; } |
| 66 | 66 |
| 67 // Returns any initial configuration arguments, passed by the Shell. | |
| 68 const std::vector<std::string>& args() const { return args_; } | |
| 69 bool HasArg(const std::string& arg) const; | |
| 70 | |
| 71 // Requests a new connection to an application. Returns a pointer to the | 67 // Requests a new connection to an application. Returns a pointer to the |
| 72 // connection if the connection is permitted by this application's delegate, | 68 // connection if the connection is permitted by this application's delegate, |
| 73 // or nullptr otherwise. Caller does not take ownership. The pointer remains | 69 // or nullptr otherwise. Caller does not take ownership. The pointer remains |
| 74 // valid until an error occurs on the connection with the Shell, or until the | 70 // valid until an error occurs on the connection with the Shell, or until the |
| 75 // ApplicationImpl is destroyed, whichever occurs first. | 71 // ApplicationImpl is destroyed, whichever occurs first. |
| 76 ApplicationConnection* ConnectToApplication(const String& application_url); | 72 ApplicationConnection* ConnectToApplication(const String& application_url); |
| 77 | 73 |
| 78 // Connect to application identified by |application_url| and connect to the | 74 // Connect to application identified by |application_url| and connect to the |
| 79 // service implementation of the interface identified by |Interface|. | 75 // service implementation of the interface identified by |Interface|. |
| 80 template <typename Interface> | 76 template <typename Interface> |
| 81 void ConnectToService(const std::string& application_url, | 77 void ConnectToService(const std::string& application_url, |
| 82 InterfacePtr<Interface>* ptr) { | 78 InterfacePtr<Interface>* ptr) { |
| 83 ConnectToApplication(application_url)->ConnectToService(ptr); | 79 ConnectToApplication(application_url)->ConnectToService(ptr); |
| 84 } | 80 } |
| 85 | 81 |
| 86 // Application implementation. | 82 // Application implementation. |
| 87 void Initialize(ShellPtr shell, | 83 void Initialize(ShellPtr shell, |
| 88 Array<String> args, | |
| 89 const mojo::String& url) override; | 84 const mojo::String& url) override; |
|
msw
2015/05/19 17:45:27
nit: fits on line above.
jam
2015/05/19 20:56:37
Done.
| |
| 90 | 85 |
| 91 // Block until the Application is initialized, if it is not already. | 86 // Block until the Application is initialized, if it is not already. |
| 92 void WaitForInitialize(); | 87 void WaitForInitialize(); |
| 93 | 88 |
| 94 // Unbinds the Shell and Application connections. Can be used to re-bind the | 89 // Unbinds the Shell and Application connections. Can be used to re-bind the |
| 95 // handles to another implementation of ApplicationImpl, for instance when | 90 // handles to another implementation of ApplicationImpl, for instance when |
| 96 // running apptests. | 91 // running apptests. |
| 97 void UnbindConnections(InterfaceRequest<Application>* application_request, | 92 void UnbindConnections(InterfaceRequest<Application>* application_request, |
| 98 ShellPtr* shell); | 93 ShellPtr* shell); |
| 99 | 94 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 123 | 118 |
| 124 typedef std::vector<internal::ServiceRegistry*> ServiceRegistryList; | 119 typedef std::vector<internal::ServiceRegistry*> ServiceRegistryList; |
| 125 | 120 |
| 126 ServiceRegistryList incoming_service_registries_; | 121 ServiceRegistryList incoming_service_registries_; |
| 127 ServiceRegistryList outgoing_service_registries_; | 122 ServiceRegistryList outgoing_service_registries_; |
| 128 ApplicationDelegate* delegate_; | 123 ApplicationDelegate* delegate_; |
| 129 Binding<Application> binding_; | 124 Binding<Application> binding_; |
| 130 ShellPtr shell_; | 125 ShellPtr shell_; |
| 131 ShellPtrWatcher* shell_watch_; | 126 ShellPtrWatcher* shell_watch_; |
| 132 std::string url_; | 127 std::string url_; |
| 133 std::vector<std::string> args_; | |
| 134 | 128 |
| 135 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationImpl); | 129 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationImpl); |
| 136 }; | 130 }; |
| 137 | 131 |
| 138 } // namespace mojo | 132 } // namespace mojo |
| 139 | 133 |
| 140 #endif // MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_IMPL_H_ | 134 #endif // MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_IMPL_H_ |
| OLD | NEW |