0

content: Replace uses of BrowserThread task posting with post_task.h API

This patch updates callsites of BrowserThread task posting methods to
use the post_task.h API instead.

Background: We're changing the way tasks are posted to a BrowserThread,
see PSA [1] and design doc [2]. This unifies the way tasks are posted
and paves the way for annotating tasks with task types and other
attributes that can be used to prioritize tasks in the future browser
UI thread scheduler (design doc [3]).

This CL changes callsites of the following forms:
(a) BrowserThread::Post*Task(BrowserThread::UI/IO, ..) to
    base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI/IO}, ..),
(b) BrowserThread::GetTaskRunnerForThread(BrowserThread::UI/IO) to
    base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::UI/IO}).

It also adds necessary includes. These mechanical changes were applied
by a script.

Tasks posted with the same BrowserThread::ID trait (via
PostTaskWithTraits or TaskRunners obtained from
Create*TaskRunnerWithTraits) will still execute in the order they
were posted, see [4].

[1] https://groups.google.com/a/chromium.org/d/topic/chromium-dev/A3_snMVXv8A/discussion
[2] https://docs.google.com/document/d/1SGy9VTXUwyXEX_yBZ0ukFAnS8B0hDeMUJD-1iALaE-Q/edit?usp=sharing
[3] https://docs.google.com/document/d/1z1BDq9vzcEpkhN9LSPF5XMnZ0kLJ8mWWkNAi4OI7cos/edit?usp=sharing
[4] https://cs.chromium.org/chromium/src/base/task/post_task.h?l=66

TBR=achuith@chromium.org, afakhry@chromium.org, agl@chromium.org, avi@chromium.org, bbudge@chromium.org, bengr@chromium.org, benwells@chromium.org, bnc@chromium.org, calamity@chromium.org, ccameron@chromium.org, chiniforooshan@chromium.org, cjgrant@chromium.org, cmumford@chromium.org, csharrison@chromium.org, dalecurtis@chromium.org, delphick@chromium.org, dgozman@chromium.org, dmazzoni@chromium.org, droger@chromium.org, dschuff@chromium.org, dullweber@chromium.org, erikchen@chromium.org, felt@chromium.org, fgorski@chromium.org, gogerald@chromium.org, groby@chromium.org, horo@chromium.org, imcheng@chromium.org, jcivelli@chromium.org, jianli@chromium.org, jinho.bang@samsung.com, jkarlin@chromium.org, jochen@chromium.org, kinuko@chromium.org, lazyboy@chromium.org, lpy@chromium.org, markusheintz@chromium.org, mattcary@chromium.org, maxmorin@chromium.org, miu@chromium.org, mkwst@chromium.org, mmenke@chromium.org, mpearson@chromium.org, msramek@chromium.org, nick@chromium.org, nparker@chromium.org, nyquist@chromium.org, peter@chromium.org, pwnall@chromium.org, qinmin@chromium.org, rbpotter@chromium.org, rdevlin.cronin@chromium.org, rouslan@chromium.org, scottmg@chromium.org, servolk@chromium.org, skuhne@chromium.org, sky@chromium.org, tapted@chromium.org, tbansal@chromium.org, thestig@chromium.org, tommi@chromium.org, tommycli@chromium.org, torne@chromium.org, tschumann@chromium.org, vabr@chromium.org, vakh@chromium.org, waffles@chromium.org, yfriedman@chromium.org, zmo@chromium.org, bartfab@chromium.org

Bug: 878356
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:linux_vr;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: I37526c8e75630ee7bec29421276094a30e903894
Reviewed-on: https://chromium-review.googlesource.com/1186623
Reviewed-by: Eric Seckler <eseckler@chromium.org>
Reviewed-by: Vaclav Brozek <vabr@chromium.org>
Reviewed-by: Alex Clarke <alexclarke@chromium.org>
Reviewed-by: Sami Kyöstilä <skyostil@chromium.org>
Commit-Queue: Eric Seckler <eseckler@chromium.org>
Cr-Commit-Position: refs/heads/master@{#592750}
This commit is contained in:
Eric Seckler
2018-09-20 10:42:28 +00:00
committed by Commit Bot
parent 860a3b3343
commit 8652dcd5d8
936 changed files with 6758 additions and 5205 deletions
android_webview/browser
apps
chrome
browser
after_startup_task_utils.ccafter_startup_task_utils_unittest.cc
android
apps
background
bookmarks
browser_process_impl.cc
browsing_data
captive_portal
certificate_manager_model.ccchrome_browser_main.ccchrome_browser_main_linux.ccchrome_browser_main_posix.ccchrome_browser_main_win.ccchrome_content_browser_client.ccchrome_content_browser_client_browsertest_chromeos.ccchrome_plugin_browsertest.ccchrome_quota_permission_context.ccchrome_service.ccchrome_service_worker_browsertest.ccchrome_site_per_process_browsertest.cc
chromeos
accessibility
android_sms
app_mode
apps
arc
attestation
base
boot_times_recorder.ccchrome_browser_main_chromeos.cc
crostini
customization
dbus
drive
extensions
external_metrics.cc
file_manager
file_system_provider
fileapi
login
mobile
net
ownership
platform_keys
policy
power
printing
proxy_config_service_impl_unittest.cc
system_logs
component_updater
content_settings
custom_handlers
data_use_measurement
devtools
download
engagement
extensions
activity_log
api
background_xhr_browsertest.ccblacklist.ccchrome_content_browser_client_extensions_part.cccrx_installer.ccdata_deleter.ccevent_router_forwarder.ccevent_router_forwarder_unittest.ccextension_assets_manager_chromeos.ccextension_gcm_app_handler_unittest.ccextension_messages_apitest.ccextension_service.ccextension_special_storage_policy.ccextension_storage_monitor.ccextension_system_impl.ccexternal_pref_loader.ccexternal_pref_loader_unittest.ccexternal_registry_loader_win.ccstartup_helper.ccunpacked_installer.cc
updater
feedback
file_select_helper.ccfile_select_helper_mac.mm
gcm
google
history
icon_loader_auralinux.ccicon_loader_chromeos.ccimage_decoder.ccio_thread.cc
lifetime
loader
local_discovery
media
media_galleries
memory_details.ccmemory_details_android.ccmemory_details_linux.ccmemory_details_mac.ccmemory_details_win.cc
metrics
nacl_host
net
notifications
offline_pages
password_manager
pdf
pepper_flash_settings_manager.cc
performance_monitor
permissions
platform_util.ccplatform_util_mac.mm
plugins
policy
predictors
prerender
previews
printing
process_resource_usage.hprocess_singleton_posix.ccprocess_singleton_posix_unittest.cc
profile_resetter
profiles
profiling_host
push_messaging
renderer_host
resource_coordinator
safe_browsing
search
service_process
shell_integration.cc
signin
speech
spellchecker
ssl
storage
subresource_filter
supervised_user
sync
sync_file_system
task_manager
thumbnails
tracing
ui
unload_browsertest.cc
vr
web_applications
web_data_service_factory.cc
win
renderer
services
test
chromecast/browser
components
content
browser
accessibility
android
appcache
background_fetch
background_sync
bad_message.cc
blob_storage
browser_associated_interface_unittest.ccbrowser_child_process_host_impl.ccbrowser_context.ccbrowser_ipc_logging.ccbrowser_main_loop.cc
browsing_data
byte_stream.h
cache_storage
child_process_launcher_helper.ccchild_process_launcher_helper_android.cc
cocoa
code_cache
compositor
cookie_store
devtools
dom_storage
download
fileapi
frame_host
gpu
gpu_interface_provider.cchistogram_controller.cchistogram_synchronizer.cc
image_capture
indexed_db
interface_provider_filtering.cc
loader
mach_broker_mac.mm
manifest
media
memory
mojo_sandbox_browsertest.ccnavigation_browsertest.cc
net
network_service_client.ccnetwork_service_instance.cc
notifications
payments
plugin_data_remover_impl.ccplugin_private_storage_helper.ccplugin_service_impl.ccplugin_service_impl_browsertest.ccpower_monitor_browsertest.cc
push_messaging
quota_dispatcher_host.cc
renderer_host
compositor_impl_android.cc
media
pepper
render_message_filter.ccrender_process_host_browsertest.ccrender_process_host_impl.ccrender_process_host_impl.hrender_view_host_impl.ccrender_widget_helper.ccrender_widget_host_view_mac_unittest.mmweb_database_host_impl.cc
scheduler
security_exploit_browsertest.cc
service_manager
service_worker
shared_worker
site_per_process_browsertest.ccsite_per_process_hit_test_browsertest.ccsite_per_process_mac_browsertest.mm
speech
ssl
storage_partition_impl.ccstorage_partition_impl_map.ccstorage_partition_impl_unittest.cc
streams
tracing
url_loader_factory_getter.ccutility_process_host.ccutility_process_host_browsertest.cc
web_contents
web_package
webrtc
websockets
webui
public
renderer
shell
test
extensions
browser
shell
headless
ppapi/host
webrunner/browser

@ -28,6 +28,7 @@
#include "components/url_formatter/url_fixer.h"
#include "components/user_prefs/user_prefs.h"
#include "components/visitedlink/browser/visitedlink_master.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/ssl_host_state_delegate.h"
#include "content/public/browser/storage_partition.h"
@ -66,7 +67,7 @@ AwBrowserContext* g_browser_context = NULL;
std::unique_ptr<net::ProxyConfigServiceAndroid> CreateProxyConfigService() {
std::unique_ptr<net::ProxyConfigServiceAndroid> config_service_android =
std::make_unique<net::ProxyConfigServiceAndroid>(
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::IO}),
base::ThreadTaskRunnerHandle::Get());
// TODO(csharrison) Architect the wrapper better so we don't need a cast for
@ -82,7 +83,7 @@ CreateSafeBrowsingWhitelistManager() {
base::CreateSequencedTaskRunnerWithTraits(
{base::MayBlock(), base::TaskPriority::BEST_EFFORT});
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner =
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO);
base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::IO});
return std::make_unique<AwSafeBrowsingWhitelistManager>(
background_task_runner, io_task_runner);
}

@ -16,6 +16,7 @@
#include "base/sync_socket.h"
#include "base/task/post_task.h"
#include "components/crash/content/browser/crash_dump_manager_android.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_data.h"
#include "content/public/browser/child_process_launcher_utils.h"
@ -153,8 +154,8 @@ void AwBrowserTerminator::OnChildExitAsync(
crashed = true;
}
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&OnRenderProcessGoneDetail, info.process_host_id, info.pid,
crashed));
}

@ -41,6 +41,7 @@
#include "base/memory/ptr_util.h"
#include "base/path_service.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/post_task.h"
#include "components/autofill/content/browser/content_autofill_driver_factory.h"
#include "components/cdm/browser/cdm_message_filter_android.h"
#include "components/crash/content/browser/child_exit_observer_android.h"
@ -53,6 +54,7 @@
#include "components/services/heap_profiling/public/mojom/constants.mojom.h"
#include "components/spellcheck/spellcheck_buildflags.h"
#include "content/public/browser/browser_message_filter.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/client_certificate_delegate.h"
@ -605,12 +607,12 @@ void AwContentBrowserClient::ExposeInterfacesToRenderer(
base::BindRepeating(
&AwContentBrowserClient::GetSafeBrowsingUrlCheckerDelegate,
base::Unretained(this))),
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO));
base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::IO}));
}
#if BUILDFLAG(ENABLE_SPELLCHECK)
registry->AddInterface(
base::BindRepeating(&SpellCheckHostImpl::Create),
BrowserThread::GetTaskRunnerForThread(BrowserThread::UI));
base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::UI}));
#endif
}

@ -54,6 +54,7 @@
#include "base/single_thread_task_runner.h"
#include "base/strings/string16.h"
#include "base/supports_user_data.h"
#include "base/task/post_task.h"
#include "base/threading/thread_restrictions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "components/autofill/android/autofill_provider_android.h"
@ -63,6 +64,7 @@
#include "components/navigation_interception/intercept_navigation_delegate.h"
#include "content/public/browser/android/child_process_importance.h"
#include "content/public/browser/android/synchronous_compositor.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/browsing_data_remover.h"
#include "content/public/browser/child_process_security_policy.h"
@ -235,7 +237,7 @@ AwContents::AwContents(std::unique_ptr<WebContents> web_contents)
functor_(nullptr),
browser_view_renderer_(
this,
BrowserThread::GetTaskRunnerForThread(BrowserThread::UI)),
base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::UI})),
web_contents_(std::move(web_contents)),
renderer_manager_key_(GLViewRendererManager::GetInstance()->NullKey()) {
base::subtle::NoBarrier_AtomicIncrement(&g_instance_count, 1);
@ -586,8 +588,8 @@ void ShowGeolocationPromptHelper(const JavaObjectWeakGlobalRef& java_ref,
const GURL& origin) {
JNIEnv* env = AttachCurrentThread();
if (java_ref.get(env).obj()) {
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&ShowGeolocationPromptHelperTask, java_ref, origin));
}
}

@ -11,9 +11,11 @@
#include "base/android/jni_string.h"
#include "base/android/scoped_java_ref.h"
#include "base/callback.h"
#include "base/task/post_task.h"
#include "components/google/core/common/google_util.h"
#include "components/security_interstitials/core/urls.h"
#include "components/version_info/version_info.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/common/url_constants.h"
@ -73,8 +75,8 @@ void JNI_AwContentsStatics_ClearClientCertPreferences(
const JavaParamRef<jclass>&,
const JavaParamRef<jobject>& callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
BrowserThread::PostTaskAndReply(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraitsAndReply(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&NotifyClientCertificatesChanged),
base::BindOnce(&ClientCertificatesCleared,
ScopedJavaGlobalRef<jobject>(env, callback)));

@ -5,6 +5,8 @@
#include "android_webview/browser/aw_gl_functor.h"
#include "android_webview/public/browser/draw_gl.h"
#include "base/task/post_task.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "jni/AwGLFunctor_jni.h"
@ -35,7 +37,7 @@ AwGLFunctor::AwGLFunctor(const JavaObjectWeakGlobalRef& java_ref)
: java_ref_(java_ref),
render_thread_manager_(
this,
BrowserThread::GetTaskRunnerForThread(BrowserThread::UI)) {
base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::UI})) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
++g_instance_count;
}

@ -8,6 +8,8 @@
#include "base/android/jni_android.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/task/post_task.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
@ -28,8 +30,8 @@ scoped_refptr<AwLoginDelegate> AwLoginDelegate::Create(
LoginAuthRequiredCallback auth_required_callback) {
scoped_refptr<AwLoginDelegate> instance(
new AwLoginDelegate(auth_info, std::move(auth_required_callback)));
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&AwLoginDelegate::HandleHttpAuthRequestOnUIThread,
instance, first_auth_attempt, web_contents_getter));
return instance;
@ -50,15 +52,15 @@ AwLoginDelegate::~AwLoginDelegate() {
void AwLoginDelegate::Proceed(const base::string16& user,
const base::string16& password) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
base::BindOnce(&AwLoginDelegate::ProceedOnIOThread,
this, user, password));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::IO},
base::BindOnce(&AwLoginDelegate::ProceedOnIOThread,
this, user, password));
}
void AwLoginDelegate::Cancel() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&AwLoginDelegate::CancelOnIOThread, this));
}
@ -102,8 +104,8 @@ void AwLoginDelegate::OnRequestCancelled() {
void AwLoginDelegate::DeleteAuthHandlerSoon() {
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&AwLoginDelegate::DeleteAuthHandlerSoon, this));
return;
}

@ -12,6 +12,8 @@
#include "base/android/jni_string.h"
#include "base/memory/scoped_refptr.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/post_task.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/common/content_client.h"
@ -82,8 +84,8 @@ GetOriginsTask::~GetOriginsTask() {}
void GetOriginsTask::Run() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&QuotaManager::GetOriginsModifiedSince, quota_manager_,
blink::mojom::StorageType::kTemporary,
base::Time() /* Since beginning of time. */,
@ -126,8 +128,8 @@ void GetOriginsTask::OnUsageAndQuotaObtained(
void GetOriginsTask::CheckDone() {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (num_callbacks_received_ == num_callbacks_to_wait_) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&GetOriginsTask::DoneOnUIThread, this));
} else if (num_callbacks_received_ > num_callbacks_to_wait_) {
NOTREACHED();
@ -144,7 +146,7 @@ void RunOnUIThread(base::OnceClosure task) {
if (BrowserThread::CurrentlyOn(BrowserThread::UI)) {
std::move(task).Run();
} else {
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, std::move(task));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI}, std::move(task));
}
}
@ -286,8 +288,9 @@ void OnUsageAndQuotaObtained(
usage = 0;
quota = 0;
}
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::BindOnce(std::move(ui_callback), usage, quota));
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(std::move(ui_callback), usage, quota));
}
} // namespace
@ -314,8 +317,8 @@ void AwQuotaManagerBridge::GetUsageAndQuotaForOriginOnUiThread(
base::BindOnce(&AwQuotaManagerBridge::QuotaUsageCallbackImpl,
weak_factory_.GetWeakPtr(), callback_id, is_quota);
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(
&QuotaManager::GetUsageAndQuota, GetQuotaManager(), GURL(origin),
blink::mojom::StorageType::kTemporary,

@ -11,6 +11,7 @@
#include "base/command_line.h"
#include "base/metrics/histogram_macros.h"
#include "base/path_service.h"
#include "base/task/post_task.h"
#include "components/prefs/pref_service.h"
#include "components/safe_browsing/base_ui_manager.h"
#include "components/safe_browsing/browser/safe_browsing_network_context.h"
@ -18,6 +19,7 @@
#include "components/safe_browsing/common/safebrowsing_constants.h"
#include "components/safe_browsing/db/v4_protocol_manager_util.h"
#include "components/safe_browsing/ping_manager.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "services/network/public/cpp/features.h"
#include "services/network/public/mojom/network_service.mojom.h"
@ -105,8 +107,8 @@ scoped_refptr<network::SharedURLLoaderFactory>
AwSafeBrowsingUIManager::GetURLLoaderFactoryOnIOThread() {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (!shared_url_loader_factory_on_io_) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&AwSafeBrowsingUIManager::CreateURLLoaderFactoryForIO,
this, MakeRequest(&url_loader_factory_on_io_)));
shared_url_loader_factory_on_io_ =

@ -10,10 +10,12 @@
#include "android_webview/browser/aw_safe_browsing_whitelist_manager.h"
#include "android_webview/browser/net/aw_web_resource_request.h"
#include "base/bind.h"
#include "base/task/post_task.h"
#include "components/safe_browsing/db/database_manager.h"
#include "components/safe_browsing/db/v4_protocol_manager_util.h"
#include "components/security_interstitials/content/unsafe_resource.h"
#include "components/security_interstitials/core/urls.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/web_contents.h"
@ -46,8 +48,8 @@ void AwUrlCheckerDelegateImpl::StartDisplayingBlockingPageHelper(
AwWebResourceRequest request(resource.url.spec(), method, is_main_frame,
has_user_gesture, headers);
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&AwUrlCheckerDelegateImpl::StartApplicationResponse,
ui_manager_, resource, std::move(request)));
}
@ -128,8 +130,8 @@ void AwUrlCheckerDelegateImpl::DoApplicationResponse(
bool proceed;
switch (action) {
case SafeBrowsingAction::SHOW_INTERSTITIAL:
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(
&AwUrlCheckerDelegateImpl::StartDisplayingDefaultBlockingPage,
ui_manager, resource));
@ -175,8 +177,8 @@ void AwUrlCheckerDelegateImpl::StartDisplayingDefaultBlockingPage(
}
// Reporting back that it is not okay to proceed with loading the URL.
content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE,
base::BindOnce(resource.callback, false));
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(resource.callback, false));
}
} // namespace android_webview

@ -10,6 +10,8 @@
#include "android_webview/browser/aw_cookie_access_policy.h"
#include "android_webview/browser/net/aw_web_resource_request.h"
#include "base/android/build_info.h"
#include "base/task/post_task.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/resource_request_info.h"
#include "net/base/completion_once_callback.h"
@ -79,8 +81,8 @@ int AwNetworkDelegate::OnHeadersReceived(
std::unique_ptr<AwContentsClientBridge::HttpErrorInfo> error_info =
AwContentsClientBridge::ExtractHttpErrorInfo(original_response_headers);
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&OnReceivedHttpErrorOnUiThread,
request_info->GetWebContentsGetterForRequest(),
AwWebResourceRequest(*request), std::move(error_info)));

@ -31,6 +31,7 @@
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
#include "components/version_info/version_info.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/cookie_store_factory.h"
@ -194,7 +195,7 @@ AwURLRequestContextGetter::AwURLRequestContextGetter(
DCHECK_CURRENTLY_ON(BrowserThread::UI);
scoped_refptr<base::SingleThreadTaskRunner> io_thread_proxy =
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO);
base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::IO});
auth_server_whitelist_.Init(
prefs::kAuthServerWhitelist, user_pref_service,
@ -370,7 +371,7 @@ net::URLRequestContext* AwURLRequestContextGetter::GetURLRequestContext() {
scoped_refptr<base::SingleThreadTaskRunner>
AwURLRequestContextGetter::GetNetworkTaskRunner() const {
return BrowserThread::GetTaskRunnerForThread(BrowserThread::IO);
return base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::IO});
}
void AwURLRequestContextGetter::SetHandlersAndInterceptors(

@ -9,7 +9,9 @@
#include "base/android/jni_android.h"
#include "base/files/scoped_temp_dir.h"
#include "base/memory/ref_counted.h"
#include "base/task/post_task.h"
#include "components/prefs/testing_pref_service.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/common/url_constants.h"
#include "content/public/test/test_browser_thread_bundle.h"
@ -67,8 +69,8 @@ class AwURLRequestContextGetterTest : public ::testing::Test {
std::unique_ptr<net::ProxyConfigServiceAndroid> config_service_android;
config_service_android.reset(static_cast<net::ProxyConfigServiceAndroid*>(
net::ProxyResolutionService::CreateSystemProxyConfigService(
content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::IO))
base::CreateSingleThreadTaskRunnerWithTraits(
{content::BrowserThread::IO}))
.release()));
getter_ = base::MakeRefCounted<android_webview::AwURLRequestContextGetter>(

@ -6,6 +6,8 @@
#include "android_webview/browser/aw_browser_context.h"
#include "base/callback_helpers.h"
#include "base/task/post_task.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
#include "net/ssl/channel_id_service.h"
@ -25,14 +27,14 @@ void CompletionCallback(TokenBindingManager::KeyReadyCallback callback,
ChannelIDService::Request* request,
std::unique_ptr<crypto::ECPrivateKey>* key,
int status) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(std::move(callback), status, base::Owned(key->release())));
}
void DeletionCompleteCallback(
TokenBindingManager::DeletionCompleteCallback callback) {
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, std::move(callback));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI}, std::move(callback));
}
void GetKeyImpl(const std::string& host,
@ -56,8 +58,8 @@ void GetKeyImpl(const std::string& host,
// The operation is pending, callback will be called async.
return;
}
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
base::BindOnce(completion_callback, status));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::IO},
base::BindOnce(completion_callback, status));
}
void DeleteKeyImpl(const std::string& host,
@ -93,8 +95,8 @@ void TokenBindingManager::GetKey(const std::string& host,
scoped_refptr<net::URLRequestContextGetter> context_getter =
content::BrowserContext::GetDefaultStoragePartition(
AwBrowserContext::GetDefault())->GetURLRequestContext();
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&GetKeyImpl, host, std::move(callback), context_getter));
}
@ -103,8 +105,8 @@ void TokenBindingManager::DeleteKey(const std::string& host,
scoped_refptr<net::URLRequestContextGetter> context_getter =
content::BrowserContext::GetDefaultStoragePartition(
AwBrowserContext::GetDefault())->GetURLRequestContext();
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&DeleteKeyImpl, host, std::move(callback), context_getter,
false));
}
@ -113,8 +115,8 @@ void TokenBindingManager::DeleteAllKeys(DeletionCompleteCallback callback) {
scoped_refptr<net::URLRequestContextGetter> context_getter =
content::BrowserContext::GetDefaultStoragePartition(
AwBrowserContext::GetDefault())->GetURLRequestContext();
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&DeleteKeyImpl, "", std::move(callback), context_getter,
true));
}

@ -16,9 +16,11 @@
#include "android_webview/browser/net/aw_web_resource_request.h"
#include "android_webview/browser/renderer_host/auto_login_parser.h"
#include "android_webview/common/url_constants.h"
#include "base/task/post_task.h"
#include "components/safe_browsing/android/safe_browsing_api_handler.h"
#include "components/safe_browsing/features.h"
#include "components/web_restrictions/browser/web_restrictions_resource_throttle.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/resource_dispatcher_host.h"
#include "content/public/browser/resource_request_info.h"
@ -346,8 +348,8 @@ void AwResourceDispatcherHostDelegate::RequestComplete(
if (IsCancelledBySafeBrowsing(request)) {
safebrowsing_hit = true;
}
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&OnReceivedErrorOnUiThread,
request_info->GetWebContentsGetterForRequest(),
AwWebResourceRequest(*request),
@ -388,8 +390,8 @@ void AwResourceDispatcherHostDelegate::DownloadStarting(
const content::ResourceRequestInfo* request_info =
content::ResourceRequestInfo::ForRequest(request);
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&DownloadStartingOnUIThread,
request_info->GetWebContentsGetterForRequest(), url,
user_agent, content_disposition, mime_type,
@ -412,8 +414,8 @@ void AwResourceDispatcherHostDelegate::OnResponseStarted(
// Check for x-auto-login header.
HeaderData header_data;
if (ParserHeaderInResponse(request, ALLOW_ANY_REALM, &header_data)) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&NewLoginRequestOnUIThread,
request_info->GetWebContentsGetterForRequest(),
header_data.realm, header_data.account,
@ -437,8 +439,8 @@ void AwResourceDispatcherHostDelegate::RemovePendingThrottleOnIoThread(
void AwResourceDispatcherHostDelegate::OnIoThreadClientReady(
int new_render_process_id,
int new_render_frame_id) {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(
&AwResourceDispatcherHostDelegate::OnIoThreadClientReadyInternal,
base::Unretained(
@ -451,8 +453,8 @@ void AwResourceDispatcherHostDelegate::AddPendingThrottle(
int render_process_id,
int render_frame_id,
IoThreadClientThrottle* pending_throttle) {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(
&AwResourceDispatcherHostDelegate::AddPendingThrottleOnIoThread,
base::Unretained(

@ -10,6 +10,7 @@
#include "base/bind.h"
#include "base/memory/ref_counted_memory.h"
#include "base/task/post_task.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/tracing_controller.h"
@ -44,14 +45,14 @@ class AwTraceDataEndpoint
void ReceiveTraceFinalContents(
std::unique_ptr<const base::DictionaryValue> metadata) override {
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(std::move(completed_callback_), std::move(metadata)));
}
void ReceiveTraceChunk(std::unique_ptr<std::string> chunk) override {
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(received_chunk_callback_, std::move(chunk)));
}

@ -18,6 +18,7 @@
#include "base/task/post_task.h"
#include "base/task/task_traits.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
@ -171,17 +172,16 @@ class PlatformAppPathLauncher
it != entry_paths_.end(); ++it) {
if (!DoMakePathAbsolute(current_directory, &*it)) {
LOG(WARNING) << "Cannot make absolute path from " << it->value();
BrowserThread::PostTask(
BrowserThread::UI,
FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::Bind(&PlatformAppPathLauncher::LaunchWithNoLaunchData, this));
return;
}
}
BrowserThread::PostTask(BrowserThread::UI,
FROM_HERE,
base::Bind(&PlatformAppPathLauncher::Launch, this));
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::Bind(&PlatformAppPathLauncher::Launch, this));
}
void OnFilesValid(std::unique_ptr<std::set<base::FilePath>> directory_paths) {

@ -16,11 +16,13 @@
#include "base/rand_util.h"
#include "base/sequence_checker.h"
#include "base/synchronization/atomic_flag.h"
#include "base/task/post_task.h"
#include "base/task_runner.h"
#include "build/build_config.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
@ -89,8 +91,8 @@ void QueueTask(std::unique_ptr<AfterStartupTask> queued_task) {
CHECK(queued_task->task);
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::BindOnce(QueueTask, std::move(queued_task)));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::BindOnce(QueueTask, std::move(queued_task)));
return;
}
@ -208,8 +210,8 @@ void StartupObserver::Start() {
delay = base::TimeDelta::FromMinutes(kLongerDelayMins);
#endif // !defined(OS_ANDROID)
BrowserThread::PostDelayedTask(
BrowserThread::UI, FROM_HERE,
base::PostDelayedTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&StartupObserver::OnFailsafeTimeout,
weak_factory_.GetWeakPtr()),
delay);

@ -13,6 +13,7 @@
#include "base/run_loop.h"
#include "base/task/post_task.h"
#include "base/task_runner_util.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"
@ -69,8 +70,8 @@ class AfterStartupTaskTest : public testing::Test {
public:
AfterStartupTaskTest() {
ui_thread_ = base::MakeRefCounted<WrappedTaskRunner>(
content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::UI));
base::CreateSingleThreadTaskRunnerWithTraits(
{content::BrowserThread::UI}));
background_sequence_ = base::MakeRefCounted<WrappedTaskRunner>(
base::CreateSequencedTaskRunnerWithTraits(base::TaskTraits()));
AfterStartupTaskUtils::UnsafeResetForTesting();

@ -8,6 +8,7 @@
#include "base/android/jni_string.h"
#include "base/bind.h"
#include "base/logging.h"
#include "base/task/post_task.h"
#include "chrome/browser/android/bookmarks/partner_bookmarks_shim.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/favicon/favicon_service_factory.h"
@ -20,6 +21,7 @@
#include "components/favicon/core/large_icon_service.h"
#include "components/favicon_base/favicon_types.h"
#include "components/image_fetcher/core/image_fetcher.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "jni/PartnerBookmarksReader_jni.h"
#include "third_party/skia/include/core/SkBitmap.h"
@ -90,8 +92,8 @@ void PrepareAndSetFavicon(jbyte* icon_bytes,
base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::Bind(&SetFaviconCallback, profile, node->url(), fake_icon_url,
image_data, icon_type, &event));
// TODO(aruslan): http://b/6397072 If possible - avoid using favicon service
@ -219,8 +221,8 @@ void PartnerBookmarksReader::GetFavicon(const GURL& page_url,
bool fallback_to_server,
int desired_favicon_size_px,
FaviconFetchedCallback callback) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&PartnerBookmarksReader::GetFaviconImpl,
base::Unretained(this), page_url, profile,
fallback_to_server, desired_favicon_size_px,

@ -16,6 +16,7 @@
#include "base/metrics/field_trial_params.h"
#include "base/metrics/histogram_macros.h"
#include "base/synchronization/lock.h"
#include "base/task/post_task.h"
#include "chrome/browser/android/chrome_feature_list.h"
#include "chrome/browser/android/download/dangerous_download_infobar_delegate.h"
#include "chrome/browser/android/download/download_manager_service.h"
@ -29,6 +30,7 @@
#include "chrome/grit/chromium_strings.h"
#include "components/download/public/common/download_url_parameters.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/download_item_utils.h"
#include "content/public/browser/download_manager.h"
@ -269,14 +271,14 @@ void DownloadController::AcquireFileAccessPermission(
StoragePermissionType::STORAGE_PERMISSION_REQUESTED);
RecordStoragePermission(
StoragePermissionType::STORAGE_PERMISSION_NO_ACTION_NEEDED);
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::BindOnce(std::move(cb), true));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::BindOnce(std::move(cb), true));
return;
} else if (vr::VrTabHelper::IsUiSuppressedInVr(
web_contents,
vr::UiSuppressedElement::kFileAccessPermission)) {
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::BindOnce(std::move(cb), false));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::BindOnce(std::move(cb), false));
return;
}
@ -294,11 +296,9 @@ void DownloadController::AcquireFileAccessPermission(
void DownloadController::CreateAndroidDownload(
const content::ResourceRequestInfo::WebContentsGetter& wc_getter,
const DownloadInfo& info) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&DownloadController::StartAndroidDownload,
base::Unretained(this),
wc_getter, info));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::Bind(&DownloadController::StartAndroidDownload,
base::Unretained(this), wc_getter, info));
}
void DownloadController::AboutToResumeDownload(DownloadItem* download_item) {
@ -450,10 +450,9 @@ void DownloadController::OnDangerousDownload(DownloadItem* item) {
auto download_manager_getter = std::make_unique<DownloadManagerGetter>(
BrowserContext::GetDownloadManager(
content::DownloadItemUtils::GetBrowserContext(item)));
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::BindOnce(&RemoveDownloadItem,
std::move(download_manager_getter),
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&RemoveDownloadItem, std::move(download_manager_getter),
item->GetGuid()));
item->RemoveObserver(this);
return;

@ -4,6 +4,8 @@
#include "chrome/browser/android/feedback/process_id_feedback_source.h"
#include "base/task/post_task.h"
#include "content/public/browser/browser_task_traits.h"
#include "jni/ProcessIdFeedbackSource_jni.h"
#include "base/android/jni_array.h"
@ -55,8 +57,8 @@ void ProcessIdFeedbackSource::PrepareProcessIds() {
process_ids_[content::PROCESS_TYPE_RENDERER].push_back(
host->GetProcess().Pid());
}
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&ProcessIdFeedbackSource::PrepareProcessIdsOnIOThread,
this));
}
@ -68,8 +70,8 @@ void ProcessIdFeedbackSource::PrepareProcessIdsOnIOThread() {
process_ids_[iter.GetData().process_type].push_back(
iter.GetData().GetHandle());
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&ProcessIdFeedbackSource::PrepareCompleted, this));
}

@ -11,6 +11,7 @@
#include "base/bind.h"
#include "base/logging.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/post_task.h"
#include "chrome/browser/android/history_report/delta_file_commons.h"
#include "chrome/browser/android/history_report/delta_file_service.h"
#include "chrome/browser/android/history_report/get_all_urls_from_history_task.h"
@ -23,6 +24,7 @@
#include "components/bookmarks/browser/url_and_title.h"
#include "components/history/core/browser/history_db_task.h"
#include "components/history/core/browser/history_service.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
using bookmarks::BookmarkModel;
@ -126,11 +128,9 @@ std::unique_ptr<std::vector<DeltaFileEntryWithData>> DataProvider::Query(
if (!entries->empty()) {
Context context(history_service_,
&history_task_tracker_);
content::BrowserThread::PostTask(
content::BrowserThread::UI,
FROM_HERE,
base::Bind(&QueryUrlsHistoryInUiThread,
base::Unretained(&context),
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::Bind(&QueryUrlsHistoryInUiThread, base::Unretained(&context),
base::Unretained(entries.get())));
std::vector<UrlAndTitle> bookmarks;
bookmark_model_->model_loader()->BlockTillLoaded();
@ -165,12 +165,10 @@ void DataProvider::StartVisitMigrationToUsageBuffer(
base::WaitableEvent finished(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
buffer_service->Clear();
content::BrowserThread::PostTask(
content::BrowserThread::UI,
FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::Bind(&StartVisitMigrationToUsageBufferUiThread,
base::Unretained(history_service_),
buffer_service,
base::Unretained(history_service_), buffer_service,
base::Unretained(&finished),
base::Unretained(&history_task_tracker_)));
finished.Wait();
@ -186,8 +184,8 @@ void DataProvider::RecreateLog() {
std::unique_ptr<history::HistoryDBTask> task =
std::unique_ptr<history::HistoryDBTask>(
new GetAllUrlsFromHistoryTask(&finished, &urls));
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::Bind(base::IgnoreResult(&history::HistoryService::ScheduleDBTask),
base::Unretained(history_service_), FROM_HERE,
base::Passed(&task),

@ -8,6 +8,8 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/post_task.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
// Runs code synchronously on the UI thread. Should never be called directly
@ -22,9 +24,10 @@ class RunOnUIThreadBlocking {
base::WaitableEvent finished(
base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
base::Bind(&RunOnUIThreadBlocking::RunOnUIThread<Signature>,
runnable, &finished));
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::Bind(&RunOnUIThreadBlocking::RunOnUIThread<Signature>, runnable,
&finished));
finished.Wait();
}

@ -19,6 +19,7 @@
#include "base/task/post_task.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "third_party/android_opengl/etc1/etc1.h"
#include "third_party/skia/include/core/SkBitmap.h"
@ -554,8 +555,8 @@ void ThumbnailCache::WriteTask(TabId tab_id,
if (!success)
base::DeleteFile(file_path, false);
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE, post_write_task);
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI},
post_write_task);
}
void ThumbnailCache::PostWriteTask() {
@ -602,9 +603,8 @@ void ThumbnailCache::CompressionTask(
}
}
content::BrowserThread::PostTask(
content::BrowserThread::UI,
FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::Bind(post_compression_task, std::move(compressed_data),
content_size));
}
@ -772,9 +772,8 @@ void ThumbnailCache::ReadTask(
base::Bind(post_read_task, std::move(compressed_data), scale,
content_size));
} else {
content::BrowserThread::PostTask(
content::BrowserThread::UI,
FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::Bind(post_read_task, std::move(compressed_data), scale,
content_size));
}
@ -879,9 +878,8 @@ void ThumbnailCache::DecompressionTask(
}
}
content::BrowserThread::PostTask(
content::BrowserThread::UI,
FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::Bind(post_decompression_callback, success, raw_data_small));
}

@ -13,6 +13,7 @@
#include "base/threading/sequenced_task_runner_handle.h"
#include "components/viz/common/gpu/context_provider.h"
#include "content/public/browser/android/compositor.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "gpu/GLES2/gl2extchromium.h"
#include "gpu/command_buffer/client/context_support.h"
@ -251,8 +252,8 @@ void MailboxToSurfaceBridge::CreateContextProviderInternal() {
base::BindRepeating(&MailboxToSurfaceBridge::OnContextAvailableOnUiThread,
weak_ptr_factory_.GetWeakPtr());
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(
[](int surface_handle,
const content::Compositor::ContextProviderCallback& callback) {

@ -19,6 +19,7 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/mac/app_mode_common.h"
#include "components/version_info/version_info.h"
#include "content/public/browser/browser_task_traits.h"
namespace {
@ -142,7 +143,7 @@ void AppShimHostManager::InitOnBackgroundThread() {
base::CreateSymbolicLink(base::FilePath(version_info::GetVersionNumber()),
version_path);
content::BrowserThread::GetTaskRunnerForThread(content::BrowserThread::IO)
base::CreateSingleThreadTaskRunnerWithTraits({content::BrowserThread::IO})
->PostTask(FROM_HERE,
base::Bind(&AppShimHostManager::ListenOnIOThread, this));
}
@ -150,7 +151,7 @@ void AppShimHostManager::InitOnBackgroundThread() {
void AppShimHostManager::ListenOnIOThread() {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
if (!acceptor_->Listen()) {
content::BrowserThread::GetTaskRunnerForThread(content::BrowserThread::UI)
base::CreateSingleThreadTaskRunnerWithTraits({content::BrowserThread::UI})
->PostTask(FROM_HERE,
base::Bind(&AppShimHostManager::OnListenError, this));
}
@ -159,7 +160,7 @@ void AppShimHostManager::ListenOnIOThread() {
void AppShimHostManager::OnClientConnected(
mojo::PlatformChannelEndpoint endpoint) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
content::BrowserThread::GetTaskRunnerForThread(content::BrowserThread::UI)
base::CreateSingleThreadTaskRunnerWithTraits({content::BrowserThread::UI})
->PostTask(FROM_HERE,
base::BindOnce(&CreateAppShimHost, std::move(endpoint)));
}

@ -9,6 +9,7 @@
#include "base/compiler_specific.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/post_task.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/extension_service.h"
@ -20,6 +21,7 @@
#include "chrome/common/pref_names.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/common/content_switches.h"
#include "extensions/browser/extension_registry.h"
@ -151,8 +153,8 @@ void AppShortcutManager::UpdateShortcutsForAllAppsIfNeeded() {
if (last_version >= kCurrentAppShortcutsVersion)
return;
content::BrowserThread::PostDelayedTask(
content::BrowserThread::UI, FROM_HERE,
base::PostDelayedTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&web_app::UpdateShortcutsForAllApps, profile_,
base::Bind(&SetCurrentAppShortcutsVersion, prefs_)),
base::TimeDelta::FromSeconds(kUpdateShortcutsForAllAppsDelay));

@ -13,6 +13,7 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
using content::BrowserThread;
@ -43,8 +44,8 @@ void CheckForUserRemovedLoginItemOnWorkerThread() {
base::AssertBlockingAllowed();
if (!base::mac::CheckLoginItemStatus(NULL)) {
// There's no LoginItem, so set the kUserRemovedLoginItem pref.
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(SetUserRemovedLoginItemPrefOnUIThread));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::Bind(SetUserRemovedLoginItemPrefOnUIThread));
}
}
@ -59,8 +60,8 @@ void EnableLaunchOnStartupOnWorkerThread(bool need_migration) {
if (is_hidden) {
// We already have a hidden login item, so set the kChromeCreatedLoginItem
// flag.
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(SetCreatedLoginItemPrefOnUIThread));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::Bind(SetCreatedLoginItemPrefOnUIThread));
}
// LoginItem already exists - just exit.
return;
@ -75,8 +76,8 @@ void EnableLaunchOnStartupOnWorkerThread(bool need_migration) {
// before our callback is run, but the user can manually disable
// "Open At Login" via the dock if this happens.
base::mac::AddToLoginItems(true); // Hide on startup.
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(SetCreatedLoginItemPrefOnUIThread));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::Bind(SetCreatedLoginItemPrefOnUIThread));
}
}

@ -7,6 +7,7 @@
#include "base/command_line.h"
#include "base/deferred_sequenced_task_runner.h"
#include "base/memory/singleton.h"
#include "base/task/post_task.h"
#include "base/values.h"
#include "build/build_config.h"
#include "chrome/browser/bookmarks/chrome_bookmark_client.h"
@ -25,6 +26,7 @@
#include "components/prefs/pref_service.h"
#include "components/sync_bookmarks/bookmark_sync_service.h"
#include "components/undo/bookmark_undo_service.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
using bookmarks::BookmarkModel;
@ -71,8 +73,8 @@ KeyedService* BookmarkModelFactory::BuildServiceInstanceFor(
bookmark_model->Load(profile->GetPrefs(), profile->GetPath(),
StartupTaskRunnerServiceFactory::GetForProfile(profile)
->GetBookmarkTaskRunner(),
content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::UI));
base::CreateSingleThreadTaskRunnerWithTraits(
{content::BrowserThread::UI}));
BookmarkUndoServiceFactory::GetForProfile(profile)->Start(bookmark_model);
return bookmark_model;

@ -115,6 +115,7 @@
#include "components/ukm/ukm_service.h"
#include "components/update_client/update_query_params.h"
#include "components/web_resource/web_resource_pref_names.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/network_service_instance.h"
@ -535,8 +536,8 @@ void RequestProxyResolvingSocketFactoryOnUIThread(
void RequestProxyResolvingSocketFactory(
network::mojom::ProxyResolvingSocketFactoryRequest request) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&RequestProxyResolvingSocketFactoryOnUIThread,
std::move(request)));
}
@ -1347,8 +1348,8 @@ void BrowserProcessImpl::CreateOptimizationGuideService() {
optimization_guide_service_ =
std::make_unique<optimization_guide::OptimizationGuideService>(
content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::IO));
base::CreateSingleThreadTaskRunnerWithTraits(
{content::BrowserThread::IO}));
}
void BrowserProcessImpl::CreateGCMDriver() {
@ -1373,10 +1374,10 @@ void BrowserProcessImpl::CreateGCMDriver() {
base::BindRepeating(&RequestProxyResolvingSocketFactory),
system_network_context_manager()->GetSharedURLLoaderFactory(),
chrome::GetChannel(), gcm::GetProductCategoryForSubtypes(local_state()),
content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::UI),
content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::IO),
base::CreateSingleThreadTaskRunnerWithTraits(
{content::BrowserThread::UI}),
base::CreateSingleThreadTaskRunnerWithTraits(
{content::BrowserThread::IO}),
blocking_task_runner);
#endif // defined(OS_ANDROID)
}

@ -7,8 +7,10 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/location.h"
#include "base/task/post_task.h"
#include "chrome/browser/browsing_data/browsing_data_helper.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
#include "net/base/completion_callback.h"
@ -35,8 +37,8 @@ void OnAppCacheInfoFetchComplete(
++it;
}
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::BindOnce(callback, info_collection));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::BindOnce(callback, info_collection));
}
} // namespace
@ -51,16 +53,16 @@ void BrowsingDataAppCacheHelper::StartFetching(const FetchCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(!callback.is_null());
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&BrowsingDataAppCacheHelper::StartFetchingOnIOThread, this,
callback));
}
void BrowsingDataAppCacheHelper::DeleteAppCacheGroup(const GURL& manifest_url) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&BrowsingDataAppCacheHelper::DeleteAppCacheGroupOnIOThread,
this, manifest_url));
}

@ -8,7 +8,9 @@
#include "base/bind.h"
#include "base/location.h"
#include "base/task/post_task.h"
#include "chrome/browser/browsing_data/browsing_data_helper.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/cache_storage_context.h"
@ -31,8 +33,8 @@ void GetAllOriginsInfoForCacheStorageCallback(
result.push_back(origin);
}
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::BindOnce(callback, result));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::BindOnce(callback, result));
}
} // namespace
@ -49,8 +51,8 @@ void BrowsingDataCacheStorageHelper::StartFetching(
const FetchCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(!callback.is_null());
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(
&BrowsingDataCacheStorageHelper::FetchCacheStorageUsageInfoOnIOThread,
this, callback));
@ -58,8 +60,8 @@ void BrowsingDataCacheStorageHelper::StartFetching(
void BrowsingDataCacheStorageHelper::DeleteCacheStorage(const GURL& origin) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(
&BrowsingDataCacheStorageHelper::DeleteCacheStorageOnIOThread, this,
origin));
@ -141,8 +143,8 @@ void CannedBrowsingDataCacheStorageHelper::StartFetching(
result.push_back(info);
}
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::BindOnce(callback, result));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::BindOnce(callback, result));
}
void CannedBrowsingDataCacheStorageHelper::DeleteCacheStorage(

@ -11,7 +11,9 @@
#include "base/logging.h"
#include "base/macros.h"
#include "base/single_thread_task_runner.h"
#include "base/task/post_task.h"
#include "base/threading/thread_task_runner_handle.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "net/ssl/channel_id_service.h"
#include "net/url_request/url_request_context.h"
@ -66,8 +68,8 @@ void BrowsingDataChannelIDHelperImpl::StartFetching(
const FetchResultCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(!callback.is_null());
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&BrowsingDataChannelIDHelperImpl::FetchOnIOThread, this,
callback));
}
@ -75,8 +77,8 @@ void BrowsingDataChannelIDHelperImpl::StartFetching(
void BrowsingDataChannelIDHelperImpl::DeleteChannelID(
const std::string& server_id) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&BrowsingDataChannelIDHelperImpl::DeleteOnIOThread, this,
server_id));
}
@ -105,8 +107,8 @@ void BrowsingDataChannelIDHelperImpl::OnFetchComplete(
const net::ChannelIDStore::ChannelIDList& channel_id_list) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(!callback.is_null());
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::BindOnce(callback, channel_id_list));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::BindOnce(callback, channel_id_list));
}
void BrowsingDataChannelIDHelperImpl::DeleteOnIOThread(

@ -13,8 +13,10 @@
#include "base/files/file_util.h"
#include "base/location.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/post_task.h"
#include "chrome/browser/browsing_data/browsing_data_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
#include "net/base/completion_callback.h"
@ -161,8 +163,8 @@ void CannedBrowsingDataDatabaseHelper::StartFetching(FetchCallback callback) {
DatabaseInfo(identifier, info.name, info.description, 0, base::Time()));
}
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::BindOnce(std::move(callback), result));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::BindOnce(std::move(callback), result));
}
void CannedBrowsingDataDatabaseHelper::DeleteDatabase(

@ -11,7 +11,9 @@
#include "base/location.h"
#include "base/macros.h"
#include "base/sequenced_task_runner.h"
#include "base/task/post_task.h"
#include "chrome/browser/browsing_data/browsing_data_helper.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/buildflags/buildflags.h"
#include "storage/browser/fileapi/file_system_context.h"
@ -130,8 +132,8 @@ void BrowsingDataFileSystemHelperImpl::FetchFileSystemInfoInFileThread(
for (const auto& iter : file_system_info_map)
result.push_back(iter.second);
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::BindOnce(callback, result));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::BindOnce(callback, result));
}
void BrowsingDataFileSystemHelperImpl::DeleteFileSystemOriginInFileThread(
@ -208,6 +210,6 @@ void CannedBrowsingDataFileSystemHelper::StartFetching(
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(!callback.is_null());
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::BindOnce(callback, file_system_info_));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::BindOnce(callback, file_system_info_));
}

@ -9,8 +9,10 @@
#include "base/bind.h"
#include "base/location.h"
#include "base/task/post_task.h"
#include "base/time/time.h"
#include "chrome/browser/browsing_data/browsing_data_helper.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/indexed_db_context.h"
@ -57,8 +59,8 @@ void BrowsingDataIndexedDBHelper::FetchIndexedDBInfoInIndexedDBThread(
continue; // Non-websafe state is not considered browsing data.
result.push_back(origin);
}
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::BindOnce(callback, result));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::BindOnce(callback, result));
}
void BrowsingDataIndexedDBHelper::DeleteIndexedDBInIndexedDBThread(
@ -126,8 +128,8 @@ void CannedBrowsingDataIndexedDBHelper::StartFetching(
result.push_back(info);
}
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::BindOnce(callback, result));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::BindOnce(callback, result));
}
void CannedBrowsingDataIndexedDBHelper::DeleteIndexedDB(

@ -8,8 +8,10 @@
#include "base/bind.h"
#include "base/location.h"
#include "base/task/post_task.h"
#include "chrome/browser/browsing_data/browsing_data_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/local_storage_usage_info.h"
#include "content/public/browser/storage_partition.h"
@ -42,8 +44,8 @@ void GetUsageInfoCallback(
info.origin, info.data_size, info.last_modified));
}
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::BindOnce(callback, result));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::BindOnce(callback, result));
}
} // namespace
@ -120,8 +122,8 @@ void CannedBrowsingDataLocalStorageHelper::StartFetching(
for (const GURL& url : pending_local_storage_info_)
result.push_back(LocalStorageInfo(url, 0, base::Time()));
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::BindOnce(callback, result));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::BindOnce(callback, result));
}
void CannedBrowsingDataLocalStorageHelper::DeleteOrigin(

@ -11,7 +11,9 @@
#include "base/location.h"
#include "base/macros.h"
#include "base/sequenced_task_runner.h"
#include "base/task/post_task.h"
#include "chrome/browser/browsing_data/browsing_data_helper.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "storage/browser/fileapi/file_system_context.h"
#include "storage/browser/fileapi/file_system_quota_util.h"
@ -111,8 +113,8 @@ void BrowsingDataMediaLicenseHelperImpl::FetchMediaLicenseInfoOnFileTaskRunner(
result.push_back(MediaLicenseInfo(origin, size, last_modified_time));
}
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::BindOnce(callback, result));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::BindOnce(callback, result));
}
void BrowsingDataMediaLicenseHelperImpl::

@ -11,11 +11,12 @@
#include "base/bind.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/task/post_task.h"
#include "chrome/browser/browsing_data/browsing_data_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
#include "storage/browser/quota/quota_manager.h"
@ -35,16 +36,16 @@ void BrowsingDataQuotaHelperImpl::StartFetching(
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(!callback.is_null());
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&BrowsingDataQuotaHelperImpl::FetchQuotaInfoOnIOThread,
this, callback));
}
void BrowsingDataQuotaHelperImpl::RevokeHostQuota(const std::string& host) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&BrowsingDataQuotaHelperImpl::RevokeHostQuotaOnIOThread,
this, host));
}
@ -159,8 +160,8 @@ void BrowsingDataQuotaHelperImpl::OnGetHostsUsageComplete(
result.push_back(info);
}
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::BindOnce(callback, result));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::BindOnce(callback, result));
}
void BrowsingDataQuotaHelperImpl::RevokeHostQuotaOnIOThread(

@ -11,7 +11,9 @@
#include "base/files/scoped_temp_dir.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/task/post_task.h"
#include "chrome/browser/browsing_data/browsing_data_quota_helper_impl.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/test/test_browser_thread.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "content/public/test/test_utils.h"
@ -37,8 +39,8 @@ class BrowsingDataQuotaHelperTest : public testing::Test {
EXPECT_TRUE(dir_.CreateUniqueTempDir());
quota_manager_ = new storage::QuotaManager(
false, dir_.GetPath(),
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO).get(), nullptr,
storage::GetQuotaSettingsFunc());
base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::IO}).get(),
nullptr, storage::GetQuotaSettingsFunc());
helper_ = new BrowsingDataQuotaHelperImpl(quota_manager_.get());
}

@ -9,7 +9,9 @@
#include "base/bind.h"
#include "base/location.h"
#include "base/task/post_task.h"
#include "chrome/browser/browsing_data/browsing_data_helper.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/service_worker_context.h"
@ -32,8 +34,8 @@ void GetAllOriginsInfoForServiceWorkerCallback(
result.push_back(origin);
}
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::BindOnce(callback, result));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::BindOnce(callback, result));
}
} // namespace
@ -50,8 +52,8 @@ void BrowsingDataServiceWorkerHelper::StartFetching(
const FetchCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(!callback.is_null());
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&BrowsingDataServiceWorkerHelper::
FetchServiceWorkerUsageInfoOnIOThread,
this, callback));
@ -59,8 +61,8 @@ void BrowsingDataServiceWorkerHelper::StartFetching(
void BrowsingDataServiceWorkerHelper::DeleteServiceWorkers(const GURL& origin) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(
&BrowsingDataServiceWorkerHelper::DeleteServiceWorkersOnIOThread,
this, origin));
@ -148,8 +150,8 @@ void CannedBrowsingDataServiceWorkerHelper::StartFetching(
result.push_back(info);
}
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::BindOnce(callback, result));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::BindOnce(callback, result));
}
void CannedBrowsingDataServiceWorkerHelper::DeleteServiceWorkers(

@ -9,7 +9,9 @@
#include "base/bind.h"
#include "base/location.h"
#include "base/task/post_task.h"
#include "chrome/browser/browsing_data/browsing_data_helper.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/shared_worker_service.h"
#include "content/public/browser/storage_partition.h"
@ -46,8 +48,8 @@ void BrowsingDataSharedWorkerHelper::StartFetching(FetchCallback callback) {
// We always return an empty list, as there are no "persistent" shared
// workers.
std::list<SharedWorkerInfo> result;
content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
base::BindOnce(std::move(callback), result));
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(std::move(callback), result));
}
void BrowsingDataSharedWorkerHelper::DeleteSharedWorker(
const GURL& worker,
@ -102,8 +104,8 @@ void CannedBrowsingDataSharedWorkerHelper::StartFetching(
std::list<SharedWorkerInfo> result;
for (auto& it : pending_shared_worker_info_)
result.push_back(it);
content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
base::BindOnce(std::move(callback), result));
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(std::move(callback), result));
}
void CannedBrowsingDataSharedWorkerHelper::DeleteSharedWorker(

@ -92,6 +92,7 @@
#include "components/web_cache/browser/web_cache_manager.h"
#include "components/webrtc_logging/browser/log_cleanup.h"
#include "components/webrtc_logging/browser/text_log_list.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/browsing_data_filter_builder.h"
#include "content/public/browser/plugin_data_remover.h"
@ -152,7 +153,7 @@ namespace {
// Generic functions but currently only used when ENABLE_NACL.
#if BUILDFLAG(ENABLE_NACL)
void UIThreadTrampolineHelper(base::OnceClosure callback) {
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, std::move(callback));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI}, std::move(callback));
}
// Convenience method to create a callback that can be run on any thread and
@ -859,13 +860,13 @@ void ChromeBrowsingDataRemoverDelegate::RemoveEmbedderData(
web_cache::WebCacheManager::GetInstance()->ClearCache();
#if BUILDFLAG(ENABLE_NACL)
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&ClearNaClCacheOnIOThread,
base::AdaptCallbackForRepeating(UIThreadTrampoline(
CreatePendingTaskCompletionClosure()))));
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&ClearPnaclCacheOnIOThread, delete_begin_, delete_end_,
base::AdaptCallbackForRepeating(UIThreadTrampoline(
CreatePendingTaskCompletionClosure()))));

@ -4,11 +4,13 @@
#include "chrome/browser/browsing_data/counters/site_data_counting_helper.h"
#include "base/task/post_task.h"
#include "chrome/browser/browsing_data/browsing_data_flash_lso_helper.h"
#include "chrome/browser/browsing_data/browsing_data_helper.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/dom_storage_context.h"
#include "content/public/browser/local_storage_usage_info.h"
@ -65,8 +67,8 @@ void SiteDataCountingHelper::CountAndDestroySelfWhenFinished() {
blink::mojom::StorageType::kSyncable};
for (auto type : types) {
tasks_ += 1;
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&storage::QuotaManager::GetOriginsModifiedSince,
quota_manager, type, begin_, origins_callback));
}
@ -104,8 +106,8 @@ void SiteDataCountingHelper::CountAndDestroySelfWhenFinished() {
}
// Count origins with channel ids.
tasks_ += 1;
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&SiteDataCountingHelper::GetChannelIDsOnIOThread,
base::Unretained(this), base::WrapRefCounted(rq_context)));
}
@ -135,9 +137,9 @@ void SiteDataCountingHelper::GetCookiesCallback(
origins.push_back(url);
}
}
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::BindOnce(&SiteDataCountingHelper::Done,
base::Unretained(this), origins));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::BindOnce(&SiteDataCountingHelper::Done,
base::Unretained(this), origins));
}
void SiteDataCountingHelper::GetQuotaOriginsCallback(
@ -145,9 +147,9 @@ void SiteDataCountingHelper::GetQuotaOriginsCallback(
blink::mojom::StorageType type) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
std::vector<GURL> origins(origin_set.begin(), origin_set.end());
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::BindOnce(&SiteDataCountingHelper::Done,
base::Unretained(this), origins));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::BindOnce(&SiteDataCountingHelper::Done,
base::Unretained(this), origins));
}
void SiteDataCountingHelper::GetLocalStorageUsageInfoCallback(
@ -204,9 +206,9 @@ void SiteDataCountingHelper::GetChannelIDsCallback(
origins.push_back(GURL("https://" + channel_id.server_identifier()));
}
}
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::BindOnce(&SiteDataCountingHelper::Done,
base::Unretained(this), origins));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::BindOnce(&SiteDataCountingHelper::Done,
base::Unretained(this), origins));
}
void SiteDataCountingHelper::Done(const std::vector<GURL>& origins) {

@ -10,11 +10,13 @@
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/run_loop.h"
#include "base/task/post_task.h"
#include "chrome/browser/browsing_data/counters/site_data_counting_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/test/test_browser_thread_bundle.h"
@ -55,8 +57,8 @@ class SiteDataCountingHelperTest : public testing::Test {
DCHECK(success);
if (--tasks_ > 0)
return;
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&SiteDataCountingHelperTest::DoneCallback,
base::Unretained(this)));
}
@ -74,8 +76,8 @@ class SiteDataCountingHelperTest : public testing::Test {
content::BrowserContext::GetDefaultStoragePartition(profile());
net::URLRequestContextGetter* rq_context =
partition->GetURLRequestContext();
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&SiteDataCountingHelperTest::CreateCookiesOnIOThread,
base::Unretained(this), base::WrapRefCounted(rq_context),
creation_time, urls));

@ -24,6 +24,7 @@
#include "base/sequence_checker.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/post_task.h"
#include "base/test/bind_test_util.h"
#include "base/values.h"
#include "build/build_config.h"
@ -49,6 +50,7 @@
#include "chrome/test/base/ui_test_utils.h"
#include "components/prefs/pref_service.h"
#include "components/security_interstitials/content/security_interstitial_page.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/interstitial_page.h"
#include "content/public/browser/interstitial_page_delegate.h"
@ -728,8 +730,8 @@ class CaptivePortalBrowserTest : public InProcessBrowserTest {
// not affected.
void SetBehindCaptivePortal(bool behind_captive_portal) {
if (BrowserThread::CurrentlyOn(BrowserThread::UI)) {
content::BrowserThread::PostTask(
content::BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(&CaptivePortalBrowserTest::SetBehindCaptivePortal,
base::Unretained(this), behind_captive_portal));
return;
@ -741,8 +743,8 @@ class CaptivePortalBrowserTest : public InProcessBrowserTest {
// Waits for exactly |num_jobs| kMockHttps* requests.
void WaitForJobs(int num_jobs) {
if (BrowserThread::CurrentlyOn(BrowserThread::UI)) {
content::BrowserThread::PostTask(
content::BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(&CaptivePortalBrowserTest::WaitForJobs,
base::Unretained(this), num_jobs));
content::RunMessageLoop();
@ -752,8 +754,8 @@ class CaptivePortalBrowserTest : public InProcessBrowserTest {
DCHECK(!num_jobs_to_wait_for_);
EXPECT_LE(static_cast<int>(ongoing_mock_requests_.size()), num_jobs);
if (num_jobs == static_cast<int>(ongoing_mock_requests_.size())) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::RunLoop::QuitCurrentWhenIdleClosureDeprecated());
} else {
num_jobs_to_wait_for_ = num_jobs;
@ -766,8 +768,8 @@ class CaptivePortalBrowserTest : public InProcessBrowserTest {
// WaitForJobs, so makes sure there has been a matching WaitForJobs call.
void FailJobs(int expected_num_jobs) {
if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&CaptivePortalBrowserTest::FailJobs,
base::Unretained(this), expected_num_jobs));
return;
@ -787,8 +789,8 @@ class CaptivePortalBrowserTest : public InProcessBrowserTest {
void FailJobsWithCertError(int expected_num_jobs,
const net::SSLInfo& ssl_info) {
if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&CaptivePortalBrowserTest::FailJobsWithCertError,
base::Unretained(this), expected_num_jobs, ssl_info));
return;
@ -807,8 +809,8 @@ class CaptivePortalBrowserTest : public InProcessBrowserTest {
EXPECT_EQ(expected_num_jobs,
static_cast<int>(ongoing_mock_requests_.size()));
for (auto& job : ongoing_mock_requests_) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&CaptivePortalBrowserTest::CreateLoader,
base::Unretained(this), std::move(job)));
}
@ -829,8 +831,8 @@ class CaptivePortalBrowserTest : public InProcessBrowserTest {
// behaves just as in FailJobs.
void AbandonJobs(int expected_num_jobs) {
if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&CaptivePortalBrowserTest::AbandonJobs,
base::Unretained(this), expected_num_jobs));
return;
@ -955,8 +957,8 @@ bool CaptivePortalBrowserTest::OnIntercept(
if (num_jobs_to_wait_for_ ==
static_cast<int>(ongoing_mock_requests_.size())) {
num_jobs_to_wait_for_ = 0;
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::RunLoop::QuitCurrentWhenIdleClosureDeprecated());
}
}

@ -14,12 +14,14 @@
#include "base/sequence_checker.h"
#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/post_task.h"
#include "build/build_config.h"
#include "chrome/browser/net/nss_context.h"
#include "chrome/browser/ui/crypto_module_password_dialog_nss.h"
#include "chrome/common/net/x509_certificate_model_nss.h"
#include "chrome/grit/generated_resources.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/resource_context.h"
#include "crypto/nss_util.h"
@ -492,8 +494,8 @@ void CertificateManagerModel::Create(
certificate_provider_service->CreateCertificateProvider();
#endif
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&CertificateManagerModel::GetCertDBOnIOThread,
std::move(params), browser_context->GetResourceContext(),
observer, callback));
@ -694,8 +696,8 @@ void CertificateManagerModel::DidGetCertDBOnIOThread(
#if defined(OS_CHROMEOS)
is_tpm_available = crypto::IsTPMTokenEnabledForNSS();
#endif
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&CertificateManagerModel::DidGetCertDBOnUIThread,
std::move(params), observer, callback, cert_db,
is_user_db_available, is_tpm_available));

@ -165,6 +165,7 @@
#include "components/variations/variations_switches.h"
#include "components/version_info/version_info.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
@ -1371,8 +1372,8 @@ void ChromeBrowserMainParts::PostCreateThreads() {
// BrowserMainLoop::InitializeMainThread(). PostCreateThreads is preferred to
// BrowserThreadsStarted as it matches the PreCreateThreads and CreateThreads
// stages.
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&ThreadProfiler::StartOnChildThread,
metrics::CallStackProfileParams::IO_THREAD));
}
@ -1478,8 +1479,8 @@ void ChromeBrowserMainParts::PostBrowserStart() {
#endif // !defined(OS_ANDROID)
// Set up a task to delete old WebRTC log files for all profiles. Use a delay
// to reduce the impact on startup time.
BrowserThread::PostDelayedTask(
BrowserThread::UI, FROM_HERE,
base::PostDelayedTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&WebRtcLogUtil::DeleteOldWebRtcLogFilesForAllProfiles),
base::TimeDelta::FromMinutes(1));
@ -1487,7 +1488,8 @@ void ChromeBrowserMainParts::PostBrowserStart() {
if (base::FeatureList::IsEnabled(features::kWebUsb)) {
web_usb_detector_.reset(new WebUsbDetector());
BrowserThread::PostAfterStartupTask(
FROM_HERE, BrowserThread::GetTaskRunnerForThread(BrowserThread::UI),
FROM_HERE,
base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::UI}),
base::BindOnce(&WebUsbDetector::Initialize,
base::Unretained(web_usb_detector_.get())));
}
@ -1513,7 +1515,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
// Can't be in SetupFieldTrials() because it needs a task runner.
blink::MemoryAblationExperiment::MaybeStart(
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO));
base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::IO}));
#if defined(OS_WIN)
// Windows parental controls calls can be slow, so we do an early init here
@ -1922,8 +1924,8 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
#endif
#if BUILDFLAG(ENABLE_NACL)
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
base::BindOnce(nacl::NaClProcessHost::EarlyStartup));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::IO},
base::BindOnce(nacl::NaClProcessHost::EarlyStartup));
#endif // BUILDFLAG(ENABLE_NACL)
// Make sure initial prefs are recorded

@ -18,6 +18,7 @@
#include "chrome/grit/chromium_strings.h"
#include "components/crash/content/app/breakpad_linux.h"
#include "components/metrics/metrics_service.h"
#include "content/public/browser/browser_task_traits.h"
#include "device/bluetooth/dbus/bluez_dbus_manager.h"
#include "device/bluetooth/dbus/dbus_thread_manager_linux.h"
#include "media/audio/audio_manager.h"
@ -76,8 +77,8 @@ void ChromeBrowserMainPartsLinux::PreProfileInit() {
// Forward the product name
config->product_name = l10n_util::GetStringUTF8(IDS_PRODUCT_NAME);
// OSCrypt may target keyring, which requires calls from the main thread.
config->main_thread_runner = content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::UI);
config->main_thread_runner = base::CreateSingleThreadTaskRunnerWithTraits(
{content::BrowserThread::UI});
// OSCrypt can be disabled in a special settings file.
config->should_use_preference =
parsed_command_line().HasSwitch(switches::kEnableEncryptionSelection);

@ -16,10 +16,12 @@
#include "base/bind.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/task/post_task.h"
#include "build/build_config.h"
#include "chrome/app/shutdown_signal_handlers_posix.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/sessions/session_restore.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/common/result_codes.h"
@ -87,8 +89,8 @@ void ExitHandler::OnSessionRestoreDone(int /* num_tabs */) {
// At this point the message loop may not be running (meaning we haven't
// gotten through browser startup, but are close). Post the task to at which
// point the message loop is running.
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::BindOnce(&ExitHandler::Exit));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::BindOnce(&ExitHandler::Exit));
delete this;
}
}
@ -136,7 +138,7 @@ void ChromeBrowserMainPartsPosix::PostMainMessageLoopStart() {
// Exit in response to SIGINT, SIGTERM, etc.
InstallShutdownSignalHandlers(
base::Bind(&ExitHandler::ExitWhenPossibleOnUIThread),
BrowserThread::GetTaskRunnerForThread(BrowserThread::UI));
base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::UI}));
}
void ChromeBrowserMainPartsPosix::ShowMissingLocaleMessageBox() {

@ -71,6 +71,7 @@
#include "components/crash/content/app/dump_hung_process_with_ptype.h"
#include "components/crash/core/common/crash_key.h"
#include "components/version_info/channel.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/common/content_switches.h"
@ -399,8 +400,8 @@ void MaybePostSettingsResetPrompt() {
if (base::FeatureList::IsEnabled(safe_browsing::kSettingsResetPrompt)) {
content::BrowserThread::PostAfterStartupTask(
FROM_HERE,
content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::UI),
base::CreateSingleThreadTaskRunnerWithTraits(
{content::BrowserThread::UI}),
base::Bind(safe_browsing::MaybeShowSettingsResetPromptWithDelay));
}
}
@ -571,11 +572,9 @@ void ChromeBrowserMainPartsWin::PostBrowserStart() {
// Record UMA data about whether the fault-tolerant heap is enabled.
// Use a delayed task to minimize the impact on startup time.
content::BrowserThread::PostDelayedTask(
content::BrowserThread::UI,
FROM_HERE,
base::Bind(&DetectFaultTolerantHeap),
base::TimeDelta::FromMinutes(1));
base::PostDelayedTaskWithTraits(FROM_HERE, {content::BrowserThread::UI},
base::Bind(&DetectFaultTolerantHeap),
base::TimeDelta::FromMinutes(1));
// Start the swap thrashing monitor if it's enabled.
//

@ -28,6 +28,7 @@
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/sys_info.h"
#include "base/task/post_task.h"
#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
#include "chrome/browser/after_startup_task_utils.h"
@ -221,6 +222,7 @@
#include "content/public/browser/browser_child_process_host.h"
#include "content/public/browser/browser_main_parts.h"
#include "content/public/browser/browser_ppapi_host.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/browser_url_handler.h"
#include "content/public/browser/browsing_data_remover.h"
@ -1077,8 +1079,8 @@ void ChromeContentBrowserClient::SetApplicationLocale(
// the IO thread.
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&SetApplicationLocaleOnIOThread, locale));
}
@ -2323,8 +2325,8 @@ bool ChromeContentBrowserClient::AllowServiceWorker(
// Record access to database for potential display in UI.
// Only post the task if this is for a specific tab.
if (!wc_getter.is_null()) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&TabSpecificContentSettings::ServiceWorkerAccessed,
wc_getter, scope, !allow_javascript,
!allow_serviceworker));
@ -2398,8 +2400,8 @@ void ChromeContentBrowserClient::OnCookiesRead(
base::RepeatingCallback<content::WebContents*(void)> wc_getter =
base::BindRepeating(&GetWebContentsFromProcessAndFrameId, process_id,
routing_id);
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&TabSpecificContentSettings::CookiesRead, wc_getter, url,
first_party_url, cookie_list, blocked_by_policy));
}
@ -2414,8 +2416,8 @@ void ChromeContentBrowserClient::OnCookieChange(
base::RepeatingCallback<content::WebContents*(void)> wc_getter =
base::BindRepeating(&GetWebContentsFromProcessAndFrameId, process_id,
routing_id);
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&TabSpecificContentSettings::CookieChanged, wc_getter, url,
first_party_url, cookie, blocked_by_policy));
}
@ -2464,8 +2466,8 @@ void ChromeContentBrowserClient::GuestPermissionRequestHelper(
}
DCHECK_EQ(1U, process_map.size());
it = process_map.begin();
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(
&ChromeContentBrowserClient::RequestFileSystemPermissionOnUIThread,
it->first, it->second, url, allow,
@ -2499,8 +2501,8 @@ void ChromeContentBrowserClient::FileSystemAccessed(
bool allow) {
// Record access to file system for potential display in UI.
for (const auto& it : render_frames) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&TabSpecificContentSettings::FileSystemAccessed,
it.child_id, it.frame_routing_id, url, !allow));
}
@ -2520,8 +2522,8 @@ bool ChromeContentBrowserClient::AllowWorkerIndexedDB(
// Record access to IndexedDB for potential display in UI.
for (const auto& it : render_frames) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&TabSpecificContentSettings::IndexedDBAccessed,
it.child_id, it.frame_routing_id, url, name, !allow));
}
@ -3503,8 +3505,8 @@ void ChromeContentBrowserClient::ExposeInterfacesToRenderer(
base::Bind(&CacheStatsRecorder::Create, render_process_host->GetID()));
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner =
content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::UI);
base::CreateSingleThreadTaskRunnerWithTraits(
{content::BrowserThread::UI});
registry->AddInterface(
base::Bind(&rappor::RapporRecorderImpl::Create,
g_browser_process->rappor_service()),
@ -3536,7 +3538,7 @@ void ChromeContentBrowserClient::ExposeInterfacesToRenderer(
base::Bind(
&ChromeContentBrowserClient::GetSafeBrowsingUrlCheckerDelegate,
base::Unretained(this), resource_context)),
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO));
base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::IO}));
}
#endif // defined(SAFE_BROWSING_DB_LOCAL) || defined(SAFE_BROWSING_DB_REMOTE)
@ -3566,7 +3568,7 @@ void ChromeContentBrowserClient::ExposeInterfacesToRenderer(
registry->AddInterface(
base::BindRepeating(&android::AvailableOfflineContentProvider::Create,
render_process_host->GetBrowserContext()),
BrowserThread::GetTaskRunnerForThread(BrowserThread::UI));
base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::UI}));
#endif
for (auto* ep : extra_parts_) {
@ -4348,7 +4350,7 @@ ChromeContentBrowserClient::CreateURLLoaderThrottles(
chrome_navigation_ui_data->prerender_mode(),
chrome_navigation_ui_data->prerender_histogram_prefix(),
base::BindOnce(GetPrerenderCanceller, wc_getter),
BrowserThread::GetTaskRunnerForThread(BrowserThread::UI)));
base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::UI})));
}
}
@ -4727,9 +4729,9 @@ bool ChromeContentBrowserClient::HandleExternalProtocol(
return false;
#endif // defined(ANDROID)
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::BindOnce(&LaunchURL, url, web_contents_getter,
page_transition, has_user_gesture));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::BindOnce(&LaunchURL, url, web_contents_getter,
page_transition, has_user_gesture));
return true;
}

@ -9,10 +9,12 @@
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/run_loop.h"
#include "base/task/post_task.h"
#include "base/threading/thread_restrictions.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "content/public/browser/browser_child_process_host_iterator.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_data.h"
#include "content/public/common/process_type.h"
@ -60,8 +62,8 @@ IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientMashTest, CrashReporter) {
// Child process management lives on the IO thread.
std::vector<pid_t> pids;
base::RunLoop loop;
BrowserThread::PostTaskAndReply(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraitsAndReply(
FROM_HERE, {BrowserThread::IO},
base::Bind(&GetUtilityProcessPidsOnIOThread, &pids), loop.QuitClosure());
loop.Run();
ASSERT_FALSE(pids.empty());

@ -15,6 +15,7 @@
#include "base/path_service.h"
#include "base/process/process.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/post_task.h"
#include "build/build_config.h"
#include "chrome/browser/plugins/plugin_prefs.h"
#include "chrome/browser/profiles/profile.h"
@ -24,6 +25,7 @@
#include "chrome/test/base/ui_test_utils.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_child_process_host_iterator.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_data.h"
#include "content/public/browser/plugin_service.h"
@ -110,8 +112,8 @@ class ChromePluginTest : public InProcessBrowserTest {
static void CrashFlash() {
scoped_refptr<content::MessageLoopRunner> runner =
new content::MessageLoopRunner;
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&CrashFlashInternal, runner->QuitClosure()));
runner->Run();
}
@ -140,8 +142,8 @@ class ChromePluginTest : public InProcessBrowserTest {
int actual = 0;
scoped_refptr<content::MessageLoopRunner> runner =
new content::MessageLoopRunner;
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&CountPluginProcesses, &actual, runner->QuitClosure()));
runner->Run();
ASSERT_EQ(expected, actual);
@ -159,7 +161,7 @@ class ChromePluginTest : public InProcessBrowserTest {
found = true;
}
ASSERT_TRUE(found) << "Didn't find Flash process!";
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, quit_task);
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI}, quit_task);
}
static void GetPluginsInfoCallback(
@ -175,7 +177,7 @@ class ChromePluginTest : public InProcessBrowserTest {
if (iter.GetData().process_type == content::PROCESS_TYPE_PPAPI_PLUGIN)
(*count)++;
}
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, quit_task);
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI}, quit_task);
}
};

@ -11,6 +11,7 @@
#include "base/bind.h"
#include "base/macros.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/post_task.h"
#include "build/build_config.h"
#include "chrome/browser/permissions/permission_request.h"
#include "chrome/browser/permissions/permission_request_manager.h"
@ -19,6 +20,7 @@
#include "chrome/browser/vr/vr_tab_helper.h"
#include "chrome/grit/generated_resources.h"
#include "components/url_formatter/elide_url.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_details.h"
#include "content/public/browser/web_contents.h"
@ -166,8 +168,8 @@ void ChromeQuotaPermissionContext::RequestQuotaPermission(
}
if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) {
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&ChromeQuotaPermissionContext::RequestQuotaPermission,
this, params, render_process_id, callback));
return;
@ -214,8 +216,8 @@ void ChromeQuotaPermissionContext::DispatchCallbackOnIOThread(
DCHECK_EQ(false, callback.is_null());
if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)) {
content::BrowserThread::PostTask(
content::BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(
&ChromeQuotaPermissionContext::DispatchCallbackOnIOThread, this,
callback, response));

@ -6,10 +6,12 @@
#include "base/no_destructor.h"
#include "base/single_thread_task_runner.h"
#include "base/task/post_task.h"
#include "chrome/browser/chrome_browser_main_extra_parts.h"
#include "chrome/common/constants.mojom.h"
#include "components/spellcheck/spellcheck_buildflags.h"
#include "components/startup_metric_utils/browser/startup_metric_host_impl.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/common/content_client.h"
@ -36,8 +38,8 @@ class ChromeService::IOThreadContext : public service_manager::Service {
public:
IOThreadContext() {
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner =
content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::UI);
base::CreateSingleThreadTaskRunnerWithTraits(
{content::BrowserThread::UI});
#if defined(OS_CHROMEOS)
#if defined(USE_OZONE)
@ -68,7 +70,7 @@ class ChromeService::IOThreadContext : public service_manager::Service {
// on the IO thread. Post a task instead. As long as this task is posted
// before any code attempts to connect to the chrome service, there's no
// race.
content::BrowserThread::GetTaskRunnerForThread(content::BrowserThread::IO)
base::CreateSingleThreadTaskRunnerWithTraits({content::BrowserThread::IO})
->PostTask(FROM_HERE,
base::BindOnce(&IOThreadContext::BindConnectorOnIOThread,
base::Unretained(this),

@ -12,6 +12,7 @@
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/post_task.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/threading/thread_restrictions.h"
#include "build/build_config.h"
@ -27,6 +28,7 @@
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/nacl/common/buildflags.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/service_worker_context.h"
#include "content/public/browser/storage_partition.h"
@ -222,8 +224,8 @@ IN_PROC_BROWSER_TEST_F(ChromeServiceWorkerTest,
msg.owned_encoded_message = blink::EncodeStringMessage(message_data);
msg.encoded_message = msg.owned_encoded_message;
content::BrowserThread::PostTask(
content::BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(&content::ServiceWorkerContext::
StartServiceWorkerAndDispatchLongRunningMessage,
base::Unretained(GetServiceWorkerContext()),

@ -12,6 +12,7 @@
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/post_task.h"
#include "chrome/browser/chrome_content_browser_client.h"
#include "chrome/browser/external_protocol/external_protocol_handler.h"
#include "chrome/browser/profiles/profile.h"
@ -26,6 +27,7 @@
#include "components/guest_view/browser/guest_view_manager_delegate.h"
#include "components/guest_view/browser/test_guest_view_manager.h"
#include "components/spellcheck/spellcheck_buildflags.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/interstitial_page.h"
#include "content/public/browser/navigation_entry.h"
@ -882,8 +884,8 @@ class MockSpellCheckHost : spellcheck::mojom::SpellCheckHost {
if (text_received_)
return;
auto ui_task_runner = content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::UI);
auto ui_task_runner = base::CreateSingleThreadTaskRunnerWithTraits(
{content::BrowserThread::UI});
ui_task_runner->PostDelayedTask(
FROM_HERE,
base::BindOnce(&MockSpellCheckHost::Timeout, base::Unretained(this)),
@ -967,8 +969,8 @@ class TestBrowserClientForSpellCheck : public ChromeContentBrowserClient {
spellcheck::mojom::SpellCheckHostRequest request(std::move(*handle));
// Override the default SpellCheckHost interface.
auto ui_task_runner = content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::UI);
auto ui_task_runner = base::CreateSingleThreadTaskRunnerWithTraits(
{content::BrowserThread::UI});
ui_task_runner->PostTask(
FROM_HERE,
base::BindOnce(
@ -1002,8 +1004,8 @@ class TestBrowserClientForSpellCheck : public ChromeContentBrowserClient {
if (spell_check_hosts_.size())
return;
auto ui_task_runner = content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::UI);
auto ui_task_runner = base::CreateSingleThreadTaskRunnerWithTraits(
{content::BrowserThread::UI});
ui_task_runner->PostDelayedTask(
FROM_HERE,
base::BindOnce(&TestBrowserClientForSpellCheck::Timeout,

@ -28,6 +28,7 @@
#include "base/strings/string_piece.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/task/post_task.h"
#include "base/values.h"
#include "chrome/browser/accessibility/accessibility_extension_api.h"
#include "chrome/browser/browser_process.h"
@ -62,6 +63,7 @@
#include "components/prefs/pref_service.h"
#include "components/user_manager/known_user.h"
#include "content/public/browser/browser_accessibility_state.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/focused_node_details.h"
#include "content/public/browser/notification_details.h"
@ -889,8 +891,8 @@ void AccessibilityManager::CheckBrailleState() {
BrailleController* braille_controller = GetBrailleController();
if (!scoped_braille_observer_.IsObserving(braille_controller))
scoped_braille_observer_.Add(braille_controller);
BrowserThread::PostTaskAndReplyWithResult(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraitsAndReplyWithResult(
FROM_HERE, {BrowserThread::IO},
base::Bind(&BrailleController::GetDisplayState,
base::Unretained(braille_controller)),
base::Bind(&AccessibilityManager::ReceiveBrailleDisplayState,

@ -18,6 +18,7 @@
#include "base/macros.h"
#include "base/strings/pattern.h"
#include "base/strings/string_util.h"
#include "base/task/post_task.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
@ -44,6 +45,7 @@
#include "chromeos/chromeos_switches.h"
#include "components/account_id/account_id.h"
#include "components/user_manager/user_names.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/common/url_constants.h"
#include "content/public/test/browser_test_utils.h"
@ -628,8 +630,8 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, DISABLED_ChromeVoxNextStickyMode) {
// Sticky key has a minimum 100 ms check to prevent key repeat from toggling
// it.
content::BrowserThread::PostDelayedTask(
content::BrowserThread::UI, FROM_HERE,
base::PostDelayedTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::Bind(&LoggedInSpokenFeedbackTest::SendKeyPress,
base::Unretained(this), ui::VKEY_LWIN),
base::TimeDelta::FromMilliseconds(200));
@ -644,8 +646,8 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, DISABLED_ChromeVoxNextStickyMode) {
// Sticky key has a minimum 100 ms check to prevent key repeat from toggling
// it.
content::BrowserThread::PostDelayedTask(
content::BrowserThread::UI, FROM_HERE,
base::PostDelayedTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::Bind(&LoggedInSpokenFeedbackTest::SendKeyPress,
base::Unretained(this), ui::VKEY_LWIN),
base::TimeDelta::FromMilliseconds(200));

@ -5,8 +5,10 @@
#include "chrome/browser/chromeos/android_sms/connection_establisher_impl.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/post_task.h"
#include "chrome/browser/chromeos/android_sms/android_sms_urls.h"
#include "chromeos/components/proximity_auth/logging/logging.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "third_party/blink/public/common/messaging/string_message_codec.h"
@ -22,8 +24,8 @@ ConnectionEstablisherImpl::~ConnectionEstablisherImpl() = default;
void ConnectionEstablisherImpl::EstablishConnection(
content::ServiceWorkerContext* service_worker_context) {
content::BrowserThread::PostTask(
content::BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(
&ConnectionEstablisherImpl::SendStartStreamingMessageIfNotConnected,
base::Unretained(this), service_worker_context));

@ -12,6 +12,7 @@
#include "base/location.h"
#include "base/macros.h"
#include "base/single_thread_task_runner.h"
#include "base/task/post_task.h"
#include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
@ -35,6 +36,7 @@
#include "components/prefs/pref_service.h"
#include "components/user_manager/user_manager.h"
#include "content/public/browser/browser_child_process_host_iterator.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_data.h"
#include "content/public/browser/plugin_service.h"
@ -93,8 +95,8 @@ void DumpPluginProcessOnIOThread(const std::set<int>& child_ids) {
// Wait a bit to let dump finish (if requested) before rebooting the device.
const int kDumpWaitSeconds = 10;
content::BrowserThread::PostDelayedTask(
content::BrowserThread::UI, FROM_HERE, base::BindOnce(&RebootDevice),
base::PostDelayedTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI}, base::BindOnce(&RebootDevice),
base::TimeDelta::FromSeconds(dump_requested ? kDumpWaitSeconds : 0));
}
@ -270,8 +272,8 @@ void AppSession::OnPluginHung(const std::set<int>& hung_plugins) {
is_shutting_down_ = true;
LOG(ERROR) << "Plugin hung detected. Dump and reboot.";
content::BrowserThread::PostTask(
content::BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(&DumpPluginProcessOnIOThread, hung_plugins));
}

@ -24,6 +24,7 @@
#include "chrome/browser/profiles/profile.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/scoped_user_pref_update.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/common/service_manager_connection.h"
#include "extensions/browser/extension_system.h"
@ -161,8 +162,8 @@ class KioskAppData::CrxLoader : public extensions::SandboxedUnpackerClient {
<< temp_dir_.GetPath().value();
}
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&CrxLoader::NotifyFinishedOnUIThread, this));
}

@ -13,6 +13,7 @@
#include "base/task/post_task.h"
#include "base/task/task_traits.h"
#include "chrome/browser/image_decoder.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
using content::BrowserThread;
@ -28,15 +29,15 @@ class IconImageRequest : public ImageDecoder::ImageRequest {
void OnImageDecoded(const SkBitmap& decoded_image) override {
gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(decoded_image);
image.MakeThreadSafe();
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::BindOnce(result_callback_, image));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::BindOnce(result_callback_, image));
delete this;
}
void OnDecodeImageFailed() override {
LOG(ERROR) << "Failed to decode icon image.";
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(result_callback_, base::Optional<gfx::ImageSkia>()));
delete this;
}
@ -55,8 +56,8 @@ void LoadOnBlockingPool(
std::string data;
if (!base::ReadFileToString(base::FilePath(icon_path), &data)) {
LOG(ERROR) << "Failed to read icon file.";
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(result_callback, base::Optional<gfx::ImageSkia>()));
return;
}

@ -11,11 +11,13 @@
#include "base/memory/singleton.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/task/post_task.h"
#include "base/time/time.h"
#include "chrome/browser/feedback/feedback_util_chromeos.h"
#include "chrome/browser/profiles/profile.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/browser/api/feedback_private/feedback_private_api.h"
#include "extensions/browser/extension_system_provider.h"
@ -73,8 +75,8 @@ void KioskDiagnosisRunner::Start(const std::string& app_id) {
app_id_ = app_id;
// Schedules system logs to be collected after 1 minute.
content::BrowserThread::PostDelayedTask(
content::BrowserThread::UI, FROM_HERE,
base::PostDelayedTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&KioskDiagnosisRunner::StartSystemLogCollection,
weak_factory_.GetWeakPtr()),
base::TimeDelta::FromMinutes(1));

@ -6,6 +6,8 @@
#include "base/bind.h"
#include "base/location.h"
#include "base/task/post_task.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/common/service_manager_connection.h"
#include "extensions/common/extension.h"
@ -47,8 +49,8 @@ void KioskExternalUpdateValidator::OnUnpackFailure(
const extensions::CrxInstallError& error) {
LOG(ERROR) << "Failed to unpack external kiosk crx file: "
<< crx_file_.extension_id << " " << error.message();
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(
&KioskExternalUpdateValidatorDelegate::OnExternalUpdateUnpackFailure,
delegate_, crx_file_.extension_id));
@ -72,8 +74,8 @@ void KioskExternalUpdateValidator::OnUnpackSuccess(
minimum_browser_version.clear();
}
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(
&KioskExternalUpdateValidatorDelegate::OnExternalUpdateUnpackSuccess,
delegate_, crx_file_.extension_id, extension->VersionString(),

@ -10,6 +10,7 @@
#include "base/bind.h"
#include "base/feature_list.h"
#include "base/metrics/histogram_macros.h"
#include "base/task/post_task.h"
#include "chrome/browser/apps/foundation/app_service/public/mojom/types.mojom.h"
#include "chrome/browser/chromeos/apps/intent_helper/apps_navigation_types.h"
#include "chrome/browser/chromeos/apps/intent_helper/page_transition_util.h"
@ -28,6 +29,7 @@
#include "components/arc/intent_helper/arc_intent_helper_bridge.h"
#include "components/arc/metrics/arc_metrics_constants.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/site_instance.h"
@ -422,10 +424,9 @@ void AppsNavigationThrottle::CancelNavigation() {
content::WebContents* web_contents = navigation_handle()->GetWebContents();
if (web_contents && web_contents->GetController().IsInitialNavigation()) {
// Workaround for b/79167225, closing |web_contents| here may be dangerous.
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::BindOnce(&AppsNavigationThrottle::CloseTab,
weak_factory_.GetWeakPtr()));
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&AppsNavigationThrottle::CloseTab,
weak_factory_.GetWeakPtr()));
} else {
CancelDeferredNavigation(content::NavigationThrottle::CANCEL_AND_IGNORE);
}

@ -9,6 +9,7 @@
#include "base/callback.h"
#include "base/command_line.h"
#include "base/run_loop.h"
#include "base/task/post_task.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/arc/arc_support_host.h"
#include "chrome/browser/chromeos/arc/auth/arc_active_directory_enrollment_token_fetcher.h"
@ -25,6 +26,7 @@
#include "components/policy/core/common/cloud/device_management_service.h"
#include "components/policy/core/common/policy_switches.h"
#include "components/user_manager/user_manager.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "net/base/network_delegate.h"
#include "net/base/upload_bytes_element_reader.h"
@ -300,8 +302,8 @@ class ArcActiveDirectoryEnrollmentTokenFetcherBrowserTest
void SetUpOnMainThread() override {
interceptor_ = std::make_unique<policy::TestRequestInterceptor>(
"localhost", content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::IO));
"localhost", base::CreateSingleThreadTaskRunnerWithTraits(
{content::BrowserThread::IO}));
support_host_ = std::make_unique<ArcSupportHost>(browser()->profile());
support_host_->SetErrorDelegate(this);

@ -13,6 +13,7 @@
#include "base/macros.h"
#include "base/optional.h"
#include "base/run_loop.h"
#include "base/task/post_task.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/arc/arc_service_launcher.h"
@ -60,6 +61,7 @@
#include "components/signin/core/browser/fake_profile_oauth2_token_service.h"
#include "components/user_manager/scoped_user_manager.h"
#include "components/user_manager/user_manager.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "net/url_request/url_request_test_job.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
@ -331,8 +333,8 @@ class ArcRobotAccountAuthServiceTest : public ArcAuthServiceTest {
void SetUpOnMainThread() override {
ArcAuthServiceTest::SetUpOnMainThread();
interceptor_ = std::make_unique<policy::TestRequestInterceptor>(
"localhost", content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::IO));
"localhost", base::CreateSingleThreadTaskRunnerWithTraits(
{content::BrowserThread::IO}));
SetUpPolicyClient();
}

@ -9,6 +9,7 @@
#include "base/callback.h"
#include "base/command_line.h"
#include "base/run_loop.h"
#include "base/task/post_task.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/arc/arc_session_manager.h"
#include "chrome/browser/chromeos/arc/auth/arc_auth_service.h"
@ -23,6 +24,7 @@
#include "components/policy/core/common/cloud/user_cloud_policy_manager.h"
#include "components/policy/core/common/policy_switches.h"
#include "components/user_manager/scoped_user_manager.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "net/base/upload_bytes_element_reader.h"
#include "net/base/upload_data_stream.h"
@ -79,8 +81,8 @@ class ArcRobotAuthCodeFetcherBrowserTest : public InProcessBrowserTest {
void SetUpOnMainThread() override {
interceptor_ = std::make_unique<policy::TestRequestInterceptor>(
"localhost", content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::IO));
"localhost", base::CreateSingleThreadTaskRunnerWithTraits(
{content::BrowserThread::IO}));
user_manager_enabler_ = std::make_unique<user_manager::ScopedUserManager>(
std::make_unique<chromeos::FakeChromeUserManager>());

@ -27,6 +27,7 @@
#include "chrome/common/chrome_paths.h"
#include "components/arc/arc_bridge_service.h"
#include "components/arc/arc_browser_context_keyed_service_factory_base.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
using content::BrowserThread;
@ -345,8 +346,8 @@ void ArcDownloadsWatcherService::DownloadsWatcher::OnBuildTimestampMap(
for (size_t i = 0; i < changed_paths.size(); ++i) {
string_paths[i] = changed_paths[i].value();
}
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::BindOnce(callback_, std::move(string_paths)));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::BindOnce(callback_, std::move(string_paths)));
if (last_notify_time_ > snapshot_time)
DelayBuildTimestampMap();
else

@ -10,11 +10,13 @@
#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/task/post_task.h"
#include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_root.h"
#include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_root_map.h"
#include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util.h"
#include "chrome/browser/profiles/profile.h"
#include "components/services/filesystem/public/interfaces/types.mojom.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "storage/browser/blob/shareable_file_reference.h"
#include "storage/browser/fileapi/file_system_operation_context.h"
@ -31,8 +33,8 @@ void OnGetFileInfoOnUIThread(
base::File::Error result,
const base::File::Info& info) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
base::BindOnce(std::move(callback), result, info));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::IO},
base::BindOnce(std::move(callback), result, info));
}
void OnReadDirectoryOnUIThread(
@ -50,9 +52,9 @@ void OnReadDirectoryOnUIThread(
: filesystem::mojom::FsFileType::REGULAR_FILE);
}
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
base::BindOnce(std::move(callback), result, entries,
false /* has_more */));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::IO},
base::BindOnce(std::move(callback), result, entries,
false /* has_more */));
}
void GetFileInfoOnUIThread(
@ -156,8 +158,8 @@ void ArcDocumentsProviderAsyncFileUtil::GetFileInfo(
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK_EQ(storage::kFileSystemTypeArcDocumentsProvider, url.type());
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&GetFileInfoOnUIThread, url, fields, std::move(callback)));
}
@ -168,8 +170,8 @@ void ArcDocumentsProviderAsyncFileUtil::ReadDirectory(
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK_EQ(storage::kFileSystemTypeArcDocumentsProvider, url.type());
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&ReadDirectoryOnUIThread, url, callback));
}

@ -8,9 +8,11 @@
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/task/post_task.h"
#include "chrome/browser/chromeos/arc/fileapi/arc_content_file_system_file_stream_reader.h"
#include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_root.h"
#include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_root_map.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
@ -27,8 +29,8 @@ void OnResolveToContentUrlOnUIThread(
const ArcDocumentsProviderRoot::ResolveToContentUrlCallback& callback,
const GURL& url) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
base::BindOnce(callback, url));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::IO},
base::BindOnce(callback, url));
}
void ResolveToContentUrlOnUIThread(
@ -62,8 +64,8 @@ ArcDocumentsProviderFileStreamReader::ArcDocumentsProviderFileStreamReader(
: offset_(offset), content_url_resolved_(false), weak_ptr_factory_(this) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(
&ResolveToContentUrlOnUIThread, url,
base::Bind(

@ -6,8 +6,10 @@
#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/task/post_task.h"
#include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_root.h"
#include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_root_map.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "storage/browser/fileapi/file_system_url.h"
@ -22,24 +24,24 @@ void OnAddWatcherOnUIThread(
const ArcDocumentsProviderRoot::StatusCallback& callback,
base::File::Error result) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
base::BindOnce(callback, result));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::IO},
base::BindOnce(callback, result));
}
void OnRemoveWatcherOnUIThread(
const ArcDocumentsProviderRoot::StatusCallback& callback,
base::File::Error result) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
base::BindOnce(callback, result));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::IO},
base::BindOnce(callback, result));
}
void OnNotificationOnUIThread(
const ArcDocumentsProviderRoot::WatcherCallback& notification_callback,
ArcDocumentsProviderRoot::ChangeType change_type) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
base::BindOnce(notification_callback, change_type));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::IO},
base::BindOnce(notification_callback, change_type));
}
void AddWatcherOnUIThread(
@ -111,8 +113,8 @@ void ArcDocumentsProviderWatcherManager::AddWatcher(
return;
}
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(
&AddWatcherOnUIThread, url,
base::Bind(&ArcDocumentsProviderWatcherManager::OnAddWatcher,
@ -133,8 +135,8 @@ void ArcDocumentsProviderWatcherManager::RemoveWatcher(
return;
}
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(
&RemoveWatcherOnUIThread, url,
base::Bind(&ArcDocumentsProviderWatcherManager::OnRemoveWatcher,

@ -8,6 +8,7 @@
#include "base/logging.h"
#include "base/memory/singleton.h"
#include "base/task/post_task.h"
#include "chrome/browser/chromeos/arc/fileapi/chrome_content_provider_url_util.h"
#include "chrome/browser/chromeos/arc/fileapi/file_stream_forwarder.h"
#include "chrome/browser/chromeos/file_manager/fileapi_util.h"
@ -17,6 +18,7 @@
#include "chromeos/dbus/virtual_file_provider_client.h"
#include "components/arc/arc_bridge_service.h"
#include "components/arc/arc_browser_context_keyed_service_factory_base.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/common/url_constants.h"
@ -74,9 +76,8 @@ void GetFileSizeOnIOThread(scoped_refptr<storage::FileSystemContext> context,
file_info.size >= 0) {
size = file_info.size;
}
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::BindOnce(std::move(callback), size));
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(std::move(callback), size));
},
base::Passed(&callback)));
}
@ -170,8 +171,8 @@ void ArcFileSystemBridge::GetFileSize(const std::string& url,
}
scoped_refptr<storage::FileSystemContext> context =
GetFileSystemContext(profile_, url_decoded);
content::BrowserThread::PostTask(
content::BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(&GetFileSizeOnIOThread, context,
GetFileSystemURL(context, url_decoded),
std::move(callback)));

@ -7,7 +7,9 @@
#include <utility>
#include <vector>
#include "base/task/post_task.h"
#include "components/arc/arc_service_manager.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "url/gurl.h"
@ -29,8 +31,8 @@ ArcFileSystemOperationRunner* GetArcFileSystemOperationRunner() {
template <typename T>
void PostToIOThread(base::OnceCallback<void(T)> callback, T result) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(std::move(callback), std::move(result)));
}
@ -63,8 +65,8 @@ void OpenFileToReadOnUIThread(const GURL& url,
void GetFileSizeOnIOThread(const GURL& url, GetFileSizeCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(
&GetFileSizeOnUIThread, url,
base::BindOnce(&PostToIOThread<int64_t>, std::move(callback))));
@ -73,8 +75,8 @@ void GetFileSizeOnIOThread(const GURL& url, GetFileSizeCallback callback) {
void OpenFileToReadOnIOThread(const GURL& url,
OpenFileToReadCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&OpenFileToReadOnUIThread, url,
base::BindOnce(&PostToIOThread<mojo::ScopedHandle>,
std::move(callback))));

@ -8,8 +8,10 @@
#include <utility>
#include "base/files/file_util.h"
#include "base/task/post_task.h"
#include "base/task/task_scheduler/task_scheduler.h"
#include "base/task/task_traits.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "net/base/net_errors.h"
@ -45,15 +47,15 @@ FileStreamForwarder::FileStreamForwarder(
buf_(base::MakeRefCounted<net::IOBufferWithSize>(kBufSize)),
weak_ptr_factory_(this) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&FileStreamForwarder::Start, base::Unretained(this)));
}
void FileStreamForwarder::Destroy() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&FileStreamForwarder::DestroyOnIOThread,
base::Unretained(this)));
}
@ -141,8 +143,8 @@ void FileStreamForwarder::OnWriteCompleted(bool result) {
void FileStreamForwarder::NotifyCompleted(bool result) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(!callback_.is_null());
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::BindOnce(std::move(callback_), result));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::BindOnce(std::move(callback_), result));
}
} // namespace arc

@ -8,12 +8,14 @@
#include "base/bind.h"
#include "base/memory/singleton.h"
#include "base/task/post_task.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chromeos/dbus/arc_oemcrypto_client.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "components/arc/arc_bridge_service.h"
#include "components/arc/arc_browser_context_keyed_service_factory_base.h"
#include "components/arc/common/protected_buffer_manager.mojom.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/gpu_service_registry.h"
#include "mojo/public/cpp/platform/platform_channel.h"
@ -141,7 +143,7 @@ void ArcOemCryptoBridge::ConnectToDaemon(
// We need to get the GPU interface on the IO thread, then after that is
// done it will run the Mojo call on our thread.
base::PostTaskAndReplyWithResult(
content::BrowserThread::GetTaskRunnerForThread(content::BrowserThread::IO)
base::CreateSingleThreadTaskRunnerWithTraits({content::BrowserThread::IO})
.get(),
FROM_HERE, base::BindOnce(&GetGpuBufferManagerOnIOThread),
base::BindOnce(&ArcOemCryptoBridge::FinishConnectingToDaemon,

@ -27,6 +27,7 @@
#include "components/arc/arc_bridge_service.h"
#include "components/arc/arc_browser_context_keyed_service_factory_base.h"
#include "components/keyed_service/core/keyed_service.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_source.h"
@ -155,8 +156,8 @@ void CreateQueryOnIOThread(std::unique_ptr<printing::PrintSettings> settings,
// Send initialized PrinterQuery to UI thread.
void OnSetSettingsDoneOnIOThread(scoped_refptr<printing::PrinterQuery> query,
PrinterQueryCallback callback) {
content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
base::BindOnce(std::move(callback), query));
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(std::move(callback), query));
}
std::unique_ptr<printing::PrinterSemanticCapsAndDefaults>
@ -374,8 +375,8 @@ class PrintJobHostImpl : public mojom::PrintJobHost,
data_size),
base::BindOnce(&PrintJobHostImpl::OnFileRead,
weak_ptr_factory_.GetWeakPtr()));
content::BrowserThread::PostTask(
content::BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(&CreateQueryOnIOThread, std::move(settings),
base::BindOnce(&PrintJobHostImpl::OnSetSettingsDone,
weak_ptr_factory_.GetWeakPtr())));

@ -10,12 +10,14 @@
#include "base/logging.h"
#include "base/memory/singleton.h"
#include "base/posix/unix_domain_socket.h"
#include "base/task/post_task.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
#include "base/trace_event/trace_config.h"
#include "components/arc/arc_bridge_service.h"
#include "components/arc/arc_browser_context_keyed_service_factory_base.h"
#include "components/arc/arc_service_manager.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/common/service_manager_connection.h"
#include "mojo/public/cpp/system/platform_handle.h"
@ -152,8 +154,8 @@ void ArcTracingBridge::StartTracing(const std::string& config,
mojo::WrapPlatformFile(write_fd.release()),
std::move(callback));
content::BrowserThread::PostTask(
content::BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(&ArcTracingReader::StartTracing, reader_.GetWeakPtr(),
std::move(read_fd)));
}
@ -185,8 +187,8 @@ void ArcTracingBridge::OnArcTracingStopped(bool success) {
is_stopping_ = false;
return;
}
content::BrowserThread::PostTask(
content::BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(&ArcTracingReader::StopTracing, reader_.GetWeakPtr(),
base::BindOnce(&ArcTracingBridge::OnTracingReaderStopped,
weak_ptr_factory_.GetWeakPtr())));
@ -264,8 +266,8 @@ void ArcTracingBridge::ArcTracingReader::StopTracing(
}
ring_buffer_.Clear();
content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
base::BindOnce(std::move(callback), data));
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(std::move(callback), data));
}
base::WeakPtr<ArcTracingBridge::ArcTracingReader>

@ -12,10 +12,12 @@
#include "base/memory/singleton.h"
#include "base/rand_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/post_task.h"
#include "base/threading/thread_checker.h"
#include "components/arc/arc_bridge_service.h"
#include "components/arc/arc_browser_context_keyed_service_factory_base.h"
#include "components/arc/common/video_decode_accelerator.mojom.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/gpu_service_registry.h"
#include "content/public/common/service_manager_connection.h"
@ -58,8 +60,8 @@ class VideoAcceleratorFactoryService : public mojom::VideoAcceleratorFactory {
void CreateDecodeAccelerator(
mojom::VideoDecodeAcceleratorRequest request) override {
content::BrowserThread::PostTask(
content::BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(
&content::BindInterfaceInGpuProcess<mojom::VideoDecodeAccelerator>,
std::move(request)));
@ -67,8 +69,8 @@ class VideoAcceleratorFactoryService : public mojom::VideoAcceleratorFactory {
void CreateEncodeAccelerator(
mojom::VideoEncodeAcceleratorRequest request) override {
content::BrowserThread::PostTask(
content::BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(
&content::BindInterfaceInGpuProcess<mojom::VideoEncodeAccelerator>,
std::move(request)));
@ -76,8 +78,8 @@ class VideoAcceleratorFactoryService : public mojom::VideoAcceleratorFactory {
void CreateProtectedBufferAllocator(
mojom::VideoProtectedBufferAllocatorRequest request) override {
content::BrowserThread::PostTask(
content::BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(&content::BindInterfaceInGpuProcess<
mojom::VideoProtectedBufferAllocator>,
std::move(request)));

@ -11,6 +11,7 @@
#include "base/callback.h"
#include "base/location.h"
#include "base/optional.h"
#include "base/task/post_task.h"
#include "base/time/time.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/attestation/attestation_ca_client.h"
@ -26,6 +27,7 @@
#include "components/policy/core/common/cloud/cloud_policy_client.h"
#include "components/policy/core/common/cloud/cloud_policy_manager.h"
#include "components/user_manager/known_user.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_details.h"
#include "net/cert/pem_tokenizer.h"
@ -339,8 +341,8 @@ void AttestationPolicyObserver::HandleGetCertificateFailure(
void AttestationPolicyObserver::Reschedule() {
if (++num_retries_ < retry_limit_) {
content::BrowserThread::PostDelayedTask(
content::BrowserThread::UI, FROM_HERE,
base::PostDelayedTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::BindRepeating(&AttestationPolicyObserver::Start,
weak_factory_.GetWeakPtr()),
base::TimeDelta::FromSeconds(retry_delay_));

@ -10,6 +10,7 @@
#include "base/callback.h"
#include "base/location.h"
#include "base/optional.h"
#include "base/task/post_task.h"
#include "base/time/time.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/attestation/attestation_ca_client.h"
@ -25,6 +26,7 @@
#include "components/policy/core/common/cloud/cloud_policy_client.h"
#include "components/policy/core/common/cloud/cloud_policy_manager.h"
#include "components/user_manager/known_user.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_details.h"
#include "net/cert/pem_tokenizer.h"
@ -207,8 +209,8 @@ void EnrollmentPolicyObserver::HandleEnrollmentId(
void EnrollmentPolicyObserver::RescheduleGetEnrollmentId() {
if (++num_retries_ < retry_limit_) {
content::BrowserThread::PostDelayedTask(
content::BrowserThread::UI, FROM_HERE,
base::PostDelayedTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&EnrollmentPolicyObserver::GetEnrollmentId,
weak_factory_.GetWeakPtr()),
base::TimeDelta::FromSeconds(retry_delay_));
@ -224,8 +226,8 @@ void EnrollmentPolicyObserver::HandleGetCertificateFailure(
// EID we will have after a device wipe, and should upload that.
GetEnrollmentId();
} else if (++num_retries_ < retry_limit_) {
content::BrowserThread::PostDelayedTask(
content::BrowserThread::UI, FROM_HERE,
base::PostDelayedTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&EnrollmentPolicyObserver::Start,
weak_factory_.GetWeakPtr()),
base::TimeDelta::FromSeconds(retry_delay_));

@ -13,6 +13,7 @@
#include "base/logging.h"
#include "base/synchronization/cancellation_flag.h"
#include "base/task/post_task.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
namespace chromeos {
@ -148,8 +149,8 @@ void FileFlusher::Job::ScheduleFinish() {
return;
finish_scheduled_ = true;
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::Bind(&Job::FinishOnUIThread, base::Unretained(this)));
}

@ -36,6 +36,7 @@
#include "chrome/common/pref_names.h"
#include "components/prefs/pref_service.h"
#include "components/user_manager/user_manager.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/notification_service.h"
@ -470,11 +471,9 @@ void BootTimesRecorder::AddMarker(std::vector<TimeMarker>* vector,
// Add the marker on the UI thread.
// Note that it's safe to use an unretained pointer to the vector because
// BootTimesRecorder's lifetime exceeds that of the UI thread message loop.
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&BootTimesRecorder::AddMarker,
base::Unretained(vector),
marker));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::Bind(&BootTimesRecorder::AddMarker,
base::Unretained(vector), marker));
}
}

@ -150,6 +150,7 @@
#include "components/user_manager/user.h"
#include "components/user_manager/user_manager.h"
#include "components/user_manager/user_names.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/media_capture_devices.h"
#include "content/public/browser/notification_service.h"
@ -230,8 +231,8 @@ void GotSystemSlotOnUIThread(
void GotSystemSlotOnIOThread(
base::Callback<void(crypto::ScopedPK11Slot)> callback_ui_thread,
crypto::ScopedPK11Slot system_slot) {
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&GotSystemSlotOnUIThread, callback_ui_thread,
std::move(system_slot)));
}
@ -502,8 +503,8 @@ class SystemTokenCertDBInitializer {
base::Callback<void(crypto::ScopedPK11Slot)> callback =
base::BindRepeating(&SystemTokenCertDBInitializer::InitializeDatabase,
weak_ptr_factory_.GetWeakPtr());
content::BrowserThread::PostTask(
content::BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(&GetSystemSlotOnIOThread, callback));
}
@ -647,8 +648,8 @@ void ChromeBrowserMainPartsChromeos::PostMainMessageLoopStart() {
void ChromeBrowserMainPartsChromeos::PreMainMessageLoopRun() {
// Set the crypto thread after the IO thread has been created/started.
TPMTokenLoader::Get()->SetCryptoTaskRunner(
content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::IO));
base::CreateSingleThreadTaskRunnerWithTraits(
{content::BrowserThread::IO}));
// Initialize NSS database for system token.
system_token_certdb_initializer_ =

@ -33,6 +33,7 @@
#include "chromeos/disks/disk_mount_manager.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "dbus/message.h"
#include "extensions/browser/extension_registry.h"
@ -98,8 +99,8 @@ class CrostiniManager::CrostiniRestarter
is_running_ = true;
// Skip to the end immediately if testing.
if (crostini_manager_->skip_restart_for_testing()) {
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&CrostiniRestarter::SetUpLxdContainerUserFinished,
base::WrapRefCounted(this),
ConciergeClientResult::SUCCESS));
@ -495,8 +496,8 @@ void CrostiniManager::InstallTerminaComponent(CrostiniResultCallback callback) {
g_browser_process->platform_part()->cros_component_manager();
if (!cros_component_manager) {
// Running in a unit test. We still PostTask to prevent races.
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&CrostiniManager::OnInstallTerminaComponent,
weak_ptr_factory_.GetWeakPtr(), std::move(callback),
true, component_manager_load_error_for_testing_,

@ -43,6 +43,7 @@
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/common/extension_urls.h"
#include "net/base/load_flags.h"
@ -638,9 +639,8 @@ void ServicesCustomizationDocument::OnSimpleLoaderComplete(
} else {
if (num_retries_ < kMaxFetchRetries) {
num_retries_++;
content::BrowserThread::PostDelayedTask(
content::BrowserThread::UI,
FROM_HERE,
base::PostDelayedTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::Bind(&ServicesCustomizationDocument::StartFileFetch,
weak_ptr_factory_.GetWeakPtr()),
base::TimeDelta::FromSeconds(kRetriesDelayInSec));

@ -8,7 +8,9 @@
#include "base/bind.h"
#include "base/files/file_path.h"
#include "base/task/post_task.h"
#include "chrome/browser/component_updater/cros_component_installer_chromeos.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "dbus/bus.h"
#include "dbus/message.h"
@ -79,8 +81,8 @@ void ComponentUpdaterServiceProvider::Start(
void ComponentUpdaterServiceProvider::EmitInstalledSignal(
const std::string& component) {
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(
&ComponentUpdaterServiceProvider::EmitInstalledSignalInternal,
weak_ptr_factory_.GetWeakPtr(), component));

@ -24,6 +24,7 @@
#include "chrome/browser/download/download_history.h"
#include "components/drive/chromeos/file_system_interface.h"
#include "components/drive/drive.pb.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/download_item_utils.h"
@ -322,8 +323,8 @@ void DownloadHandler::OnDownloadCreated(DownloadManager* manager,
// Remove any persisted Drive DownloadItem. crbug.com/171384
if (IsPersistedDriveDownload(drive_tmp_download_path_, download)) {
// Remove download later, since doing it here results in a crash.
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&DownloadHandler::RemoveDownload,
weak_ptr_factory_.GetWeakPtr(),
static_cast<void*>(manager), download->GetId()));

@ -14,9 +14,11 @@
#include "base/callback_helpers.h"
#include "base/logging.h"
#include "base/sequenced_task_runner.h"
#include "base/task/post_task.h"
#include "components/drive/chromeos/file_system_interface.h"
#include "components/drive/drive.pb.h"
#include "components/drive/local_file_reader.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "google_apis/drive/task_util.h"
#include "net/base/io_buffer.h"
@ -317,8 +319,8 @@ void GetFileContent(
const base::Callback<void(const base::Closure&)>& reply_callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
BrowserThread::PostTaskAndReplyWithResult(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraitsAndReplyWithResult(
FROM_HERE, {BrowserThread::UI},
base::Bind(&GetFileContentOnUIThread, file_system_getter, drive_file_path,
base::Passed(google_apis::CreateRelayCallback(
std::move(initialized_callback))),

@ -15,6 +15,7 @@
#include "chrome/browser/chromeos/drive/drive_integration_service.h"
#include "chrome/browser/chromeos/drive/file_system_util.h"
#include "chrome/browser/chromeos/drive/fileapi/fileapi_worker.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "google_apis/drive/task_util.h"
#include "storage/browser/blob/shareable_file_reference.h"
@ -36,8 +37,8 @@ void PostFileSystemCallback(
const base::Closure& on_error_callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&fileapi_internal::RunFileSystemCallback,
file_system_getter, function,
on_error_callback.is_null()
@ -58,10 +59,10 @@ void RunCreateOrOpenFileCallback(
// It will be provided as a FileSystem::OpenFileCallback's argument later.
// (crbug.com/259184).
std::move(callback).Run(
std::move(file),
base::Bind(&google_apis::RunTaskWithTaskRunner,
BrowserThread::GetTaskRunnerForThread(BrowserThread::UI),
close_callback_on_ui_thread));
std::move(file), base::Bind(&google_apis::RunTaskWithTaskRunner,
base::CreateSingleThreadTaskRunnerWithTraits(
{BrowserThread::UI}),
close_callback_on_ui_thread));
}
// Runs CreateOrOpenFile when the error happens.

@ -6,8 +6,10 @@
#include <utility>
#include "base/task/post_task.h"
#include "chrome/browser/chromeos/drive/drive_integration_service.h"
#include "chrome/browser/chromeos/drive/file_system_util.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "mojo/public/cpp/bindings/callback_helpers.h"
#include "storage/browser/fileapi/file_system_operation_context.h"
@ -131,8 +133,8 @@ void DriveFsAsyncFileUtil::CopyFileLocal(
CopyOrMoveOption option,
CopyFileProgressCallback progress_callback,
StatusCallback callback) {
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(
&CopyOperation::Start,
base::Unretained(new CopyOperation(

@ -8,6 +8,7 @@
#include "base/bind.h"
#include "base/files/file_path.h"
#include "base/task/post_task.h"
#include "chrome/browser/chromeos/drive/file_system_util.h"
#include "chrome/browser/chromeos/drive/fileapi/async_file_util.h"
#include "chrome/browser/chromeos/drive/fileapi/fileapi_worker.h"
@ -15,6 +16,7 @@
#include "chrome/browser/chromeos/drive/fileapi/webkit_file_stream_writer_impl.h"
#include "components/drive/chromeos/file_system_interface.h"
#include "components/drive/drive_api_util.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "storage/browser/fileapi/async_file_util.h"
#include "storage/browser/fileapi/file_stream_reader.h"
@ -38,8 +40,8 @@ void GetRedirectURLForContentsOnUIThreadWithResourceEntry(
entry->file_specific_info().is_hosted_document()) {
url = GURL(entry->alternate_url());
}
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
base::BindOnce(callback, url));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::IO},
base::BindOnce(callback, url));
}
// Called on the UI thread after
@ -52,14 +54,14 @@ void GetRedirectURLForContentsOnUIThread(
FileSystemInterface* const file_system =
fileapi_internal::GetFileSystemFromUrl(url);
if (!file_system) {
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
base::BindOnce(callback, GURL()));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::IO},
base::BindOnce(callback, GURL()));
return;
}
const base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url);
if (file_path.empty()) {
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
base::BindOnce(callback, GURL()));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::IO},
base::BindOnce(callback, GURL()));
return;
}
@ -134,8 +136,8 @@ void FileSystemBackendDelegate::GetRedirectURLForContents(
const storage::FileSystemURL& url,
const storage::URLCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&GetRedirectURLForContentsOnUIThread, url, callback));
}

@ -8,8 +8,10 @@
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/task/post_task.h"
#include "chrome/browser/chromeos/drive/fileapi/fileapi_worker.h"
#include "components/drive/file_system_core_util.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "google_apis/drive/task_util.h"
#include "net/base/io_buffer.h"
@ -29,8 +31,8 @@ void CreateWritableSnapshotFile(
const fileapi_internal::CreateWritableSnapshotFileCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(
&fileapi_internal::RunFileSystemCallback, file_system_getter,
base::Bind(&fileapi_internal::CreateWritableSnapshotFile, drive_path,
@ -59,9 +61,8 @@ WebkitFileStreamWriterImpl::~WebkitFileStreamWriterImpl() {
// It is necessary to close the local file in advance.
local_file_writer_.reset();
DCHECK(!close_callback_on_ui_thread_.is_null());
BrowserThread::PostTask(BrowserThread::UI,
FROM_HERE,
close_callback_on_ui_thread_);
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
close_callback_on_ui_thread_);
}
}
@ -143,9 +144,8 @@ void WebkitFileStreamWriterImpl::WriteAfterCreateWritableSnapshotFile(
// Here the file is internally created. To revert the operation, close
// the file.
DCHECK(!close_callback_on_ui_thread.is_null());
BrowserThread::PostTask(BrowserThread::UI,
FROM_HERE,
close_callback_on_ui_thread);
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
close_callback_on_ui_thread);
}
base::ResetAndReturn(&pending_cancel_callback_).Run(net::OK);

@ -41,6 +41,7 @@
#include "components/drive/file_system_core_util.h"
#include "components/storage_monitor/storage_info.h"
#include "components/storage_monitor/storage_monitor.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/render_frame_host.h"
@ -155,8 +156,8 @@ void OnCopyProgress(
int64_t size) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&NotifyCopyProgress, profile_id, *operation_id, type,
source_url, destination_url, size));
}
@ -188,8 +189,8 @@ void OnCopyCompleted(
base::File::Error error) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&NotifyCopyCompletion, profile_id, *operation_id,
source_url, destination_url, error));
}
@ -253,8 +254,8 @@ void ComputeChecksumRespondOnUIThread(
const base::Callback<void(const std::string&)>& callback,
const std::string& hash) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::BindOnce(callback, hash));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::BindOnce(callback, hash));
}
// Calls a response callback on the UI thread.
@ -263,8 +264,8 @@ void GetFileMetadataRespondOnUIThread(
base::File::Error result,
const base::File::Info& file_info) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::BindOnce(callback, result, file_info));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::BindOnce(callback, result, file_info));
}
} // namespace
@ -327,16 +328,16 @@ void PostResponseCallbackTaskToUIThread(
const FileWatchFunctionBase::ResponseCallback& callback,
bool success) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::BindOnce(callback, success));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::BindOnce(callback, success));
}
void PostNotificationCallbackTaskToUIThread(
const storage::WatcherManager::NotificationCallback& callback,
storage::WatcherManager::ChangeType type) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::BindOnce(callback, type));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::BindOnce(callback, type));
}
} // namespace
@ -373,8 +374,8 @@ bool FileWatchFunctionBase::RunAsync() {
file_manager::EventRouter* const event_router =
file_manager::EventRouterFactory::GetForProfile(GetProfile());
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&FileWatchFunctionBase::RunAsyncOnIOThread, this,
file_system_context, file_system_url,
event_router->GetWeakPtr()));
@ -391,8 +392,8 @@ void FileWatchFunctionBase::RunAsyncOnIOThread(
file_system_context->GetWatcherManager(file_system_url.type());
if (!watcher_manager) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(
&FileWatchFunctionBase::PerformFallbackFileWatchOperationOnUIThread,
this, file_system_url, event_router));
@ -705,8 +706,8 @@ bool FileManagerPrivateInternalStartCopyFunction::RunAsync() {
// spece by freeing drive caches.
if (destination_url_.filesystem_id() ==
file_manager::util::GetDownloadsMountPointName(GetProfile())) {
return BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
return base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&GetFileMetadataOnIOThread, file_system_context,
source_url_,
storage::FileSystemOperation::GET_METADATA_FIELD_SIZE,
@ -715,8 +716,8 @@ bool FileManagerPrivateInternalStartCopyFunction::RunAsync() {
this)));
}
return BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
return base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(
&FileManagerPrivateInternalStartCopyFunction::RunAfterFreeDiskSpace,
this, true));
@ -767,8 +768,8 @@ void FileManagerPrivateInternalStartCopyFunction::RunAfterFreeDiskSpace(
scoped_refptr<storage::FileSystemContext> file_system_context =
file_manager::util::GetFileSystemContextForRenderFrameHost(
GetProfile(), render_frame_host());
const bool result = BrowserThread::PostTaskAndReplyWithResult(
BrowserThread::IO, FROM_HERE,
const bool result = base::PostTaskWithTraitsAndReplyWithResult(
FROM_HERE, {BrowserThread::IO},
base::Bind(&StartCopyOnIOThread, GetProfile(), file_system_context,
source_url_, destination_url_),
base::Bind(
@ -798,9 +799,10 @@ bool FileManagerPrivateCancelCopyFunction::RunAsync() {
GetProfile(), render_frame_host());
// We don't much take care about the result of cancellation.
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
base::BindOnce(&CancelCopyOnIOThread,
file_system_context, params->copy_id));
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&CancelCopyOnIOThread, file_system_context,
params->copy_id));
SendResponse(true);
return true;
}
@ -911,8 +913,8 @@ bool FileManagerPrivateInternalComputeChecksumFunction::RunAsync() {
&ComputeChecksumRespondOnUIThread,
base::Bind(&FileManagerPrivateInternalComputeChecksumFunction::Respond,
this));
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&FileStreamMd5Digester::GetMd5Digest,
base::Unretained(digester_.get()), base::Passed(&reader),
result_callback));

@ -10,6 +10,7 @@
#include "ash/public/cpp/ash_pref_names.h"
#include "base/stl_util.h"
#include "base/task/post_task.h"
#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_service.h"
#include "chrome/browser/chromeos/login/quick_unlock/auth_token.h"
#include "chrome/browser/chromeos/login/quick_unlock/pin_backend.h"
@ -25,6 +26,7 @@
#include "chromeos/login/auth/extended_authenticator.h"
#include "chromeos/login/auth/user_context.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/browser/event_router.h"
@ -244,8 +246,8 @@ QuickUnlockPrivateGetAuthTokenFunction::Run() {
// is needed.
AddRef();
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&chromeos::ExtendedAuthenticator::AuthenticateToCheck,
extended_authenticator_.get(), user_context,
base::Closure()));

@ -17,6 +17,7 @@
#include "base/sequenced_task_runner.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/task/post_task.h"
#include "base/task_runner_util.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
@ -33,6 +34,7 @@
#include "components/strings/grit/components_strings.h"
#include "components/user_manager/user.h"
#include "components/user_manager/user_manager.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/browser/event_router.h"
#include "ui/base/l10n/l10n_util.h"
@ -282,8 +284,8 @@ void WallpaperPrivateGetStringsFunction::OnWallpaperInfoReturned(
ExtensionFunction::ResponseAction
WallpaperPrivateGetSyncSettingFunction::Run() {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&WallpaperPrivateGetSyncSettingFunction::
CheckProfileSyncServiceStatus,
this));
@ -324,8 +326,8 @@ void WallpaperPrivateGetSyncSettingFunction::CheckProfileSyncServiceStatus() {
// the first time configuration). In this case GetActiveDataTypes() returns an
// empty set. So re-check the status later.
retry_number_++;
BrowserThread::PostDelayedTask(
BrowserThread::UI, FROM_HERE,
base::PostDelayedTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&WallpaperPrivateGetSyncSettingFunction::
CheckProfileSyncServiceStatus,
this),
@ -576,19 +578,19 @@ void WallpaperPrivateGetThumbnailFunction::Get(const base::FilePath& path) {
std::string data;
if (GetData(path, &data)) {
if (data.empty()) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&WallpaperPrivateGetThumbnailFunction::FileNotLoaded,
this));
} else {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&WallpaperPrivateGetThumbnailFunction::FileLoaded,
this, data));
}
} else {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&WallpaperPrivateGetThumbnailFunction::Failure, this,
path.BaseName().value()));
}
@ -630,12 +632,12 @@ void WallpaperPrivateSaveThumbnailFunction::Save(
WallpaperFunctionBase::AssertCalledOnWallpaperSequence(
WallpaperFunctionBase::GetNonBlockingTaskRunner());
if (SaveData(chrome::DIR_CHROMEOS_WALLPAPER_THUMBNAILS, file_name, data)) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&WallpaperPrivateSaveThumbnailFunction::Success, this));
} else {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&WallpaperPrivateSaveThumbnailFunction::Failure, this,
file_name));
}

@ -23,6 +23,7 @@
#include "chromeos/chromeos_switches.h"
#include "components/metrics/serialization/metric_sample.h"
#include "components/metrics/serialization/serialization_utils.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
using content::BrowserThread;
@ -94,9 +95,8 @@ void ExternalMetrics::RecordActionUI(const std::string& action_string) {
}
void ExternalMetrics::RecordAction(const std::string& action) {
BrowserThread::PostTask(
BrowserThread::UI,
FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::Bind(&ExternalMetrics::RecordActionUI, this, action));
}
@ -105,8 +105,8 @@ void ExternalMetrics::RecordCrashUI(const std::string& crash_kind) {
}
void ExternalMetrics::RecordCrash(const std::string& crash_kind) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::Bind(&ExternalMetrics::RecordCrashUI, this, crash_kind));
}

Some files were not shown because too many files have changed in this diff Show More