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

Side by Side Diff: mash/init/init.cc

Issue 2420253002: Rename shell namespace to service_manager (Closed)
Patch Set: . Created 4 years, 2 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
« no previous file with comments | « mash/init/init.h ('k') | mash/init/main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "mash/init/init.h" 5 #include "mash/init/init.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/guid.h" 9 #include "base/guid.h"
10 #include "mash/login/public/interfaces/login.mojom.h" 10 #include "mash/login/public/interfaces/login.mojom.h"
11 #include "services/service_manager/public/cpp/connection.h" 11 #include "services/service_manager/public/cpp/connection.h"
12 #include "services/service_manager/public/cpp/connector.h" 12 #include "services/service_manager/public/cpp/connector.h"
13 13
14 namespace mash { 14 namespace mash {
15 namespace init { 15 namespace init {
16 16
17 Init::Init() {} 17 Init::Init() {}
18 Init::~Init() {} 18 Init::~Init() {}
19 19
20 void Init::OnStart(const shell::Identity& identity) { 20 void Init::OnStart(const service_manager::Identity& identity) {
21 connector()->Connect("service:ui"); 21 connector()->Connect("service:ui");
22 StartTracing(); 22 StartTracing();
23 StartLogin(); 23 StartLogin();
24 } 24 }
25 25
26 bool Init::OnConnect(const shell::Identity& remote_identity, 26 bool Init::OnConnect(const service_manager::Identity& remote_identity,
27 shell::InterfaceRegistry* registry) { 27 service_manager::InterfaceRegistry* registry) {
28 registry->AddInterface<mojom::Init>(this); 28 registry->AddInterface<mojom::Init>(this);
29 return true; 29 return true;
30 } 30 }
31 31
32 void Init::StartService(const mojo::String& name, 32 void Init::StartService(const mojo::String& name,
33 const mojo::String& user_id) { 33 const mojo::String& user_id) {
34 if (user_services_.find(user_id) == user_services_.end()) { 34 if (user_services_.find(user_id) == user_services_.end()) {
35 shell::Connector::ConnectParams params(shell::Identity(name, user_id)); 35 service_manager::Connector::ConnectParams params(
36 std::unique_ptr<shell::Connection> connection = 36 service_manager::Identity(name, user_id));
37 std::unique_ptr<service_manager::Connection> connection =
37 connector()->Connect(&params); 38 connector()->Connect(&params);
38 connection->SetConnectionLostClosure( 39 connection->SetConnectionLostClosure(
39 base::Bind(&Init::UserServiceQuit, base::Unretained(this), user_id)); 40 base::Bind(&Init::UserServiceQuit, base::Unretained(this), user_id));
40 user_services_[user_id] = std::move(connection); 41 user_services_[user_id] = std::move(connection);
41 } 42 }
42 } 43 }
43 44
44 void Init::StopServicesForUser(const mojo::String& user_id) { 45 void Init::StopServicesForUser(const mojo::String& user_id) {
45 auto it = user_services_.find(user_id); 46 auto it = user_services_.find(user_id);
46 if (it != user_services_.end()) 47 if (it != user_services_.end())
47 user_services_.erase(it); 48 user_services_.erase(it);
48 } 49 }
49 50
50 void Init::Create(const shell::Identity& remote_identity, 51 void Init::Create(const service_manager::Identity& remote_identity,
51 mojom::InitRequest request) { 52 mojom::InitRequest request) {
52 init_bindings_.AddBinding(this, std::move(request)); 53 init_bindings_.AddBinding(this, std::move(request));
53 } 54 }
54 55
55 void Init::UserServiceQuit(const std::string& user_id) { 56 void Init::UserServiceQuit(const std::string& user_id) {
56 auto it = user_services_.find(user_id); 57 auto it = user_services_.find(user_id);
57 DCHECK(it != user_services_.end()); 58 DCHECK(it != user_services_.end());
58 user_services_.erase(it); 59 user_services_.erase(it);
59 } 60 }
60 61
61 void Init::StartTracing() { 62 void Init::StartTracing() {
62 connector()->Connect("service:tracing"); 63 connector()->Connect("service:tracing");
63 } 64 }
64 65
65 void Init::StartLogin() { 66 void Init::StartLogin() {
66 login_connection_ = connector()->Connect("service:login"); 67 login_connection_ = connector()->Connect("service:login");
67 mash::login::mojom::LoginPtr login; 68 mash::login::mojom::LoginPtr login;
68 login_connection_->GetInterface(&login); 69 login_connection_->GetInterface(&login);
69 login->ShowLoginUI(); 70 login->ShowLoginUI();
70 } 71 }
71 72
72 } // namespace init 73 } // namespace init
73 } // namespace main 74 } // namespace main
OLDNEW
« no previous file with comments | « mash/init/init.h ('k') | mash/init/main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698