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

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

Issue 2487573002: Service Manager: Remove ServiceContext* arg from Service::OnStart() (Closed)
Patch Set: rebase 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/session/session.h ('k') | mash/task_viewer/task_viewer.h » ('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 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 "mash/session/session.h" 5 #include "mash/session/session.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/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "mash/login/public/interfaces/login.mojom.h" 10 #include "mash/login/public/interfaces/login.mojom.h"
(...skipping 11 matching lines...) Expand all
22 } 22 }
23 23
24 } // namespace 24 } // namespace
25 25
26 namespace mash { 26 namespace mash {
27 namespace session { 27 namespace session {
28 28
29 Session::Session() : screen_locked_(false) {} 29 Session::Session() : screen_locked_(false) {}
30 Session::~Session() {} 30 Session::~Session() {}
31 31
32 void Session::OnStart(service_manager::ServiceContext* context) { 32 void Session::OnStart() {
33 context_ = context;
34
35 StartWindowManager(); 33 StartWindowManager();
36 StartQuickLaunch(); 34 StartQuickLaunch();
37 35
38 // Launch a chrome window for dev convience; don't do this in the long term. 36 // Launch a chrome window for dev convience; don't do this in the long term.
39 context->connector()->Connect("service:content_browser"); 37 context()->connector()->Connect("service:content_browser");
40 } 38 }
41 39
42 bool Session::OnConnect(const service_manager::ServiceInfo& remote_info, 40 bool Session::OnConnect(const service_manager::ServiceInfo& remote_info,
43 service_manager::InterfaceRegistry* registry) { 41 service_manager::InterfaceRegistry* registry) {
44 registry->AddInterface<mojom::Session>(this); 42 registry->AddInterface<mojom::Session>(this);
45 return true; 43 return true;
46 } 44 }
47 45
48 void Session::Logout() { 46 void Session::Logout() {
49 // TODO(beng): Notify connected listeners that login is happening, potentially 47 // TODO(beng): Notify connected listeners that login is happening, potentially
50 // give them the option to stop it. 48 // give them the option to stop it.
51 mash::login::mojom::LoginPtr login; 49 mash::login::mojom::LoginPtr login;
52 context_->connector()->ConnectToInterface("service:login", &login); 50 context()->connector()->ConnectToInterface("service:login", &login);
53 login->ShowLoginUI(); 51 login->ShowLoginUI();
54 // This kills the user environment. 52 // This kills the user environment.
55 base::MessageLoop::current()->QuitWhenIdle(); 53 base::MessageLoop::current()->QuitWhenIdle();
56 } 54 }
57 55
58 void Session::SwitchUser() { 56 void Session::SwitchUser() {
59 mash::login::mojom::LoginPtr login; 57 mash::login::mojom::LoginPtr login;
60 context_->connector()->ConnectToInterface("service:login", &login); 58 context()->connector()->ConnectToInterface("service:login", &login);
61 login->SwitchUser(); 59 login->SwitchUser();
62 } 60 }
63 61
64 void Session::AddScreenlockStateListener( 62 void Session::AddScreenlockStateListener(
65 mojom::ScreenlockStateListenerPtr listener) { 63 mojom::ScreenlockStateListenerPtr listener) {
66 listener->ScreenlockStateChanged(screen_locked_); 64 listener->ScreenlockStateChanged(screen_locked_);
67 screenlock_listeners_.AddPtr(std::move(listener)); 65 screenlock_listeners_.AddPtr(std::move(listener));
68 } 66 }
69 67
70 void Session::LockScreen() { 68 void Session::LockScreen() {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 DCHECK(connections_.end() != connection); 117 DCHECK(connections_.end() != connection);
120 connections_.erase(connection); 118 connections_.erase(connection);
121 } 119 }
122 120
123 void Session::StartRestartableService( 121 void Session::StartRestartableService(
124 const std::string& url, 122 const std::string& url,
125 const base::Closure& restart_callback) { 123 const base::Closure& restart_callback) {
126 // TODO(beng): This would be the place to insert logic that counted restarts 124 // TODO(beng): This would be the place to insert logic that counted restarts
127 // to avoid infinite crash-restart loops. 125 // to avoid infinite crash-restart loops.
128 std::unique_ptr<service_manager::Connection> connection = 126 std::unique_ptr<service_manager::Connection> connection =
129 context_->connector()->Connect(url); 127 context()->connector()->Connect(url);
130 // Note: |connection| may be null if we've lost our connection to the service 128 // Note: |connection| may be null if we've lost our connection to the service
131 // manager. 129 // manager.
132 if (connection) { 130 if (connection) {
133 connection->SetConnectionLostClosure( 131 connection->SetConnectionLostClosure(
134 base::Bind(&LogAndCallServiceRestartCallback, url, restart_callback)); 132 base::Bind(&LogAndCallServiceRestartCallback, url, restart_callback));
135 connections_[url] = std::move(connection); 133 connections_[url] = std::move(connection);
136 } 134 }
137 } 135 }
138 136
139 } // namespace session 137 } // namespace session
140 } // namespace main 138 } // namespace main
OLDNEW
« no previous file with comments | « mash/session/session.h ('k') | mash/task_viewer/task_viewer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698