Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_SESSION_SESSION_CONTROLLER_H_ | 5 #ifndef ASH_SESSION_SESSION_CONTROLLER_H_ |
| 6 #define ASH_SESSION_SESSION_CONTROLLER_H_ | 6 #define ASH_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/login_status.h" | 13 #include "ash/login_status.h" |
| 14 #include "ash/public/cpp/session_types.h" | 14 #include "ash/public/cpp/session_types.h" |
| 15 #include "ash/public/interfaces/session_controller.mojom.h" | 15 #include "ash/public/interfaces/session_controller.mojom.h" |
| 16 #include "base/callback.h" | 16 #include "base/callback.h" |
| 17 #include "base/macros.h" | 17 #include "base/macros.h" |
| 18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 19 #include "base/observer_list.h" | 19 #include "base/observer_list.h" |
| 20 #include "base/time/time.h" | |
| 20 #include "mojo/public/cpp/bindings/binding_set.h" | 21 #include "mojo/public/cpp/bindings/binding_set.h" |
| 21 | 22 |
| 22 class AccountId; | 23 class AccountId; |
| 23 | 24 |
| 24 namespace ash { | 25 namespace ash { |
| 25 | 26 |
| 26 class SessionObserver; | 27 class SessionObserver; |
| 27 | 28 |
| 28 // Implements mojom::SessionController to cache session related info such as | 29 // Implements mojom::SessionController to cache session related info such as |
| 29 // session state, meta data about user sessions to support synchronous | 30 // session state, meta data about user sessions to support synchronous |
| 30 // queries for ash. It is targeted as a replacement for SessionStateDelegate. | 31 // queries for ash. It is targeted as a replacement for SessionStateDelegate. |
| 31 class ASH_EXPORT SessionController | 32 class ASH_EXPORT SessionController |
| 32 : NON_EXPORTED_BASE(public mojom::SessionController) { | 33 : NON_EXPORTED_BASE(public mojom::SessionController) { |
| 33 public: | 34 public: |
| 34 SessionController(); | 35 SessionController(); |
| 35 ~SessionController() override; | 36 ~SessionController() override; |
| 36 | 37 |
| 38 base::TimeDelta session_length_limit() const { return session_length_limit_; } | |
| 39 base::TimeTicks session_start_time() const { return session_start_time_; } | |
| 40 | |
| 37 // Binds the mojom::SessionControllerRequest to this object. | 41 // Binds the mojom::SessionControllerRequest to this object. |
| 38 void BindRequest(mojom::SessionControllerRequest request); | 42 void BindRequest(mojom::SessionControllerRequest request); |
| 39 | 43 |
| 40 // Returns the number of signed in users. If 0 is returned, there is either | 44 // Returns the number of signed in users. If 0 is returned, there is either |
| 41 // no session in progress or no active user. | 45 // no session in progress or no active user. |
| 42 int NumberOfLoggedInUsers() const; | 46 int NumberOfLoggedInUsers() const; |
| 43 | 47 |
| 44 // Gets the policy of adding a user session to ash. | 48 // Gets the policy of adding a user session to ash. |
| 45 AddUserSessionPolicy GetAddUserPolicy() const; | 49 AddUserSessionPolicy GetAddUserPolicy() const; |
| 46 | 50 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 // mojom::SessionController | 121 // mojom::SessionController |
| 118 void SetClient(mojom::SessionControllerClientPtr client) override; | 122 void SetClient(mojom::SessionControllerClientPtr client) override; |
| 119 void SetSessionInfo(mojom::SessionInfoPtr info) override; | 123 void SetSessionInfo(mojom::SessionInfoPtr info) override; |
| 120 void UpdateUserSession(mojom::UserSessionPtr user_session) override; | 124 void UpdateUserSession(mojom::UserSessionPtr user_session) override; |
| 121 void SetUserSessionOrder( | 125 void SetUserSessionOrder( |
| 122 const std::vector<uint32_t>& user_session_order) override; | 126 const std::vector<uint32_t>& user_session_order) override; |
| 123 void StartLock(StartLockCallback callback) override; | 127 void StartLock(StartLockCallback callback) override; |
| 124 void NotifyChromeLockAnimationsComplete() override; | 128 void NotifyChromeLockAnimationsComplete() override; |
| 125 void RunUnlockAnimation(RunUnlockAnimationCallback callback) override; | 129 void RunUnlockAnimation(RunUnlockAnimationCallback callback) override; |
| 126 void NotifyChromeTerminating() override; | 130 void NotifyChromeTerminating() override; |
| 131 void SetSessionLengthLimit(base::TimeDelta length_limit, | |
| 132 base::TimeTicks start_time) override; | |
| 127 | 133 |
| 128 // Test helpers. | 134 // Test helpers. |
| 129 void ClearUserSessionsForTest(); | 135 void ClearUserSessionsForTest(); |
| 130 void FlushMojoForTest(); | 136 void FlushMojoForTest(); |
| 131 void LockScreenAndFlushForTest(); | 137 void LockScreenAndFlushForTest(); |
| 132 | 138 |
| 133 private: | 139 private: |
| 134 void SetSessionState(session_manager::SessionState state); | 140 void SetSessionState(session_manager::SessionState state); |
| 135 void AddUserSession(mojom::UserSessionPtr user_session); | 141 void AddUserSession(mojom::UserSessionPtr user_session); |
| 136 | 142 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 173 // Last known login status. Used to track login status changes. | 179 // Last known login status. Used to track login status changes. |
| 174 LoginStatus login_status_ = LoginStatus::NOT_LOGGED_IN; | 180 LoginStatus login_status_ = LoginStatus::NOT_LOGGED_IN; |
| 175 | 181 |
| 176 // Whether unlocking is in progress. The flag is set when the pre-unlock | 182 // Whether unlocking is in progress. The flag is set when the pre-unlock |
| 177 // animation starts and reset when session state is no longer LOCKED. | 183 // animation starts and reset when session state is no longer LOCKED. |
| 178 bool is_unlocking_ = false; | 184 bool is_unlocking_ = false; |
| 179 | 185 |
| 180 // Pending callback for the StartLock request. | 186 // Pending callback for the StartLock request. |
| 181 base::OnceCallback<void(bool)> start_lock_callback_; | 187 base::OnceCallback<void(bool)> start_lock_callback_; |
| 182 | 188 |
| 189 // Zero if there is no session length limit. | |
|
msw
2017/06/06 19:01:04
nit: "The session length limit; set to zero if the
James Cook
2017/06/07 00:48:13
Done.
| |
| 190 base::TimeDelta session_length_limit_; | |
| 191 | |
| 192 // Stored in a pref in case of a crash in the middle of the session. Can | |
|
msw
2017/06/06 19:01:04
nit: "The session start time, set at login or on t
James Cook
2017/06/07 00:48:13
Done.
| |
| 193 // either be login time or the time of first user activity. Null when there | |
| 194 // is no session length limit. | |
| 195 base::TimeTicks session_start_time_; | |
| 196 | |
| 183 base::ObserverList<ash::SessionObserver> observers_; | 197 base::ObserverList<ash::SessionObserver> observers_; |
| 184 | 198 |
| 185 base::WeakPtrFactory<SessionController> weak_ptr_factory_; | 199 base::WeakPtrFactory<SessionController> weak_ptr_factory_; |
| 186 | 200 |
| 187 DISALLOW_COPY_AND_ASSIGN(SessionController); | 201 DISALLOW_COPY_AND_ASSIGN(SessionController); |
| 188 }; | 202 }; |
| 189 | 203 |
| 190 } // namespace ash | 204 } // namespace ash |
| 191 | 205 |
| 192 #endif // ASH_SESSION_SESSION_CONTROLLER_H_ | 206 #endif // ASH_SESSION_SESSION_CONTROLLER_H_ |
| OLD | NEW |