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

Side by Side Diff: content/browser/mojo/mojo_shell_context.cc

Issue 1737933002: mojo leveldb: Get profile and leveldb connected to DOMStorageContext. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ben comments Created 4 years, 9 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include "content/browser/mojo/mojo_shell_context.h" 5 #include "content/browser/mojo/mojo_shell_context.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h"
9 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "base/path_service.h" 12 #include "base/path_service.h"
12 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
13 #include "base/thread_task_runner_handle.h" 14 #include "base/thread_task_runner_handle.h"
14 #include "components/profile_service/profile_app.h" 15 #include "components/profile_service/profile_app.h"
15 #include "content/browser/gpu/gpu_process_host.h" 16 #include "content/browser/gpu/gpu_process_host.h"
16 #include "content/common/gpu/gpu_process_launch_causes.h" 17 #include "content/common/gpu/gpu_process_launch_causes.h"
17 #include "content/common/mojo/mojo_shell_connection_impl.h" 18 #include "content/common/mojo/mojo_shell_connection_impl.h"
18 #include "content/common/mojo/static_loader.h" 19 #include "content/common/mojo/static_loader.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 // Thread-safe proxy providing access to the shell context from any thread. 154 // Thread-safe proxy providing access to the shell context from any thread.
154 class MojoShellContext::Proxy { 155 class MojoShellContext::Proxy {
155 public: 156 public:
156 Proxy(MojoShellContext* shell_context) 157 Proxy(MojoShellContext* shell_context)
157 : shell_context_(shell_context), 158 : shell_context_(shell_context),
158 task_runner_(base::ThreadTaskRunnerHandle::Get()) {} 159 task_runner_(base::ThreadTaskRunnerHandle::Get()) {}
159 160
160 ~Proxy() {} 161 ~Proxy() {}
161 162
162 void ConnectToApplication( 163 void ConnectToApplication(
164 const std::string& user_id,
163 const std::string& name, 165 const std::string& name,
164 const std::string& requestor_name, 166 const std::string& requestor_name,
165 mojo::shell::mojom::InterfaceProviderRequest request, 167 mojo::shell::mojom::InterfaceProviderRequest request,
166 mojo::shell::mojom::InterfaceProviderPtr exposed_services, 168 mojo::shell::mojom::InterfaceProviderPtr exposed_services,
167 const mojo::shell::mojom::Connector::ConnectCallback& callback) { 169 const mojo::shell::mojom::Connector::ConnectCallback& callback) {
168 if (task_runner_ == base::ThreadTaskRunnerHandle::Get()) { 170 if (task_runner_ == base::ThreadTaskRunnerHandle::Get()) {
169 if (shell_context_) { 171 if (shell_context_) {
170 shell_context_->ConnectToApplicationOnOwnThread( 172 shell_context_->ConnectToApplicationOnOwnThread(
171 name, requestor_name, std::move(request), 173 user_id, name, requestor_name, std::move(request),
172 std::move(exposed_services), callback); 174 std::move(exposed_services), callback);
173 } 175 }
174 } else { 176 } else {
175 // |shell_context_| outlives the main MessageLoop, so it's safe for it to 177 // |shell_context_| outlives the main MessageLoop, so it's safe for it to
176 // be unretained here. 178 // be unretained here.
177 task_runner_->PostTask( 179 task_runner_->PostTask(
178 FROM_HERE, 180 FROM_HERE,
179 base::Bind(&MojoShellContext::ConnectToApplicationOnOwnThread, 181 base::Bind(&MojoShellContext::ConnectToApplicationOnOwnThread,
180 base::Unretained(shell_context_), name, requestor_name, 182 base::Unretained(shell_context_), user_id, name,
181 base::Passed(&request), base::Passed(&exposed_services), 183 requestor_name, base::Passed(&request),
182 callback)); 184 base::Passed(&exposed_services), callback));
183 } 185 }
184 } 186 }
185 187
186 private: 188 private:
187 MojoShellContext* shell_context_; 189 MojoShellContext* shell_context_;
188 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 190 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
189 191
190 DISALLOW_COPY_AND_ASSIGN(Proxy); 192 DISALLOW_COPY_AND_ASSIGN(Proxy);
191 }; 193 };
192 194
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 } 266 }
265 } 267 }
266 268
267 MojoShellContext::~MojoShellContext() { 269 MojoShellContext::~MojoShellContext() {
268 if (!IsRunningInMojoShell()) 270 if (!IsRunningInMojoShell())
269 MojoShellConnectionImpl::Destroy(); 271 MojoShellConnectionImpl::Destroy();
270 } 272 }
271 273
272 // static 274 // static
273 void MojoShellContext::ConnectToApplication( 275 void MojoShellContext::ConnectToApplication(
276 const std::string& user_id,
274 const std::string& name, 277 const std::string& name,
275 const std::string& requestor_name, 278 const std::string& requestor_name,
276 mojo::shell::mojom::InterfaceProviderRequest request, 279 mojo::shell::mojom::InterfaceProviderRequest request,
277 mojo::shell::mojom::InterfaceProviderPtr exposed_services, 280 mojo::shell::mojom::InterfaceProviderPtr exposed_services,
278 const mojo::shell::mojom::Connector::ConnectCallback& callback) { 281 const mojo::shell::mojom::Connector::ConnectCallback& callback) {
279 proxy_.Get()->ConnectToApplication(name, requestor_name, std::move(request), 282 proxy_.Get()->ConnectToApplication(
280 std::move(exposed_services), callback); 283 user_id, name, requestor_name, std::move(request),
284 std::move(exposed_services), callback);
281 } 285 }
282 286
283 void MojoShellContext::ConnectToApplicationOnOwnThread( 287 void MojoShellContext::ConnectToApplicationOnOwnThread(
288 const std::string& user_id,
284 const std::string& name, 289 const std::string& name,
285 const std::string& requestor_name, 290 const std::string& requestor_name,
286 mojo::shell::mojom::InterfaceProviderRequest request, 291 mojo::shell::mojom::InterfaceProviderRequest request,
287 mojo::shell::mojom::InterfaceProviderPtr exposed_services, 292 mojo::shell::mojom::InterfaceProviderPtr exposed_services,
288 const mojo::shell::mojom::Connector::ConnectCallback& callback) { 293 const mojo::shell::mojom::Connector::ConnectCallback& callback) {
289 scoped_ptr<mojo::shell::ConnectParams> params(new mojo::shell::ConnectParams); 294 scoped_ptr<mojo::shell::ConnectParams> params(new mojo::shell::ConnectParams);
290 // TODO(beng): kRootUserID is obviously wrong. 295 mojo::Identity source_id(requestor_name, user_id);
291 mojo::Identity source_id(requestor_name, mojo::shell::mojom::kRootUserID);
292 params->set_source(source_id); 296 params->set_source(source_id);
293 params->set_target(mojo::Identity(name, mojo::shell::mojom::kRootUserID)); 297 params->set_target(mojo::Identity(name, user_id));
294 params->set_remote_interfaces(std::move(request)); 298 params->set_remote_interfaces(std::move(request));
295 params->set_local_interfaces(std::move(exposed_services)); 299 params->set_local_interfaces(std::move(exposed_services));
296 params->set_connect_callback(callback); 300 params->set_connect_callback(callback);
297 shell_->Connect(std::move(params)); 301 shell_->Connect(std::move(params));
298 } 302 }
299 303
300 } // namespace content 304 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698