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 | 74 |
75 const std::string& url() const { return url_; } | 75 const std::string& url() const { return url_; } |
76 | 76 |
77 AppLifetimeHelper* app_lifetime_helper() { return &app_lifetime_helper_; } | 77 AppLifetimeHelper* app_lifetime_helper() { return &app_lifetime_helper_; } |
78 | 78 |
79 // Requests a new connection to an application. Returns a pointer to the | 79 // Requests a new connection to an application. Returns a pointer to the |
80 // connection if the connection is permitted by this application's delegate, | 80 // connection if the connection is permitted by this application's delegate, |
81 // or nullptr otherwise. Caller does not take ownership. The pointer remains | 81 // or nullptr otherwise. Caller does not take ownership. The pointer remains |
82 // valid until an error occurs on the connection with the Shell, until the | 82 // valid until an error occurs on the connection with the Shell, until the |
83 // ApplicationImpl is destroyed, or until the connection is closed through a | 83 // ApplicationImpl is destroyed, or until the connection is closed through a |
84 // call to ApplicationConnection::CloseConnection. | 84 // call to ApplicationConnection::CloseConnection. If |terminate_cb| is |
| 85 // provided, it will be fired when the application is terminated. |
85 ApplicationConnection* ConnectToApplication(mojo::URLRequestPtr request); | 86 ApplicationConnection* ConnectToApplication(mojo::URLRequestPtr request); |
| 87 ApplicationConnection* ConnectToApplication( |
| 88 mojo::URLRequestPtr request, |
| 89 const base::Closure& terminate_cb); |
86 | 90 |
87 // Closes the |connection|. | 91 // Closes the |connection|. |
88 void CloseConnection(ApplicationConnection* connection); | 92 void CloseConnection(ApplicationConnection* connection); |
89 | 93 |
90 // Connect to application identified by |request->url| and connect to the | 94 // Connect to application identified by |request->url| and connect to the |
91 // service implementation of the interface identified by |Interface|. | 95 // service implementation of the interface identified by |Interface|. |
92 template <typename Interface> | 96 template <typename Interface> |
93 void ConnectToService(mojo::URLRequestPtr request, | 97 void ConnectToService(mojo::URLRequestPtr request, |
94 InterfacePtr<Interface>* ptr) { | 98 InterfacePtr<Interface>* ptr) { |
95 ApplicationConnection* connection = ConnectToApplication(request.Pass()); | 99 ApplicationConnection* connection = ConnectToApplication(request.Pass()); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 bool quit_requested_; | 147 bool quit_requested_; |
144 bool in_destructor_; | 148 bool in_destructor_; |
145 base::WeakPtrFactory<ApplicationImpl> weak_factory_; | 149 base::WeakPtrFactory<ApplicationImpl> weak_factory_; |
146 | 150 |
147 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationImpl); | 151 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationImpl); |
148 }; | 152 }; |
149 | 153 |
150 } // namespace mojo | 154 } // namespace mojo |
151 | 155 |
152 #endif // MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_IMPL_H_ | 156 #endif // MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_IMPL_H_ |
OLD | NEW |