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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // 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 |
68 // connection if the connection is permitted by this application's delegate, | 68 // connection if the connection is permitted by this application's delegate, |
69 // or nullptr otherwise. Caller does not take ownership. The pointer remains | 69 // or nullptr otherwise. Caller does not take ownership. The pointer remains |
70 // 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 |
71 // ApplicationImpl is destroyed, whichever occurs first. | 71 // ApplicationImpl is destroyed, whichever occurs first. |
72 ApplicationConnection* ConnectToApplication(const String& application_url); | 72 ApplicationConnection* ConnectToApplication(mojo::URLRequestPtr request); |
73 | 73 |
74 // Connect to application identified by |application_url| and connect to the | 74 // Connect to application identified by |request->url| and connect to the |
75 // service implementation of the interface identified by |Interface|. | 75 // service implementation of the interface identified by |Interface|. |
76 template <typename Interface> | 76 template <typename Interface> |
77 void ConnectToService(const std::string& application_url, | 77 void ConnectToService(mojo::URLRequestPtr request, |
78 InterfacePtr<Interface>* ptr) { | 78 InterfacePtr<Interface>* ptr) { |
79 ConnectToApplication(application_url)->ConnectToService(ptr); | 79 ConnectToApplication(request.Pass())->ConnectToService(ptr); |
80 } | 80 } |
81 | 81 |
82 // Application implementation. | 82 // Application implementation. |
83 void Initialize(ShellPtr shell, const mojo::String& url) override; | 83 void Initialize(ShellPtr shell, const mojo::String& url) override; |
84 | 84 |
85 // Block until the Application is initialized, if it is not already. | 85 // Block until the Application is initialized, if it is not already. |
86 void WaitForInitialize(); | 86 void WaitForInitialize(); |
87 | 87 |
88 // 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 |
89 // handles to another implementation of ApplicationImpl, for instance when | 89 // handles to another implementation of ApplicationImpl, for instance when |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 ShellPtr shell_; | 124 ShellPtr shell_; |
125 ShellPtrWatcher* shell_watch_; | 125 ShellPtrWatcher* shell_watch_; |
126 std::string url_; | 126 std::string url_; |
127 | 127 |
128 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationImpl); | 128 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationImpl); |
129 }; | 129 }; |
130 | 130 |
131 } // namespace mojo | 131 } // namespace mojo |
132 | 132 |
133 #endif // MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_IMPL_H_ | 133 #endif // MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_IMPL_H_ |
OLD | NEW |