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

Unified Diff: components/session_manager/core/session_manager.cc

Issue 2510983002: session_manager: Add SessionManagerObserver interface (Closed)
Patch Set: 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
Index: components/session_manager/core/session_manager.cc
diff --git a/components/session_manager/core/session_manager.cc b/components/session_manager/core/session_manager.cc
index 4d72c12f561bdb9cbbefa8e61d495435cf3807f2..b439b861d10d5ac6bdc632464bff0060f311bcd9 100644
--- a/components/session_manager/core/session_manager.cc
+++ b/components/session_manager/core/session_manager.cc
@@ -31,14 +31,14 @@ SessionManager* SessionManager::Get() {
}
void SessionManager::SetSessionState(SessionState state) {
+ if (session_state_ == state)
+ return;
+
VLOG(1) << "Changing session state to: " << static_cast<int>(state);
- if (session_state_ != state) {
- // TODO(nkostylev): Notify observers about the state change.
- // TODO(nkostylev): Add code to process session state change and probably
- // replace delegate_ if needed.
- session_state_ = state;
- }
+ session_state_ = state;
+ for (auto* observer : observers_)
+ observer->OnSessionStateChanged();
}
void SessionManager::CreateSession(const AccountId& user_account_id,
@@ -61,6 +61,14 @@ void SessionManager::SessionStarted() {
session_started_ = true;
}
+void SessionManager::AddObserver(SessionManagerObserver* observer) {
+ observers_.AddObserver(observer);
+}
+
+void SessionManager::RemoveObserver(SessionManagerObserver* observer) {
+ observers_.RemoveObserver(observer);
+}
+
void SessionManager::NotifyUserLoggedIn(const AccountId& user_account_id,
const std::string& user_id_hash,
bool browser_restart) {

Powered by Google App Engine
This is Rietveld 408576698