Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: mojo/shell/public/cpp/application_impl.h

Issue 1578473002: Pass application ids via AcceptConnection & ConnectToApplication callback. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_SHELL_PUBLIC_CPP_APPLICATION_IMPL_H_ 5 #ifndef MOJO_SHELL_PUBLIC_CPP_APPLICATION_IMPL_H_
6 #define MOJO_SHELL_PUBLIC_CPP_APPLICATION_IMPL_H_ 6 #define MOJO_SHELL_PUBLIC_CPP_APPLICATION_IMPL_H_
7 7
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 InterfaceRequest<Application> request, 103 InterfaceRequest<Application> request,
104 const Closure& termination_closure); 104 const Closure& termination_closure);
105 ~ApplicationImpl() override; 105 ~ApplicationImpl() override;
106 106
107 // The Mojo shell. This will return a valid pointer after Initialize() has 107 // The Mojo shell. This will return a valid pointer after Initialize() has
108 // been invoked. It will remain valid until UnbindConnections() is invoked or 108 // been invoked. It will remain valid until UnbindConnections() is invoked or
109 // the ApplicationImpl is destroyed. 109 // the ApplicationImpl is destroyed.
110 Shell* shell() const { return shell_.get(); } 110 Shell* shell() const { return shell_.get(); }
111 111
112 const std::string& url() const { return url_; } 112 const std::string& url() const { return url_; }
113 uint32_t id() const { return id_; }
113 114
114 AppLifetimeHelper* app_lifetime_helper() { return &app_lifetime_helper_; } 115 AppLifetimeHelper* app_lifetime_helper() { return &app_lifetime_helper_; }
115 116
116 // Requests a new connection to an application. Returns a pointer to the 117 // Requests a new connection to an application. Returns a pointer to the
117 // connection if the connection is permitted by this application's delegate, 118 // connection if the connection is permitted by this application's delegate,
118 // or nullptr otherwise. Caller takes ownership. 119 // or nullptr otherwise. Caller takes ownership.
119 scoped_ptr<ApplicationConnection> ConnectToApplication( 120 scoped_ptr<ApplicationConnection> ConnectToApplication(
120 const std::string& url); 121 const std::string& url);
121 scoped_ptr<ApplicationConnection> ConnectToApplication(ConnectParams* params); 122 scoped_ptr<ApplicationConnection> ConnectToApplication(ConnectParams* params);
122 123
(...skipping 16 matching lines...) Expand all
139 // Block the calling thread until the Initialize() method is called by the 140 // Block the calling thread until the Initialize() method is called by the
140 // shell. 141 // shell.
141 void WaitForInitialize(); 142 void WaitForInitialize();
142 143
143 // Initiate shutdown of this application. This may involve a round trip to the 144 // Initiate shutdown of this application. This may involve a round trip to the
144 // Shell to ensure there are no inbound service requests. 145 // Shell to ensure there are no inbound service requests.
145 void Quit(); 146 void Quit();
146 147
147 private: 148 private:
148 // Application implementation. 149 // Application implementation.
149 void Initialize(ShellPtr shell, const mojo::String& url) override; 150 void Initialize(ShellPtr shell,
151 const mojo::String& url,
152 uint32_t id) override;
150 void AcceptConnection(const String& requestor_url, 153 void AcceptConnection(const String& requestor_url,
154 uint32_t requestor_id,
151 InterfaceRequest<ServiceProvider> services, 155 InterfaceRequest<ServiceProvider> services,
152 ServiceProviderPtr exposed_services, 156 ServiceProviderPtr exposed_services,
153 Array<String> allowed_interfaces, 157 Array<String> allowed_interfaces,
154 const String& url) override; 158 const String& url) override;
155 void OnQuitRequested(const Callback<void(bool)>& callback) override; 159 void OnQuitRequested(const Callback<void(bool)>& callback) override;
156 160
157 void OnConnectionError(); 161 void OnConnectionError();
158 162
159 // Called from Quit() when there is no Shell connection, or asynchronously 163 // Called from Quit() when there is no Shell connection, or asynchronously
160 // from Quit() once the Shell has OK'ed shutdown. 164 // from Quit() once the Shell has OK'ed shutdown.
161 void QuitNow(); 165 void QuitNow();
162 166
163 // Unbinds the Shell and Application connections. Can be used to re-bind the 167 // Unbinds the Shell and Application connections. Can be used to re-bind the
164 // handles to another implementation of ApplicationImpl, for instance when 168 // handles to another implementation of ApplicationImpl, for instance when
165 // running apptests. 169 // running apptests.
166 void UnbindConnections(InterfaceRequest<Application>* application_request, 170 void UnbindConnections(InterfaceRequest<Application>* application_request,
167 ShellPtr* shell); 171 ShellPtr* shell);
168 172
169 // We track the lifetime of incoming connection registries as it more 173 // We track the lifetime of incoming connection registries as it more
170 // convenient for the client. 174 // convenient for the client.
171 ScopedVector<ApplicationConnection> incoming_connections_; 175 ScopedVector<ApplicationConnection> incoming_connections_;
172 ApplicationDelegate* delegate_; 176 ApplicationDelegate* delegate_;
173 Binding<Application> binding_; 177 Binding<Application> binding_;
174 ShellPtr shell_; 178 ShellPtr shell_;
175 std::string url_; 179 std::string url_;
180 uint32_t id_;
176 Closure termination_closure_; 181 Closure termination_closure_;
177 AppLifetimeHelper app_lifetime_helper_; 182 AppLifetimeHelper app_lifetime_helper_;
178 bool quit_requested_; 183 bool quit_requested_;
179 base::WeakPtrFactory<ApplicationImpl> weak_factory_; 184 base::WeakPtrFactory<ApplicationImpl> weak_factory_;
180 185
181 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationImpl); 186 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationImpl);
182 }; 187 };
183 188
184 } // namespace mojo 189 } // namespace mojo
185 190
186 #endif // MOJO_SHELL_PUBLIC_CPP_APPLICATION_IMPL_H_ 191 #endif // MOJO_SHELL_PUBLIC_CPP_APPLICATION_IMPL_H_
OLDNEW
« no previous file with comments | « mojo/shell/public/cpp/application_connection.h ('k') | mojo/shell/public/cpp/lib/application_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698