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

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: Add OWNERS file by request. 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 // Thread-safe proxy providing access to the shell context from any thread. 152 // Thread-safe proxy providing access to the shell context from any thread.
152 class MojoShellContext::Proxy { 153 class MojoShellContext::Proxy {
153 public: 154 public:
154 Proxy(MojoShellContext* shell_context) 155 Proxy(MojoShellContext* shell_context)
155 : shell_context_(shell_context), 156 : shell_context_(shell_context),
156 task_runner_(base::ThreadTaskRunnerHandle::Get()) {} 157 task_runner_(base::ThreadTaskRunnerHandle::Get()) {}
157 158
158 ~Proxy() {} 159 ~Proxy() {}
159 160
160 void ConnectToApplication( 161 void ConnectToApplication(
162 const std::string& user_id,
161 const std::string& name, 163 const std::string& name,
162 const std::string& requestor_name, 164 const std::string& requestor_name,
163 mojo::shell::mojom::InterfaceProviderRequest request, 165 mojo::shell::mojom::InterfaceProviderRequest request,
164 mojo::shell::mojom::InterfaceProviderPtr exposed_services, 166 mojo::shell::mojom::InterfaceProviderPtr exposed_services,
165 const mojo::shell::mojom::Connector::ConnectCallback& callback) { 167 const mojo::shell::mojom::Connector::ConnectCallback& callback) {
166 if (task_runner_ == base::ThreadTaskRunnerHandle::Get()) { 168 if (task_runner_ == base::ThreadTaskRunnerHandle::Get()) {
167 if (shell_context_) { 169 if (shell_context_) {
168 shell_context_->ConnectToApplicationOnOwnThread( 170 shell_context_->ConnectToApplicationOnOwnThread(
169 name, requestor_name, std::move(request), 171 user_id, name, requestor_name, std::move(request),
170 std::move(exposed_services), callback); 172 std::move(exposed_services), callback);
171 } 173 }
172 } else { 174 } else {
173 // |shell_context_| outlives the main MessageLoop, so it's safe for it to 175 // |shell_context_| outlives the main MessageLoop, so it's safe for it to
174 // be unretained here. 176 // be unretained here.
175 task_runner_->PostTask( 177 task_runner_->PostTask(
176 FROM_HERE, 178 FROM_HERE,
177 base::Bind(&MojoShellContext::ConnectToApplicationOnOwnThread, 179 base::Bind(&MojoShellContext::ConnectToApplicationOnOwnThread,
178 base::Unretained(shell_context_), name, requestor_name, 180 base::Unretained(shell_context_), user_id, name,
179 base::Passed(&request), base::Passed(&exposed_services), 181 requestor_name, base::Passed(&request),
180 callback)); 182 base::Passed(&exposed_services), callback));
181 } 183 }
182 } 184 }
183 185
184 private: 186 private:
185 MojoShellContext* shell_context_; 187 MojoShellContext* shell_context_;
186 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 188 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
187 189
188 DISALLOW_COPY_AND_ASSIGN(Proxy); 190 DISALLOW_COPY_AND_ASSIGN(Proxy);
189 }; 191 };
190 192
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 MojoShellConnectionImpl::Destroy(); 268 MojoShellConnectionImpl::Destroy();
267 } 269 }
268 270
269 // static 271 // static
270 void MojoShellContext::ConnectToApplication( 272 void MojoShellContext::ConnectToApplication(
271 const std::string& name, 273 const std::string& name,
272 const std::string& requestor_name, 274 const std::string& requestor_name,
273 mojo::shell::mojom::InterfaceProviderRequest request, 275 mojo::shell::mojom::InterfaceProviderRequest request,
274 mojo::shell::mojom::InterfaceProviderPtr exposed_services, 276 mojo::shell::mojom::InterfaceProviderPtr exposed_services,
275 const mojo::shell::mojom::Connector::ConnectCallback& callback) { 277 const mojo::shell::mojom::Connector::ConnectCallback& callback) {
276 proxy_.Get()->ConnectToApplication(name, requestor_name, std::move(request), 278 proxy_.Get()->ConnectToApplication(
277 std::move(exposed_services), callback); 279 mojo::shell::mojom::kInheritUserID,
280 name, requestor_name, std::move(request),
281 std::move(exposed_services), callback);
282 }
283
284 // static
285 void MojoShellContext::ConnectToApplicationWithUserId(
286 const std::string& user_id,
287 const std::string& name,
288 const std::string& requestor_name,
289 mojo::shell::mojom::InterfaceProviderRequest request,
290 mojo::shell::mojom::InterfaceProviderPtr exposed_services,
291 const mojo::shell::mojom::Connector::ConnectCallback& callback) {
292 proxy_.Get()->ConnectToApplication(
293 user_id, name, requestor_name, std::move(request),
294 std::move(exposed_services), callback);
278 } 295 }
279 296
280 void MojoShellContext::ConnectToApplicationOnOwnThread( 297 void MojoShellContext::ConnectToApplicationOnOwnThread(
298 const std::string& user_id,
281 const std::string& name, 299 const std::string& name,
282 const std::string& requestor_name, 300 const std::string& requestor_name,
283 mojo::shell::mojom::InterfaceProviderRequest request, 301 mojo::shell::mojom::InterfaceProviderRequest request,
284 mojo::shell::mojom::InterfaceProviderPtr exposed_services, 302 mojo::shell::mojom::InterfaceProviderPtr exposed_services,
285 const mojo::shell::mojom::Connector::ConnectCallback& callback) { 303 const mojo::shell::mojom::Connector::ConnectCallback& callback) {
286 scoped_ptr<mojo::shell::ConnectParams> params(new mojo::shell::ConnectParams); 304 scoped_ptr<mojo::shell::ConnectParams> params(new mojo::shell::ConnectParams);
287 // TODO(beng): kRootUserID is obviously wrong. 305 mojo::Identity source_id(requestor_name, user_id);
288 mojo::Identity source_id(requestor_name, mojo::shell::mojom::kRootUserID);
289 params->set_source(source_id); 306 params->set_source(source_id);
290 params->set_target(mojo::Identity(name, mojo::shell::mojom::kRootUserID)); 307 params->set_target(mojo::Identity(name, user_id));
291 params->set_remote_interfaces(std::move(request)); 308 params->set_remote_interfaces(std::move(request));
292 params->set_local_interfaces(std::move(exposed_services)); 309 params->set_local_interfaces(std::move(exposed_services));
293 params->set_connect_callback(callback); 310 params->set_connect_callback(callback);
294 shell_->Connect(std::move(params)); 311 shell_->Connect(std::move(params));
295 } 312 }
296 313
297 } // namespace content 314 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698