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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/session_manager/core/DEPS ('k') | components/session_manager/core/session_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/session_manager/core/session_manager.h
diff --git a/components/session_manager/core/session_manager.h b/components/session_manager/core/session_manager.h
index 53623178136041a46941716bd4f08a3a9b935a70..02b7589a4576908d65778cc719a7e5dde1b2e985 100644
--- a/components/session_manager/core/session_manager.h
+++ b/components/session_manager/core/session_manager.h
@@ -5,10 +5,14 @@
#ifndef COMPONENTS_SESSION_MANAGER_CORE_SESSION_MANAGER_H_
#define COMPONENTS_SESSION_MANAGER_CORE_SESSION_MANAGER_H_
+#include <vector>
+
#include "base/macros.h"
#include "components/session_manager/session_manager_export.h"
#include "components/session_manager/session_manager_types.h"
+class AccountId;
+
namespace session_manager {
class SESSION_EXPORT SessionManager {
@@ -20,8 +24,14 @@ class SESSION_EXPORT SessionManager {
// initialized yet.
static SessionManager* Get();
- SessionState session_state() const { return session_state_; }
- virtual void SetSessionState(SessionState state);
+ void SetSessionState(SessionState state);
+
+ // Creates a session for the given user. The first one is for regular cases
+ // and the 2nd one is for the crash-and-restart case.
+ void CreateSession(const AccountId& user_account_id,
+ const std::string& user_id_hash);
+ void CreateSessionForRestart(const AccountId& user_account_id,
+ const std::string& user_id_hash);
// Returns true if we're logged in and browser has been started i.e.
// browser_creator.LaunchBrowser(...) was called after sign in
@@ -36,11 +46,23 @@ class SESSION_EXPORT SessionManager {
// before the session has been started.
virtual void SessionStarted();
+ SessionState session_state() const { return session_state_; }
+ const std::vector<Session>& sessions() const { return sessions_; }
+
protected:
+ // Notifies UserManager about a user signs in when creating a user session.
+ virtual void NotifyUserLoggedIn(const AccountId& user_account_id,
+ const std::string& user_id_hash,
+ bool browser_restart);
+
// Sets SessionManager instance.
static void SetInstance(SessionManager* session_manager);
private:
+ void CreateSessionInternal(const AccountId& user_account_id,
+ const std::string& user_id_hash,
+ bool browser_restart);
+
// Pointer to the existing SessionManager instance (if any).
// Set in ctor, reset in dtor. Not owned since specific implementation of
// SessionManager should decide on its own appropriate owner of SessionManager
@@ -53,6 +75,15 @@ class SESSION_EXPORT SessionManager {
// True if SessionStarted() has been called.
bool session_started_ = false;
+ // Id of the primary session, i.e. the first user session.
+ static const SessionId kPrimarySessionId = 1;
+
+ // ID assigned to the next session.
+ SessionId next_id_ = kPrimarySessionId;
+
+ // Keeps track of user sessions.
+ std::vector<Session> sessions_;
+
DISALLOW_COPY_AND_ASSIGN(SessionManager);
};
« 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