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

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

Issue 2468483002: session_manager: Tracks user sessions (Closed)
Patch Set: replace func overload with better names 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
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 #ifndef COMPONENTS_SESSION_MANAGER_CORE_SESSION_MANAGER_H_ 5 #ifndef COMPONENTS_SESSION_MANAGER_CORE_SESSION_MANAGER_H_
6 #define COMPONENTS_SESSION_MANAGER_CORE_SESSION_MANAGER_H_ 6 #define COMPONENTS_SESSION_MANAGER_CORE_SESSION_MANAGER_H_
7 7
8 #include <vector>
9
8 #include "base/macros.h" 10 #include "base/macros.h"
9 #include "components/session_manager/session_manager_export.h" 11 #include "components/session_manager/session_manager_export.h"
10 #include "components/session_manager/session_manager_types.h" 12 #include "components/session_manager/session_manager_types.h"
11 13
14 class AccountId;
15
12 namespace session_manager { 16 namespace session_manager {
13 17
14 class SESSION_EXPORT SessionManager { 18 class SESSION_EXPORT SessionManager {
15 public: 19 public:
16 SessionManager(); 20 SessionManager();
17 virtual ~SessionManager(); 21 virtual ~SessionManager();
18 22
19 // Returns current SessionManager instance and NULL if it hasn't been 23 // Returns current SessionManager instance and NULL if it hasn't been
20 // initialized yet. 24 // initialized yet.
21 static SessionManager* Get(); 25 static SessionManager* Get();
22 26
23 SessionState session_state() const { return session_state_; } 27 void SetSessionState(SessionState state);
24 virtual void SetSessionState(SessionState state); 28
29 // Creates a session for the given user. The first one is for regular cases
30 // and the 2nd one is for the crash-and-restart case.
31 void CreateSession(const AccountId& user_account_id,
32 const std::string& user_id_hash);
33 void CreateSessionForRestart(const AccountId& user_account_id,
34 const std::string& user_id_hash);
25 35
26 // Returns true if we're logged in and browser has been started i.e. 36 // Returns true if we're logged in and browser has been started i.e.
27 // browser_creator.LaunchBrowser(...) was called after sign in 37 // browser_creator.LaunchBrowser(...) was called after sign in
28 // or restart after crash. 38 // or restart after crash.
29 virtual bool IsSessionStarted() const; 39 virtual bool IsSessionStarted() const;
30 40
31 // Called when browser session is started i.e. after 41 // Called when browser session is started i.e. after
32 // browser_creator.LaunchBrowser(...) was called after user sign in. 42 // browser_creator.LaunchBrowser(...) was called after user sign in.
33 // When user is at the image screen IsUserLoggedIn() will return true 43 // When user is at the image screen IsUserLoggedIn() will return true
34 // but IsSessionStarted() will return false. During the kiosk splash screen, 44 // but IsSessionStarted() will return false. During the kiosk splash screen,
35 // we perform additional initialization after the user is logged in but 45 // we perform additional initialization after the user is logged in but
36 // before the session has been started. 46 // before the session has been started.
37 virtual void SessionStarted(); 47 virtual void SessionStarted();
38 48
49 SessionState session_state() const { return session_state_; }
50 const std::vector<Session>& sessions() const { return sessions_; }
51
39 protected: 52 protected:
53 // Notifies UserManager about a user signs in when creating a user session.
54 virtual void NotifyUserLoggedIn(const AccountId& user_account_id,
55 const std::string& user_id_hash,
56 bool browser_restart);
57
40 // Sets SessionManager instance. 58 // Sets SessionManager instance.
41 static void SetInstance(SessionManager* session_manager); 59 static void SetInstance(SessionManager* session_manager);
42 60
43 private: 61 private:
62 void CreateSessionInternal(const AccountId& user_account_id,
63 const std::string& user_id_hash,
64 bool browser_restart);
65
44 // Pointer to the existing SessionManager instance (if any). 66 // Pointer to the existing SessionManager instance (if any).
45 // Set in ctor, reset in dtor. Not owned since specific implementation of 67 // Set in ctor, reset in dtor. Not owned since specific implementation of
46 // SessionManager should decide on its own appropriate owner of SessionManager 68 // SessionManager should decide on its own appropriate owner of SessionManager
47 // instance. For src/chrome implementation such place is 69 // instance. For src/chrome implementation such place is
48 // g_browser_process->platform_part(). 70 // g_browser_process->platform_part().
49 static SessionManager* instance; 71 static SessionManager* instance;
50 72
51 SessionState session_state_ = SessionState::UNKNOWN; 73 SessionState session_state_ = SessionState::UNKNOWN;
52 74
53 // True if SessionStarted() has been called. 75 // True if SessionStarted() has been called.
54 bool session_started_ = false; 76 bool session_started_ = false;
55 77
78 // Id of the primary session, i.e. the first user session.
79 static const SessionId kPrimarySessionId = 1;
80
81 // ID assigned to the next session.
82 SessionId next_id_ = kPrimarySessionId;
83
84 // Keeps track of user sessions.
85 std::vector<Session> sessions_;
86
56 DISALLOW_COPY_AND_ASSIGN(SessionManager); 87 DISALLOW_COPY_AND_ASSIGN(SessionManager);
57 }; 88 };
58 89
59 } // namespace session_manager 90 } // namespace session_manager
60 91
61 #endif // COMPONENTS_SESSION_MANAGER_CORE_SESSION_MANAGER_H_ 92 #endif // COMPONENTS_SESSION_MANAGER_CORE_SESSION_MANAGER_H_
OLDNEW
« no previous file with comments | « components/session_manager/core/DEPS ('k') | components/session_manager/core/session_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698