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

Unified Diff: chrome/browser/sessions/session_restore.h

Issue 2935183002: [TabMetrics] Add signals that mark the start and end of session restore. (Closed)
Patch Set: Enable SessionRestoreObserverTest only when session service available. Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sessions/session_restore.h
diff --git a/chrome/browser/sessions/session_restore.h b/chrome/browser/sessions/session_restore.h
index e7ad887cf1bfc62d4bb736c9866ff433d86d15e2..10dabff112187730d77f053001e1fb8bbbfa8371 100644
--- a/chrome/browser/sessions/session_restore.h
+++ b/chrome/browser/sessions/session_restore.h
@@ -12,6 +12,8 @@
#include "base/callback_list.h"
#include "base/macros.h"
+#include "base/observer_list.h"
+#include "chrome/browser/sessions/session_restore_observer.h"
#include "components/history/core/browser/history_service.h"
#include "components/sessions/core/session_types.h"
#include "ui/base/window_open_disposition.h"
@@ -106,6 +108,18 @@ class SessionRestore {
static void AddURLsToOpen(const Profile* profile,
const std::vector<GURL>& urls);
+ // Add/remove an observer to/from this session restore.
+ static void AddObserver(SessionRestoreObserver* observer);
+ static void RemoveObserver(SessionRestoreObserver* observer);
+
+ // Accessor for the observer list. Create the list the first time to always
+ // return a valid reference.
+ static base::ObserverList<SessionRestoreObserver>& observers() {
+ if (!observers_)
+ observers_ = new base::ObserverList<SessionRestoreObserver>();
+ return *observers_;
+ }
+
private:
SessionRestore();
@@ -120,6 +134,9 @@ class SessionRestore {
// Contains all registered callbacks for session restore notifications.
static CallbackList* on_session_restored_callbacks_;
+ // Contains all registered observers for session restore events.
+ static base::ObserverList<SessionRestoreObserver>* observers_;
chrisha 2017/06/27 17:09:07 Shouldn't this explicitly use a leaky lazy instanc
+
DISALLOW_COPY_AND_ASSIGN(SessionRestore);
};
« no previous file with comments | « chrome/browser/resource_coordinator/tab_manager_unittest.cc ('k') | chrome/browser/sessions/session_restore.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698