Commit 7b42dacd authored by Matt Falkenhagen's avatar Matt Falkenhagen Committed by Commit Bot

background sync: Prepare for service worker UI thread core (pt 3).

This is a follow-up to r691621. It converts code added since then.

Bug: 824858
Change-Id: I6aa93cc6f5e2da40e51649c4b0052273db316581
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1786878Reviewed-by: default avatarMugdha Lakhani <nator@chromium.org>
Commit-Queue: Matt Falkenhagen <falken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#693629}
parent 3e79a934
......@@ -128,10 +128,10 @@ void BackgroundSyncBaseBrowserTest::RegistrationPendingOnCoreThread(
std::move(callback)));
}
void BackgroundSyncBaseBrowserTest::SetTestClockOnIOThread(
void BackgroundSyncBaseBrowserTest::SetTestClockOnCoreThread(
BackgroundSyncContextImpl* sync_context,
base::SimpleTestClock* clock) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
DCHECK(clock);
BackgroundSyncManager* background_sync_manager =
......@@ -205,19 +205,24 @@ bool BackgroundSyncBaseBrowserTest::RunScript(const std::string& script,
}
void BackgroundSyncBaseBrowserTest::SetTestClock(base::SimpleTestClock* clock) {
base::RunLoop run_loop;
StoragePartitionImpl* storage = GetStorage();
BackgroundSyncContextImpl* sync_context = storage->GetBackgroundSyncContext();
// TODO(crbug.com/824858): Remove the else branch after the feature is
// enabled. Also, try to make a RunOrPostTaskOnThreadAndReply() function so
// the if/else isn't needed.
if (ServiceWorkerContext::IsServiceWorkerOnUIEnabled()) {
SetTestClockOnCoreThread(sync_context, clock);
} else {
base::RunLoop run_loop;
base::PostTaskWithTraitsAndReply(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&BackgroundSyncBaseBrowserTest::SetTestClockOnIOThread,
FROM_HERE, ServiceWorkerContext::GetCoreThreadId(),
base::BindOnce(&BackgroundSyncBaseBrowserTest::SetTestClockOnCoreThread,
base::Unretained(this), base::Unretained(sync_context),
clock),
run_loop.QuitClosure());
run_loop.Run();
}
}
void BackgroundSyncBaseBrowserTest::ClearStoragePartitionData() {
......
......@@ -99,7 +99,7 @@ class BackgroundSyncBaseBrowserTest : public ContentBrowserTest {
const GURL& url,
base::OnceCallback<void(bool)> callback);
StoragePartitionImpl* GetStorage();
void SetTestClockOnIOThread(BackgroundSyncContextImpl* sync_context,
void SetTestClockOnCoreThread(BackgroundSyncContextImpl* sync_context,
base::SimpleTestClock* clock);
Shell* shell_ = nullptr;
......
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