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 "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 const std::string& url() const { return url_; } | 74 const std::string& url() const { return url_; } |
75 | 75 |
76 AppLifetimeHelper* app_lifetime_helper() { return &app_lifetime_helper_; } | 76 AppLifetimeHelper* app_lifetime_helper() { return &app_lifetime_helper_; } |
77 | 77 |
78 // Requests a new connection to an application. Returns a pointer to the | 78 // Requests a new connection to an application. Returns a pointer to the |
79 // connection if the connection is permitted by this application's delegate, | 79 // connection if the connection is permitted by this application's delegate, |
80 // or nullptr otherwise. Caller does not take ownership. The pointer remains | 80 // or nullptr otherwise. Caller does not take ownership. The pointer remains |
81 // valid until an error occurs on the connection with the Shell, until the | 81 // valid until an error occurs on the connection with the Shell, until the |
82 // ApplicationImpl is destroyed, or until the connection is closed through a | 82 // ApplicationImpl is destroyed, or until the connection is closed through a |
83 // call to ApplicationConnection::CloseConnection. | 83 // call to ApplicationConnection::CloseConnection. |
84 ApplicationConnection* ConnectToApplication(mojo::URLRequestPtr request); | 84 // TODO(beng): consider replacing default value in a separate CL per style |
| 85 // guide. |
| 86 ApplicationConnection* ConnectToApplication( |
| 87 URLRequestPtr request, |
| 88 CapabilityFilterPtr filter = nullptr); |
85 | 89 |
86 // Closes the |connection|. | 90 // Closes the |connection|. |
87 void CloseConnection(ApplicationConnection* connection); | 91 void CloseConnection(ApplicationConnection* connection); |
88 | 92 |
89 // Connect to application identified by |request->url| and connect to the | 93 // Connect to application identified by |request->url| and connect to the |
90 // service implementation of the interface identified by |Interface|. | 94 // service implementation of the interface identified by |Interface|. |
91 template <typename Interface> | 95 template <typename Interface> |
92 void ConnectToService(mojo::URLRequestPtr request, | 96 void ConnectToService(mojo::URLRequestPtr request, |
93 InterfacePtr<Interface>* ptr) { | 97 InterfacePtr<Interface>* ptr) { |
94 ApplicationConnection* connection = ConnectToApplication(request.Pass()); | 98 ApplicationConnection* connection = ConnectToApplication(request.Pass()); |
(...skipping 19 matching lines...) Expand all Loading... |
114 void Terminate(); | 118 void Terminate(); |
115 | 119 |
116 // Quits without waiting to check with the shell. | 120 // Quits without waiting to check with the shell. |
117 void QuitNow(); | 121 void QuitNow(); |
118 | 122 |
119 private: | 123 private: |
120 // Application implementation. | 124 // Application implementation. |
121 void AcceptConnection(const String& requestor_url, | 125 void AcceptConnection(const String& requestor_url, |
122 InterfaceRequest<ServiceProvider> services, | 126 InterfaceRequest<ServiceProvider> services, |
123 ServiceProviderPtr exposed_services, | 127 ServiceProviderPtr exposed_services, |
| 128 Array<String> allowed_interfaces, |
124 const String& url) override; | 129 const String& url) override; |
125 void OnQuitRequested(const Callback<void(bool)>& callback) override; | 130 void OnQuitRequested(const Callback<void(bool)>& callback) override; |
126 | 131 |
127 void OnConnectionError(); | 132 void OnConnectionError(); |
128 | 133 |
129 void ClearConnections(); | 134 void ClearConnections(); |
130 | 135 |
131 typedef std::vector<internal::ServiceRegistry*> ServiceRegistryList; | 136 typedef std::vector<internal::ServiceRegistry*> ServiceRegistryList; |
132 | 137 |
133 ServiceRegistryList incoming_service_registries_; | 138 ServiceRegistryList incoming_service_registries_; |
134 ServiceRegistryList outgoing_service_registries_; | 139 ServiceRegistryList outgoing_service_registries_; |
135 ApplicationDelegate* delegate_; | 140 ApplicationDelegate* delegate_; |
136 Binding<Application> binding_; | 141 Binding<Application> binding_; |
137 ShellPtr shell_; | 142 ShellPtr shell_; |
138 std::string url_; | 143 std::string url_; |
139 base::Closure termination_closure_; | 144 base::Closure termination_closure_; |
140 AppLifetimeHelper app_lifetime_helper_; | 145 AppLifetimeHelper app_lifetime_helper_; |
141 bool quit_requested_; | 146 bool quit_requested_; |
142 bool in_destructor_; | 147 bool in_destructor_; |
143 base::WeakPtrFactory<ApplicationImpl> weak_factory_; | 148 base::WeakPtrFactory<ApplicationImpl> weak_factory_; |
144 | 149 |
145 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationImpl); | 150 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationImpl); |
146 }; | 151 }; |
147 | 152 |
148 } // namespace mojo | 153 } // namespace mojo |
149 | 154 |
150 #endif // MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_IMPL_H_ | 155 #endif // MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_IMPL_H_ |
OLD | NEW |