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

Side by Side Diff: content/public/browser/mojo_app_connection.cc

Issue 1128453004: Embed a simple Mojo shell in content (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/public/browser/mojo_app_connection.h"
6
7 #include "base/bind.h"
8 #include "base/lazy_instance.h"
9 #include "base/location.h"
10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/single_thread_task_runner.h"
13 #include "base/thread_task_runner_handle.h"
14 #include "base/threading/thread_local.h"
15 #include "mojo/shell/application_manager.h"
16 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h"
17 #include "url/gurl.h"
18
19 namespace content {
20
21 namespace {
22
23 // Virtual requestor URL to use when connecting to applications through
24 // MojoAppConnection instances.
25 const char kBrowserAppUrl[] = "system:content_browser";
26
27 mojo::shell::ApplicationManager* g_application_manager;
28 base::SingleThreadTaskRunner* g_application_manager_task_runner;
29
30 void ConnectToApplicationOnManagerThread(
31 const GURL& application_url,
32 mojo::InterfaceRequest<mojo::ServiceProvider> services) {
33 DCHECK(g_application_manager);
34 g_application_manager->ConnectToApplication(
35 application_url, GURL(kBrowserAppUrl), services.Pass(),
36 mojo::ServiceProviderPtr(), base::Bind(&base::DoNothing));
37 }
38
39 void ConnectToApplication(
40 const GURL& application_url,
41 mojo::InterfaceRequest<mojo::ServiceProvider> services) {
42 DCHECK(g_application_manager_task_runner);
43 if (g_application_manager_task_runner)
44 g_application_manager_task_runner->PostTask(
45 FROM_HERE, base::Bind(&ConnectToApplicationOnManagerThread,
46 application_url, base::Passed(&services)));
47 }
48
49 } // namespace
50
51 MojoAppConnection::MojoAppConnection(const GURL& application_url) {
52 ConnectToApplication(application_url, mojo::GetProxy(&remote_services_));
53 }
54
55 MojoAppConnection::~MojoAppConnection() {
56 }
57
58 void MojoAppConnection::SetApplicationManager(
59 mojo::shell::ApplicationManager* application_manager) {
60 g_application_manager = application_manager;
61 g_application_manager_task_runner = base::ThreadTaskRunnerHandle::Get().get();
62 }
63
64 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698