Commit 4c83211a authored by Alexander Cooper's avatar Alexander Cooper Committed by Commit Bot

Convert Callbacks in chrome/browser/sessions

Converts the SessionRestore::CallbackList to a RepeatingCallbackList and
converts the Registration method to take a RepeatingCallback, due to
usage.
Converts quit_closure_for_sync_restore_ into a OnceClosure.
Converts a bind in tab_loader whose receiving end had previously been
converted.

Also converts one session restore notification registration in
chrome_browser_main_posix to base::BindRepeating, as part of ongoing
efforts to convert the top-level chrome/browser files.

Bug: 1007635
Change-Id: I5034a3f801e162f987becdbe9c64073a905bac5a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2300604
Auto-Submit: Alexander Cooper <alcooper@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/master@{#788818}
parent 460fe6aa
...@@ -101,9 +101,8 @@ void ExitHandler::ExitWhenPossibleOnUIThread(int signal) { ...@@ -101,9 +101,8 @@ void ExitHandler::ExitWhenPossibleOnUIThread(int signal) {
ExitHandler::ExitHandler() { ExitHandler::ExitHandler() {
on_session_restored_callback_subscription_ = on_session_restored_callback_subscription_ =
SessionRestore::RegisterOnSessionRestoredCallback( SessionRestore::RegisterOnSessionRestoredCallback(base::BindRepeating(
base::Bind(&ExitHandler::OnSessionRestoreDone, &ExitHandler::OnSessionRestoreDone, base::Unretained(this)));
base::Unretained(this)));
} }
ExitHandler::~ExitHandler() { ExitHandler::~ExitHandler() {
......
...@@ -152,7 +152,7 @@ class SessionRestoreImpl : public BrowserListObserver { ...@@ -152,7 +152,7 @@ class SessionRestoreImpl : public BrowserListObserver {
base::RunLoop loop(base::RunLoop::Type::kNestableTasksAllowed); base::RunLoop loop(base::RunLoop::Type::kNestableTasksAllowed);
quit_closure_for_sync_restore_ = loop.QuitClosure(); quit_closure_for_sync_restore_ = loop.QuitClosure();
loop.Run(); loop.Run();
quit_closure_for_sync_restore_ = base::Closure(); quit_closure_for_sync_restore_ = base::OnceClosure();
} }
Browser* browser = Browser* browser =
ProcessSessionWindowsAndNotify(&windows_, active_window_id_); ProcessSessionWindowsAndNotify(&windows_, active_window_id_);
...@@ -333,7 +333,7 @@ class SessionRestoreImpl : public BrowserListObserver { ...@@ -333,7 +333,7 @@ class SessionRestoreImpl : public BrowserListObserver {
windows_.swap(windows); windows_.swap(windows);
active_window_id_ = active_window_id; active_window_id_ = active_window_id;
CHECK(!quit_closure_for_sync_restore_.is_null()); CHECK(!quit_closure_for_sync_restore_.is_null());
quit_closure_for_sync_restore_.Run(); std::move(quit_closure_for_sync_restore_).Run();
return; return;
} }
...@@ -717,7 +717,7 @@ class SessionRestoreImpl : public BrowserListObserver { ...@@ -717,7 +717,7 @@ class SessionRestoreImpl : public BrowserListObserver {
// The quit-closure to terminate the nested message-loop started for // The quit-closure to terminate the nested message-loop started for
// synchronous session-restore. // synchronous session-restore.
base::Closure quit_closure_for_sync_restore_; base::OnceClosure quit_closure_for_sync_restore_;
// See description of CLOBBER_CURRENT_TAB. // See description of CLOBBER_CURRENT_TAB.
const bool clobber_existing_tab_; const bool clobber_existing_tab_;
...@@ -855,8 +855,8 @@ bool SessionRestore::IsRestoringSynchronously() { ...@@ -855,8 +855,8 @@ bool SessionRestore::IsRestoringSynchronously() {
// static // static
SessionRestore::CallbackSubscription SessionRestore::CallbackSubscription
SessionRestore::RegisterOnSessionRestoredCallback( SessionRestore::RegisterOnSessionRestoredCallback(
const base::Callback<void(int)>& callback) { const base::RepeatingCallback<void(int)>& callback) {
return on_session_restored_callbacks()->Add(callback); return on_session_restored_callbacks()->Add(callback);
} }
......
...@@ -50,12 +50,12 @@ class SessionRestore { ...@@ -50,12 +50,12 @@ class SessionRestore {
}; };
// Notification callback list. // Notification callback list.
using CallbackList = base::CallbackList<void(int)>; using CallbackList = base::RepeatingCallbackList<void(int)>;
// Used by objects calling RegisterOnSessionRestoredCallback() to de-register // Used by objects calling RegisterOnSessionRestoredCallback() to de-register
// themselves when they are destroyed. // themselves when they are destroyed.
using CallbackSubscription = using CallbackSubscription =
std::unique_ptr<base::CallbackList<void(int)>::Subscription>; std::unique_ptr<base::RepeatingCallbackList<void(int)>::Subscription>;
// Restores the last session. |behavior| is a bitmask of Behaviors, see it // Restores the last session. |behavior| is a bitmask of Behaviors, see it
// for details. If |browser| is non-null the tabs for the first window are // for details. If |browser| is non-null the tabs for the first window are
...@@ -103,7 +103,7 @@ class SessionRestore { ...@@ -103,7 +103,7 @@ class SessionRestore {
// have not necessarily finished loading. The integer supplied to the callback // have not necessarily finished loading. The integer supplied to the callback
// indicates the number of tabs that were created. // indicates the number of tabs that were created.
static CallbackSubscription RegisterOnSessionRestoredCallback( static CallbackSubscription RegisterOnSessionRestoredCallback(
const base::Callback<void(int)>& callback); const base::RepeatingCallback<void(int)>& callback);
// Add/remove an observer to/from this session restore. // Add/remove an observer to/from this session restore.
static void AddObserver(SessionRestoreObserver* observer); static void AddObserver(SessionRestoreObserver* observer);
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
SessionRestoreTestHelper::SessionRestoreTestHelper() SessionRestoreTestHelper::SessionRestoreTestHelper()
: restore_notification_seen_(false), loop_is_running_(false) { : restore_notification_seen_(false), loop_is_running_(false) {
callback_subscription_ = SessionRestore::RegisterOnSessionRestoredCallback( callback_subscription_ = SessionRestore::RegisterOnSessionRestoredCallback(
base::Bind(&SessionRestoreTestHelper::OnSessionRestoreDone, base::BindRepeating(&SessionRestoreTestHelper::OnSessionRestoreDone,
weak_ptr_factory.GetWeakPtr())); weak_ptr_factory.GetWeakPtr()));
} }
SessionRestoreTestHelper::~SessionRestoreTestHelper() { SessionRestoreTestHelper::~SessionRestoreTestHelper() {
......
...@@ -205,7 +205,8 @@ void TabLoader::SetAllTabsScored(bool all_tabs_scored) { ...@@ -205,7 +205,8 @@ void TabLoader::SetAllTabsScored(bool all_tabs_scored) {
TabLoader::TabLoader() TabLoader::TabLoader()
: memory_pressure_listener_( : memory_pressure_listener_(
FROM_HERE, FROM_HERE,
base::Bind(&TabLoader::OnMemoryPressure, base::Unretained(this))), base::BindRepeating(&TabLoader::OnMemoryPressure,
base::Unretained(this))),
clock_(GetDefaultTickClock()) { clock_(GetDefaultTickClock()) {
shared_tab_loader_ = this; shared_tab_loader_ = this;
this_retainer_ = this; this_retainer_ = this;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment