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, const mojo::String& url) override; |
88 Array<String> args, | |
89 const mojo::String& url) override; | |
90 | 84 |
91 // Block until the Application is initialized, if it is not already. | 85 // Block until the Application is initialized, if it is not already. |
92 void WaitForInitialize(); | 86 void WaitForInitialize(); |
93 | 87 |
94 // Unbinds the Shell and Application connections. Can be used to re-bind the | 88 // Unbinds the Shell and Application connections. Can be used to re-bind the |
95 // handles to another implementation of ApplicationImpl, for instance when | 89 // handles to another implementation of ApplicationImpl, for instance when |
96 // running apptests. | 90 // running apptests. |
97 void UnbindConnections(InterfaceRequest<Application>* application_request, | 91 void UnbindConnections(InterfaceRequest<Application>* application_request, |
98 ShellPtr* shell); | 92 ShellPtr* shell); |
99 | 93 |
(...skipping 23 matching lines...) Expand all Loading... |
123 | 117 |
124 typedef std::vector<internal::ServiceRegistry*> ServiceRegistryList; | 118 typedef std::vector<internal::ServiceRegistry*> ServiceRegistryList; |
125 | 119 |
126 ServiceRegistryList incoming_service_registries_; | 120 ServiceRegistryList incoming_service_registries_; |
127 ServiceRegistryList outgoing_service_registries_; | 121 ServiceRegistryList outgoing_service_registries_; |
128 ApplicationDelegate* delegate_; | 122 ApplicationDelegate* delegate_; |
129 Binding<Application> binding_; | 123 Binding<Application> binding_; |
130 ShellPtr shell_; | 124 ShellPtr shell_; |
131 ShellPtrWatcher* shell_watch_; | 125 ShellPtrWatcher* shell_watch_; |
132 std::string url_; | 126 std::string url_; |
133 std::vector<std::string> args_; | |
134 | 127 |
135 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationImpl); | 128 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationImpl); |
136 }; | 129 }; |
137 | 130 |
138 } // namespace mojo | 131 } // namespace mojo |
139 | 132 |
140 #endif // MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_IMPL_H_ | 133 #endif // MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_IMPL_H_ |
OLD | NEW |