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

Side by Side Diff: ash/common/session/session_controller.h

Issue 2797743002: ash: Merge LoginStatus update code path (Closed)
Patch Set: fix post unlock animation not run, and tests Created 3 years, 8 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
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 #ifndef ASH_COMMON_SESSION_SESSION_CONTROLLER_H_ 5 #ifndef ASH_COMMON_SESSION_SESSION_CONTROLLER_H_
6 #define ASH_COMMON_SESSION_SESSION_CONTROLLER_H_ 6 #define ASH_COMMON_SESSION_SESSION_CONTROLLER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <vector> 10 #include <vector>
11 11
12 #include "ash/ash_export.h" 12 #include "ash/ash_export.h"
13 #include "ash/common/login_status.h"
13 #include "ash/public/cpp/session_types.h" 14 #include "ash/public/cpp/session_types.h"
14 #include "ash/public/interfaces/session_controller.mojom.h" 15 #include "ash/public/interfaces/session_controller.mojom.h"
15 #include "base/macros.h" 16 #include "base/macros.h"
16 #include "base/observer_list.h" 17 #include "base/observer_list.h"
17 #include "mojo/public/cpp/bindings/binding_set.h" 18 #include "mojo/public/cpp/bindings/binding_set.h"
18 19
19 class AccountId; 20 class AccountId;
20 21
21 namespace ash { 22 namespace ash {
22 23
23 enum class LoginStatus;
24 class SessionStateObserver; 24 class SessionStateObserver;
25 25
26 // Implements mojom::SessionController to cache session related info such as 26 // Implements mojom::SessionController to cache session related info such as
27 // session state, meta data about user sessions to support synchronous 27 // session state, meta data about user sessions to support synchronous
28 // queries for ash. It is targeted as a replacement for SessionStateDelegate. 28 // queries for ash. It is targeted as a replacement for SessionStateDelegate.
29 class ASH_EXPORT SessionController 29 class ASH_EXPORT SessionController
30 : NON_EXPORTED_BASE(public mojom::SessionController) { 30 : NON_EXPORTED_BASE(public mojom::SessionController) {
31 public: 31 public:
32 SessionController(); 32 SessionController();
33 ~SessionController() override; 33 ~SessionController() override;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 // Switches the active user to the next or previous user, with the same 89 // Switches the active user to the next or previous user, with the same
90 // ordering as user sessions are created. 90 // ordering as user sessions are created.
91 void CycleActiveUser(CycleUserDirection direction); 91 void CycleActiveUser(CycleUserDirection direction);
92 92
93 void AddSessionStateObserver(SessionStateObserver* observer); 93 void AddSessionStateObserver(SessionStateObserver* observer);
94 void RemoveSessionStateObserver(SessionStateObserver* observer); 94 void RemoveSessionStateObserver(SessionStateObserver* observer);
95 95
96 // Returns the ash notion of login status. 96 // Returns the ash notion of login status.
97 // NOTE: Prefer GetSessionState() in new code because the concept of 97 // NOTE: Prefer GetSessionState() in new code because the concept of
98 // SessionState more closes matches the state in chrome. 98 // SessionState more closes matches the state in chrome.
99 LoginStatus GetLoginStatus() const; 99 LoginStatus GetLoginStatus() const;
James Cook 2017/04/05 00:16:24 optional: Maybe change to inline login_status() ge
xiyuan 2017/04/05 22:29:07 Done.
100 100
101 // mojom::SessionController 101 // mojom::SessionController
102 void SetClient(mojom::SessionControllerClientPtr client) override; 102 void SetClient(mojom::SessionControllerClientPtr client) override;
103 void SetSessionInfo(mojom::SessionInfoPtr info) override; 103 void SetSessionInfo(mojom::SessionInfoPtr info) override;
104 void UpdateUserSession(mojom::UserSessionPtr user_session) override; 104 void UpdateUserSession(mojom::UserSessionPtr user_session) override;
105 void SetUserSessionOrder( 105 void SetUserSessionOrder(
106 const std::vector<uint32_t>& user_session_order) override; 106 const std::vector<uint32_t>& user_session_order) override;
107 107
108 // Test helpers. 108 // Test helpers.
109 void ClearUserSessionsForTest(); 109 void ClearUserSessionsForTest();
110 void FlushMojoForTest(); 110 void FlushMojoForTest();
111 void LockScreenAndFlushForTest(); 111 void LockScreenAndFlushForTest();
112 112
113 private: 113 private:
114 void SetSessionState(session_manager::SessionState state); 114 void SetSessionState(session_manager::SessionState state);
115 void AddUserSession(mojom::UserSessionPtr user_session); 115 void AddUserSession(mojom::UserSessionPtr user_session);
116 116
117 // Calculate login status based on session state and active user session.
118 LoginStatus CalculateLoginStatus() const;
119
117 // Helper that returns login status when the session state is ACTIVE. 120 // Helper that returns login status when the session state is ACTIVE.
118 LoginStatus GetLoginStatusForActiveSession() const; 121 LoginStatus CalculateLoginStatusForActiveSession() const;
122
123 // Update the |login_status_| and notify observers.
124 void UpdateLoginStatus();
119 125
120 // Bindings for mojom::SessionController interface. 126 // Bindings for mojom::SessionController interface.
121 mojo::BindingSet<mojom::SessionController> bindings_; 127 mojo::BindingSet<mojom::SessionController> bindings_;
122 128
123 // Client interface to session manager code (chrome). 129 // Client interface to session manager code (chrome).
124 mojom::SessionControllerClientPtr client_; 130 mojom::SessionControllerClientPtr client_;
125 131
126 // Cached session info. 132 // Cached session info.
127 bool can_lock_ = false; 133 bool can_lock_ = false;
128 bool should_lock_screen_automatically_ = false; 134 bool should_lock_screen_automatically_ = false;
129 AddUserSessionPolicy add_user_session_policy_ = AddUserSessionPolicy::ALLOWED; 135 AddUserSessionPolicy add_user_session_policy_ = AddUserSessionPolicy::ALLOWED;
130 session_manager::SessionState state_; 136 session_manager::SessionState state_;
131 137
132 // Cached user session info sorted by the order from SetUserSessionOrder. 138 // Cached user session info sorted by the order from SetUserSessionOrder.
133 // Currently the session manager code (chrome) sets a LRU order with the 139 // Currently the session manager code (chrome) sets a LRU order with the
134 // active session being the first. 140 // active session being the first.
135 std::vector<mojom::UserSessionPtr> user_sessions_; 141 std::vector<mojom::UserSessionPtr> user_sessions_;
136 142
137 // The user session id of the current active user session. User session id 143 // The user session id of the current active user session. User session id
138 // is managed by session manager code, starting at 1. 0u is an invalid id 144 // is managed by session manager code, starting at 1. 0u is an invalid id
139 // to detect first active user session. 145 // to detect first active user session.
140 uint32_t active_session_id_ = 0u; 146 uint32_t active_session_id_ = 0u;
141 147
148 // Last known login status. Used to track login status changes.
149 LoginStatus login_status_ = LoginStatus::NOT_LOGGED_IN;
150
142 base::ObserverList<ash::SessionStateObserver> observers_; 151 base::ObserverList<ash::SessionStateObserver> observers_;
143 152
144 DISALLOW_COPY_AND_ASSIGN(SessionController); 153 DISALLOW_COPY_AND_ASSIGN(SessionController);
145 }; 154 };
146 155
147 } // namespace ash 156 } // namespace ash
148 157
149 #endif // ASH_COMMON_SESSION_SESSION_CONTROLLER_H_ 158 #endif // ASH_COMMON_SESSION_SESSION_CONTROLLER_H_
OLDNEW
« no previous file with comments | « no previous file | ash/common/session/session_controller.cc » ('j') | ash/common/session/session_state_observer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698