Commit 1b153503 authored by Gabriel Charette's avatar Gabriel Charette Committed by Commit Bot

Use modern base APIs to avoid base::MessageLoop::current() calls in /chrome/browser/sessions

This is a precusor cleanup extracted from
https://chromium-review.googlesource.com/c/chromium/src/+/957760/7
in the broader effort to restrict usage of MessageLoop::current().

This CL was uploaded by git cl split.

R=sky@chromium.org

Bug: 825327
Change-Id: Icf533bc3f199e16156ab0ec895ff5b2684b95967
Reviewed-on: https://chromium-review.googlesource.com/986746Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#547718}
parent d68f6dc4
...@@ -986,12 +986,6 @@ void OnGotPreviousSession( ...@@ -986,12 +986,6 @@ void OnGotPreviousSession(
FAIL() << "SessionService was destroyed, this shouldn't be reached."; FAIL() << "SessionService was destroyed, this shouldn't be reached.";
} }
void PostBackToThread(base::MessageLoop* message_loop,
base::RunLoop* run_loop) {
message_loop->task_runner()->PostTask(
FROM_HERE, base::Bind(&base::RunLoop::Quit, base::Unretained(run_loop)));
}
// Blocks until |keep_waiting| is false. // Blocks until |keep_waiting| is false.
void SimulateWaitForTesting(const base::AtomicFlag* flag) { void SimulateWaitForTesting(const base::AtomicFlag* flag) {
// Ideally this code would use WaitableEvent, but that triggers a DCHECK in // Ideally this code would use WaitableEvent, but that triggers a DCHECK in
...@@ -1024,11 +1018,7 @@ TEST_F(SessionServiceTest, GetSessionsAndDestroy) { ...@@ -1024,11 +1018,7 @@ TEST_F(SessionServiceTest, GetSessionsAndDestroy) {
FROM_HERE, base::Bind(&SimulateWaitForTesting, base::Unretained(&flag))); FROM_HERE, base::Bind(&SimulateWaitForTesting, base::Unretained(&flag)));
service()->GetLastSession(base::Bind(&OnGotPreviousSession), service()->GetLastSession(base::Bind(&OnGotPreviousSession),
&cancelable_task_tracker); &cancelable_task_tracker);
helper_.RunTaskOnBackendThread( helper_.RunTaskOnBackendThread(FROM_HERE, run_loop.QuitClosure());
FROM_HERE,
base::Bind(&PostBackToThread,
base::Unretained(base::MessageLoop::current()),
base::Unretained(&run_loop)));
delete helper_.ReleaseService(); delete helper_.ReleaseService();
flag.Set(); flag.Set();
run_loop.Run(); run_loop.Run();
......
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