Commit 0104e426 authored by Matt Falkenhagen's avatar Matt Falkenhagen Committed by Commit Bot

browsing data: Make test utils ServiceWorkerOnUI-aware.

The thread ServiceWorkerContextCore lives on (the "core thread") will
move from the IO thread to the UI thread when the ServiceWorkerOnUI
feature is enabled.

This CL makes browsing_data test utils aware of the core thread
instead of assuming the IO thread.

Bug: 824858
Change-Id: Idd9d32610776c9b7c48003564dc5e9407a467e8c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1786458Reviewed-by: default avatarMartin Šrámek <msramek@chromium.org>
Commit-Queue: Matt Falkenhagen <falken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#693644}
parent 1a4c99ff
......@@ -15,6 +15,7 @@
#include "components/network_session_configurator/common/network_switches.h"
#include "content/browser/browsing_data/browsing_data_test_utils.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/service_worker_context.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/storage_usage_info.h"
#include "content/public/browser/system_connector.h"
......@@ -99,16 +100,16 @@ void AddServiceWorker(const std::string& origin,
blink::mojom::ServiceWorkerRegistrationOptions options(
scope_url, blink::mojom::ScriptType::kClassic,
blink::mojom::ServiceWorkerUpdateViaCache::kImports);
base::PostTask(
FROM_HERE, {BrowserThread::IO},
RunOrPostTaskOnThread(
FROM_HERE, ServiceWorkerContext::GetCoreThreadId(),
base::BindOnce(&ServiceWorkerContextWrapper::RegisterServiceWorker,
base::Unretained(service_worker_context), js_url, options,
base::Bind(&AddServiceWorkerCallback)));
// Wait for its activation.
base::RunLoop run_loop;
base::PostTask(
FROM_HERE, {BrowserThread::IO},
RunOrPostTaskOnThread(
FROM_HERE, ServiceWorkerContext::GetCoreThreadId(),
base::BindOnce(&ServiceWorkerActivationObserver::SignalActivation,
base::Unretained(service_worker_context),
run_loop.QuitClosure()));
......@@ -125,8 +126,8 @@ std::vector<StorageUsageInfo> GetServiceWorkers(
std::vector<StorageUsageInfo> service_workers;
base::RunLoop run_loop;
base::PostTask(
FROM_HERE, {BrowserThread::IO},
RunOrPostTaskOnThread(
FROM_HERE, ServiceWorkerContext::GetCoreThreadId(),
base::BindOnce(
&ServiceWorkerContextWrapper::GetAllOriginsInfo,
base::Unretained(service_worker_context),
......
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