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

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

Issue 2496713003: Mojo C++ bindings: switch mash/init mojom target to use STL types. (Closed)
Patch Set: Created 4 years, 1 month 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/public/interfaces/BUILD.gn » ('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"
(...skipping 14 matching lines...) Expand all
25 StartTracing(); 25 StartTracing();
26 StartLogin(); 26 StartLogin();
27 } 27 }
28 28
29 bool Init::OnConnect(const service_manager::ServiceInfo& remote_info, 29 bool Init::OnConnect(const service_manager::ServiceInfo& remote_info,
30 service_manager::InterfaceRegistry* registry) { 30 service_manager::InterfaceRegistry* registry) {
31 registry->AddInterface<mojom::Init>(this); 31 registry->AddInterface<mojom::Init>(this);
32 return true; 32 return true;
33 } 33 }
34 34
35 void Init::StartService(const mojo::String& name, 35 void Init::StartService(const std::string& name, const std::string& user_id) {
36 const mojo::String& user_id) {
37 if (user_services_.find(user_id) == user_services_.end()) { 36 if (user_services_.find(user_id) == user_services_.end()) {
38 service_manager::Connector::ConnectParams params( 37 service_manager::Connector::ConnectParams params(
39 service_manager::Identity(name, user_id)); 38 service_manager::Identity(name, user_id));
40 std::unique_ptr<service_manager::Connection> connection = 39 std::unique_ptr<service_manager::Connection> connection =
41 context_->connector()->Connect(&params); 40 context_->connector()->Connect(&params);
42 connection->SetConnectionLostClosure( 41 connection->SetConnectionLostClosure(
43 base::Bind(&Init::UserServiceQuit, base::Unretained(this), user_id)); 42 base::Bind(&Init::UserServiceQuit, base::Unretained(this), user_id));
44 user_services_[user_id] = std::move(connection); 43 user_services_[user_id] = std::move(connection);
45 } 44 }
46 } 45 }
47 46
48 void Init::StopServicesForUser(const mojo::String& user_id) { 47 void Init::StopServicesForUser(const std::string& user_id) {
49 auto it = user_services_.find(user_id); 48 auto it = user_services_.find(user_id);
50 if (it != user_services_.end()) 49 if (it != user_services_.end())
51 user_services_.erase(it); 50 user_services_.erase(it);
52 } 51 }
53 52
54 void Init::Create(const service_manager::Identity& remote_identity, 53 void Init::Create(const service_manager::Identity& remote_identity,
55 mojom::InitRequest request) { 54 mojom::InitRequest request) {
56 init_bindings_.AddBinding(this, std::move(request)); 55 init_bindings_.AddBinding(this, std::move(request));
57 } 56 }
58 57
59 void Init::UserServiceQuit(const std::string& user_id) { 58 void Init::UserServiceQuit(const std::string& user_id) {
60 auto it = user_services_.find(user_id); 59 auto it = user_services_.find(user_id);
61 DCHECK(it != user_services_.end()); 60 DCHECK(it != user_services_.end());
62 user_services_.erase(it); 61 user_services_.erase(it);
63 } 62 }
64 63
65 void Init::StartTracing() { 64 void Init::StartTracing() {
66 context_->connector()->Connect("service:tracing"); 65 context_->connector()->Connect("service:tracing");
67 } 66 }
68 67
69 void Init::StartLogin() { 68 void Init::StartLogin() {
70 login_connection_ = context_->connector()->Connect("service:login"); 69 login_connection_ = context_->connector()->Connect("service:login");
71 mash::login::mojom::LoginPtr login; 70 mash::login::mojom::LoginPtr login;
72 login_connection_->GetInterface(&login); 71 login_connection_->GetInterface(&login);
73 login->ShowLoginUI(); 72 login->ShowLoginUI();
74 } 73 }
75 74
76 } // namespace init 75 } // namespace init
77 } // namespace main 76 } // namespace main
OLDNEW
« no previous file with comments | « mash/init/init.h ('k') | mash/init/public/interfaces/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698