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( ...@@ -128,10 +128,10 @@ void BackgroundSyncBaseBrowserTest::RegistrationPendingOnCoreThread(
std::move(callback))); std::move(callback)));
} }
void BackgroundSyncBaseBrowserTest::SetTestClockOnIOThread( void BackgroundSyncBaseBrowserTest::SetTestClockOnCoreThread(
BackgroundSyncContextImpl* sync_context, BackgroundSyncContextImpl* sync_context,
base::SimpleTestClock* clock) { base::SimpleTestClock* clock) {
DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
DCHECK(clock); DCHECK(clock);
BackgroundSyncManager* background_sync_manager = BackgroundSyncManager* background_sync_manager =
...@@ -205,19 +205,24 @@ bool BackgroundSyncBaseBrowserTest::RunScript(const std::string& script, ...@@ -205,19 +205,24 @@ bool BackgroundSyncBaseBrowserTest::RunScript(const std::string& script,
} }
void BackgroundSyncBaseBrowserTest::SetTestClock(base::SimpleTestClock* clock) { void BackgroundSyncBaseBrowserTest::SetTestClock(base::SimpleTestClock* clock) {
base::RunLoop run_loop;
StoragePartitionImpl* storage = GetStorage(); StoragePartitionImpl* storage = GetStorage();
BackgroundSyncContextImpl* sync_context = storage->GetBackgroundSyncContext(); BackgroundSyncContextImpl* sync_context = storage->GetBackgroundSyncContext();
base::PostTaskWithTraitsAndReply( // TODO(crbug.com/824858): Remove the else branch after the feature is
FROM_HERE, {BrowserThread::IO}, // enabled. Also, try to make a RunOrPostTaskOnThreadAndReply() function so
base::BindOnce(&BackgroundSyncBaseBrowserTest::SetTestClockOnIOThread, // the if/else isn't needed.
base::Unretained(this), base::Unretained(sync_context), if (ServiceWorkerContext::IsServiceWorkerOnUIEnabled()) {
clock), SetTestClockOnCoreThread(sync_context, clock);
run_loop.QuitClosure()); } else {
base::RunLoop run_loop;
run_loop.Run(); base::PostTaskWithTraitsAndReply(
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() { void BackgroundSyncBaseBrowserTest::ClearStoragePartitionData() {
......
...@@ -99,8 +99,8 @@ class BackgroundSyncBaseBrowserTest : public ContentBrowserTest { ...@@ -99,8 +99,8 @@ class BackgroundSyncBaseBrowserTest : public ContentBrowserTest {
const GURL& url, const GURL& url,
base::OnceCallback<void(bool)> callback); base::OnceCallback<void(bool)> callback);
StoragePartitionImpl* GetStorage(); StoragePartitionImpl* GetStorage();
void SetTestClockOnIOThread(BackgroundSyncContextImpl* sync_context, void SetTestClockOnCoreThread(BackgroundSyncContextImpl* sync_context,
base::SimpleTestClock* clock); base::SimpleTestClock* clock);
Shell* shell_ = nullptr; Shell* shell_ = nullptr;
std::unique_ptr<net::EmbeddedTestServer> https_server_; std::unique_ptr<net::EmbeddedTestServer> https_server_;
......
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