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

Side by Side Diff: components/session_manager/core/session_manager.cc

Issue 2438063002: user_manager: Remove deps on session_manager (Closed)
Patch Set: fix nits in PS1 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 | « components/session_manager/core/session_manager.h ('k') | components/user_manager/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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/session_manager/core/session_manager.h" 5 #include "components/session_manager/core/session_manager.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 9
10 namespace session_manager { 10 namespace session_manager {
11 11
12 // static 12 // static
13 SessionManager* SessionManager::instance = NULL; 13 SessionManager* SessionManager::instance = NULL;
14 14
15 SessionManager::SessionManager() : session_state_(SessionState::UNKNOWN) { 15 SessionManager::SessionManager() {
16 DCHECK(!SessionManager::Get()); 16 DCHECK(!SessionManager::Get());
17 SessionManager::SetInstance(this); 17 SessionManager::SetInstance(this);
18 } 18 }
19 19
20 SessionManager::~SessionManager() { 20 SessionManager::~SessionManager() {
21 DCHECK(instance == this); 21 DCHECK(instance == this);
22 SessionManager::SetInstance(NULL); 22 SessionManager::SetInstance(NULL);
23 } 23 }
24 24
25 // static 25 // static
26 SessionManager* SessionManager::Get() { 26 SessionManager* SessionManager::Get() {
27 return SessionManager::instance; 27 return SessionManager::instance;
28 } 28 }
29 29
30 void SessionManager::SetSessionState(SessionState state) { 30 void SessionManager::SetSessionState(SessionState state) {
31 VLOG(1) << "Changing session state to: " << static_cast<int>(state); 31 VLOG(1) << "Changing session state to: " << static_cast<int>(state);
32 32
33 if (session_state_ != state) { 33 if (session_state_ != state) {
34 // TODO(nkostylev): Notify observers about the state change. 34 // TODO(nkostylev): Notify observers about the state change.
35 // TODO(nkostylev): Add code to process session state change and probably 35 // TODO(nkostylev): Add code to process session state change and probably
36 // replace delegate_ if needed. 36 // replace delegate_ if needed.
37 session_state_ = state; 37 session_state_ = state;
38 } 38 }
39 } 39 }
40 40
41 bool SessionManager::IsSessionStarted() const {
42 return session_started_;
43 }
44
45 void SessionManager::SessionStarted() {
46 session_started_ = true;
47 }
48
41 void SessionManager::Initialize(SessionManagerDelegate* delegate) { 49 void SessionManager::Initialize(SessionManagerDelegate* delegate) {
42 DCHECK(delegate); 50 DCHECK(delegate);
43 delegate_.reset(delegate); 51 delegate_.reset(delegate);
44 delegate_->SetSessionManager(this); 52 delegate_->SetSessionManager(this);
45 } 53 }
46 54
47 // static 55 // static
48 void SessionManager::SetInstance(SessionManager* session_manager) { 56 void SessionManager::SetInstance(SessionManager* session_manager) {
49 SessionManager::instance = session_manager; 57 SessionManager::instance = session_manager;
50 } 58 }
51 59
52 void SessionManager::Start() { 60 void SessionManager::Start() {
53 delegate_->Start(); 61 delegate_->Start();
54 } 62 }
55 63
56 SessionManagerDelegate::SessionManagerDelegate() : session_manager_(NULL) { 64 SessionManagerDelegate::SessionManagerDelegate() {
57 } 65 }
58 66
59 SessionManagerDelegate::~SessionManagerDelegate() { 67 SessionManagerDelegate::~SessionManagerDelegate() {
60 } 68 }
61 69
62 void SessionManagerDelegate::SetSessionManager( 70 void SessionManagerDelegate::SetSessionManager(
63 session_manager::SessionManager* session_manager) { 71 session_manager::SessionManager* session_manager) {
64 session_manager_ = session_manager; 72 session_manager_ = session_manager;
65 } 73 }
66 74
67 } // namespace session_manager 75 } // namespace session_manager
OLDNEW
« no previous file with comments | « components/session_manager/core/session_manager.h ('k') | components/user_manager/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698