From: yh106.jung Date: Thu, 16 Feb 2023 05:58:41 +0000 (-0800) Subject: Post tasks to proper threads X-Git-Tag: submit/tizen/20230227.160252~58 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=26b8e44c18d5dd0dff115b582eede17ba97af20a;p=platform%2Fframework%2Fweb%2Fchromium-efl.git Post tasks to proper threads This patch posts tasks to proper content browser's threads, not to threadpool. Change-Id: I59efb81e1ac2f470d1c4cf8e84915b73766faec7 Signed-off-by: yh106.jung --- diff --git a/tizen_src/ewk/efl_integration/browser/browsing_data_remover_efl.cc b/tizen_src/ewk/efl_integration/browser/browsing_data_remover_efl.cc index 17b2a62..b6499f6 100644 --- a/tizen_src/ewk/efl_integration/browser/browsing_data_remover_efl.cc +++ b/tizen_src/ewk/efl_integration/browser/browsing_data_remover_efl.cc @@ -7,7 +7,6 @@ #include "base/bind.h" #include "base/logging.h" #include "base/task/bind_post_task.h" -#include "base/task/thread_pool.h" #include "base/threading/thread_task_runner_handle.h" #include "content/common/render_messages_efl.h" #include "content/public/browser/browser_context.h" @@ -116,8 +115,7 @@ void BrowsingDataRemoverEfl::RemoveImpl(int remove_mask, browser_context_->GetStoragePartition(NULL)->GetQuotaManager(); } waiting_for_clear_quota_managed_data_ = true; - base::ThreadPool::PostTask( - FROM_HERE, {BrowserThread::IO}, + content::GetIOThreadTaskRunner({})->PostTask(FROM_HERE, base::BindOnce(&BrowsingDataRemoverEfl::ClearQuotaManagedDataOnIOThread, base::Unretained(this))); } @@ -238,8 +236,7 @@ void BrowsingDataRemoverEfl::CheckQuotaManagedDataDeletionStatus() { quota_managed_origins_to_delete_count_ != 0) return; - base::ThreadPool::PostTask( - FROM_HERE, {BrowserThread::UI}, + content::GetUIThreadTaskRunner({})->PostTask(FROM_HERE, base::BindOnce(&BrowsingDataRemoverEfl::OnQuotaManagedDataDeleted, base::Unretained(this))); } diff --git a/tizen_src/ewk/efl_integration/browser/geolocation/geolocation_permission_context_efl.cc b/tizen_src/ewk/efl_integration/browser/geolocation/geolocation_permission_context_efl.cc index 68db2da..695ffe1 100644 --- a/tizen_src/ewk/efl_integration/browser/geolocation/geolocation_permission_context_efl.cc +++ b/tizen_src/ewk/efl_integration/browser/geolocation/geolocation_permission_context_efl.cc @@ -78,8 +78,7 @@ void GeolocationPermissionContextEfl::RequestPermission( int render_frame_id, const GURL& requesting_frame, base::OnceCallback callback) const { - base::ThreadPool::PostTask( - FROM_HERE, {BrowserThread::UI}, + content::GetUIThreadTaskRunner({})->PostTask(FROM_HERE, base::BindOnce( &GeolocationPermissionContextEfl::RequestPermissionOnUIThread, weak_ptr_factory_.GetWeakPtr(), render_process_id, render_frame_id, diff --git a/tizen_src/ewk/efl_integration/browser/quota_permission_context_efl.cc b/tizen_src/ewk/efl_integration/browser/quota_permission_context_efl.cc index f24bee9..5aea03e 100644 --- a/tizen_src/ewk/efl_integration/browser/quota_permission_context_efl.cc +++ b/tizen_src/ewk/efl_integration/browser/quota_permission_context_efl.cc @@ -17,8 +17,7 @@ void QuotaPermissionContextEfl::RequestQuotaPermission( int render_process_id, QuotaPermissionContext::PermissionCallback callback) { if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { - base::ThreadPool::PostTask( - FROM_HERE, {BrowserThread::UI}, + content::GetUIThreadTaskRunner({})->PostTask(FROM_HERE, base::BindOnce(&QuotaPermissionContextEfl::RequestQuotaPermission, this, params, render_process_id, std::move(callback))); return; @@ -48,8 +47,7 @@ void QuotaPermissionContextEfl::DispatchCallback( DCHECK_EQ(false, callback.is_null()); if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)) { - base::ThreadPool::PostTask( - FROM_HERE, {BrowserThread::IO}, + content::GetIOThreadTaskRunner({})->PostTask(FROM_HERE, base::BindOnce(&QuotaPermissionContextEfl::DispatchCallback, std::move(callback), response)); return; diff --git a/tizen_src/ewk/efl_integration/browser/resource_dispatcher_host_delegate_efl.cc b/tizen_src/ewk/efl_integration/browser/resource_dispatcher_host_delegate_efl.cc index 1ed69cb..2be3a74 100644 --- a/tizen_src/ewk/efl_integration/browser/resource_dispatcher_host_delegate_efl.cc +++ b/tizen_src/ewk/efl_integration/browser/resource_dispatcher_host_delegate_efl.cc @@ -137,8 +137,7 @@ void ResourceDispatcherHostDelegateEfl::TriggerNewDownloadStartCallback( // Since called by IO thread callback trigger needs to // be posted to UI thread so that IO thread is unblocked - base::ThreadPool::PostTaskWithTraits( - FROM_HERE, {BrowserThread::UI}, + content::GetUIThreadTaskRunner({})->PostTask(FROM_HERE, base::BindOnce(TriggerNewDownloadStartCallbackOnUIThread, render_process_id, render_view_id, request->url(), user_agent, content_disposition, mime_type, diff --git a/tizen_src/ewk/efl_integration/cookie_manager.cc b/tizen_src/ewk/efl_integration/cookie_manager.cc index 917ebb4..326328e 100644 --- a/tizen_src/ewk/efl_integration/cookie_manager.cc +++ b/tizen_src/ewk/efl_integration/cookie_manager.cc @@ -10,7 +10,6 @@ #include "base/logging.h" #include "base/stl_util.h" #include "base/synchronization/waitable_event.h" -#include "base/task/thread_pool.h" #include "browser/scoped_allow_wait_for_legacy_web_view_api.h" #include "browser_context_efl.h" #include "content/browser/storage_partition_impl.h" @@ -126,8 +125,7 @@ void CookieManager::DeleteCookiesOnIOThread(const std::string& url, void CookieManager::DeleteCookiesAsync(const std::string& url, const std::string& cookie_name) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - base::ThreadPool::PostTask( - FROM_HERE, {BrowserThread::IO}, + content::GetIOThreadTaskRunner({})->PostTask(FROM_HERE, base::BindOnce(&CookieManager::DeleteCookiesOnIOThread, base::Unretained(this), url, cookie_name)); } @@ -153,8 +151,7 @@ void CookieManager::SetStoragePath(const std::string& path, scoped_refptr context_getter = GetContextGetter(); if (context_getter.get()) { - base::ThreadPool::PostTask( - FROM_HERE, {BrowserThread::IO}, + content::GetIOThreadTaskRunner({})->PostTask(FROM_HERE, base::BindOnce(SetStoragePathOnIOThread, context_getter, path, persist_session_cookies, file_storage_type)); } @@ -162,8 +159,7 @@ void CookieManager::SetStoragePath(const std::string& path, void CookieManager::GetAcceptPolicyAsync(Ewk_Cookie_Manager_Policy_Async_Get_Cb callback, void *data) { AutoLock lock(lock_); - base::ThreadPool::PostTask( - FROM_HERE, {BrowserThread::UI}, + content::GetUIThreadTaskRunner({})->PostTask(FROM_HERE, base::BindOnce(&TriggerHostPolicyGetCallbackAsyncOnUIThread, cookie_policy_, callback, data)); } @@ -171,8 +167,7 @@ void CookieManager::GetAcceptPolicyAsync(Ewk_Cookie_Manager_Policy_Async_Get_Cb void CookieManager::GetHostNamesWithCookiesAsync(AsyncHostnamesGetCb callback, void *data) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); host_callback_queue_.push(new EwkGetHostCallback(callback, data)); - base::ThreadPool::PostTask( - FROM_HERE, {BrowserThread::IO}, + content::GetIOThreadTaskRunner({})->PostTask(FROM_HERE, base::BindOnce(&CookieManager::FetchCookiesOnIOThread, GetSharedThis())); } @@ -189,9 +184,9 @@ void CookieManager::FetchCookiesOnIOThread() { void CookieManager::OnFetchComplete(const net::CookieList& cookies) { if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { - base::ThreadPool::PostTask(FROM_HERE, {BrowserThread::UI}, - base::BindOnce(&CookieManager::OnFetchComplete, - base::Unretained(this), cookies)); + content::GetUIThreadTaskRunner({})->PostTask(FROM_HERE, + base::BindOnce(&CookieManager::OnFetchComplete, + base::Unretained(this), cookies)); return; } if (!host_callback_queue_.empty()) { @@ -282,8 +277,7 @@ void CookieManager::AllowFileSchemeCookies(bool allow) { ->GetDefaultStoragePartition() ->GetCookieManagerForBrowserProcess(); - base::ThreadPool::PostTask( - FROM_HERE, {BrowserThread::IO}, + content::GetIOThreadTaskRunner({})->PostTask(FROM_HERE, base::BindOnce(&CookieManager::AllowFileSchemeCookiesOnIOThread, weak_ptr_factory_.GetWeakPtr(), cookie_manager, allow)); } @@ -341,8 +335,7 @@ std::string CookieManager::GetCookiesForURL(const std::string& url) { std::string cookie_value; base::WaitableEvent completion(base::WaitableEvent::ResetPolicy::AUTOMATIC, base::WaitableEvent::InitialState::NOT_SIGNALED); - base::ThreadPool::PostTask( - FROM_HERE, {BrowserThread::IO}, + content::GetIOThreadTaskRunner({})->PostTask(FROM_HERE, base::BindOnce(GetCookieValueOnIOThread, cookie_store, GURL(url), &cookie_value, &completion)); // allow wait temporarily. diff --git a/tizen_src/ewk/efl_integration/eweb_context.cc b/tizen_src/ewk/efl_integration/eweb_context.cc index a8254fc..7cf189b 100644 --- a/tizen_src/ewk/efl_integration/eweb_context.cc +++ b/tizen_src/ewk/efl_integration/eweb_context.cc @@ -12,7 +12,6 @@ #endif #include "base/synchronization/waitable_event.h" -#include "base/task/thread_pool.h" #include "browser/favicon/favicon_database.h" #include "browser/password_manager/password_helper_efl.h" #include "browser/tizen_extensible_host.h" @@ -165,8 +164,8 @@ void OnTemporaryUsageAndQuotaObtained( // We still trigger callback. usage = 0; } - base::ThreadPool::PostTask(FROM_HERE, {BrowserThread::UI}, - base::BindOnce(callback, usage, user_data)); + content::GetUIThreadTaskRunner({})->PostTask(FROM_HERE, + base::BindOnce(callback, usage, user_data)); } void OnGetWebDBOrigins(storage::DatabaseQuotaClient* client, @@ -179,8 +178,8 @@ void OnGetWebDBOrigins(storage::DatabaseQuotaClient* client, new _Ewk_Security_Origin(key.origin().GetURL()); origin_list = eina_list_append(origin_list, sec_origin); } - base::ThreadPool::PostTask(FROM_HERE, {BrowserThread::UI}, - base::BindOnce(callback, origin_list, user_data)); + content::GetUIThreadTaskRunner({})->PostTask(FROM_HERE, + base::BindOnce(callback, origin_list, user_data)); } void OnGetWebDBUsageForOrigin(Ewk_Web_Database_Usage_Get_Callback callback, @@ -201,8 +200,8 @@ void OnGetFileSystemOrigins( new _Ewk_Security_Origin(key.origin().GetURL()); origin_list = eina_list_append(origin_list, sec_origin); } - base::ThreadPool::PostTask(FROM_HERE, {BrowserThread::UI}, - base::BindOnce(callback, origin_list, user_data)); + content::GetUIThreadTaskRunner({})->PostTask(FROM_HERE, + base::BindOnce(callback, origin_list, user_data)); } void OnGetPasswordDataList( @@ -519,14 +518,12 @@ void EWebContext::SetProxyUri(const char* uri) { config.proxy_rules().ParseFromString(proxy_uri_); base::WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC, base::WaitableEvent::InitialState::NOT_SIGNALED); - base::ThreadPool::PostTask( - FROM_HERE, {BrowserThread::IO}, - base::BindOnce( - &SetProxyConfigCallbackOnIOThread, &done, - base::RetainedRef( - BrowserContext::GetDefaultStoragePartition(browser_context()) - ->GetURLRequestContext()), - config)); + content::GetIOThreadTaskRunner({})->PostTask(FROM_HERE, base::BindOnce( + &SetProxyConfigCallbackOnIOThread, &done, + base::RetainedRef( + BrowserContext::GetDefaultStoragePartition(browser_context()) + ->GetURLRequestContext()), + config)); done.Wait(); #endif } @@ -609,8 +606,7 @@ void EWebContext::GetApplicationCacheUsage( content::StoragePartition* partition = BrowserContext::GetStoragePartition(browser_context_.get(), NULL); - base::ThreadPool::PostTask( - FROM_HERE, {BrowserThread::IO}, + content::GetIOThreadTaskRunner({})->PostTask(FROM_HERE, base::BindOnce(&storage::QuotaManager::GetUsageAndQuota, partition->GetQuotaManager(), url, blink::mojom::StorageType::kTemporary, @@ -649,8 +645,7 @@ void EWebContext::LocalStorageUsageForOrigin( void EWebContext::WebStorageDelete() { if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { - base::ThreadPool::PostTask( - FROM_HERE, {BrowserThread::UI}, + content::GetUIThreadTaskRunner({})->PostTask(FROM_HERE, base::BindOnce(&EWebContext::WebStorageDelete, base::Unretained(this))); return; } @@ -661,8 +656,7 @@ void EWebContext::WebStorageDelete() { void EWebContext::WebStorageDeleteForOrigin(const GURL& origin) { if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { - base::ThreadPool::PostTask( - FROM_HERE, {BrowserThread::UI}, + content::GetUIThreadTaskRunner({})->PostTask(FROM_HERE, base::BindOnce(&EWebContext::WebStorageDeleteForOrigin, base::Unretained(this), origin)); return; @@ -693,8 +687,7 @@ void EWebContext::WebStorageOriginsAllGet( void EWebContext::IndexedDBDelete() { if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { - base::ThreadPool::PostTask( - FROM_HERE, {BrowserThread::UI}, + content::GetUIThreadTaskRunner({})->PostTask(FROM_HERE, base::BindOnce(&EWebContext::IndexedDBDelete, base::Unretained(this))); return; } @@ -705,9 +698,9 @@ void EWebContext::IndexedDBDelete() { void EWebContext::WebDBDelete(const GURL& host) { if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { - base::ThreadPool::PostTask(FROM_HERE, {BrowserThread::UI}, - base::BindOnce(&EWebContext::WebDBDelete, - base::Unretained(this), host)); + content::GetUIThreadTaskRunner({})->PostTask(FROM_HERE, + base::BindOnce(&EWebContext::WebDBDelete, + base::Unretained(this), host)); return; } BrowsingDataRemoverEfl* remover = @@ -750,9 +743,9 @@ void EWebContext::GetWebDBUsageForOrigin( void EWebContext::FileSystemDelete(const GURL& host) { if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { - base::ThreadPool::PostTask(FROM_HERE, {BrowserThread::UI}, - base::BindOnce(&EWebContext::FileSystemDelete, - base::Unretained(this), host)); + content::GetUIThreadTaskRunner({})->PostTask(FROM_HERE, + base::BindOnce(&EWebContext::FileSystemDelete, + base::Unretained(this), host)); return; } BrowsingDataRemoverEfl* remover = @@ -812,9 +805,9 @@ Evas_Object* EWebContext::AddFaviconObject(const char* uri, void EWebContext::ClearCandidateData() { #if defined(TIZEN_AUTOFILL_SUPPORT) if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { - base::ThreadPool::PostTask(FROM_HERE, {BrowserThread::UI}, - base::BindOnce(&EWebContext::ClearCandidateData, - base::Unretained(this))); + content::GetUIThreadTaskRunner({})->PostTask(FROM_HERE, + base::BindOnce(&EWebContext::ClearCandidateData, + base::Unretained(this))); return; } WebDataServiceFactoryEfl* webDataServiceInstance = diff --git a/tizen_src/ewk/efl_integration/eweb_view.cc b/tizen_src/ewk/efl_integration/eweb_view.cc index 9ec559c7..ede6cd4 100644 --- a/tizen_src/ewk/efl_integration/eweb_view.cc +++ b/tizen_src/ewk/efl_integration/eweb_view.cc @@ -591,10 +591,8 @@ void EWebView::Suspend() { rfh->BlockRequestsForFrame(); #endif #if 0 - content::BrowserThread::PostTask( - content::BrowserThread::IO, FROM_HERE, - base::BindOnce(&content::ResourceDispatcherHost::BlockRequestsForFrameFromUI, - rfh)); + content::GetIOThreadTaskRunner({})->PostTask(FROM_HERE, base::BindOnce( + &content::ResourceDispatcherHost::BlockRequestsForFrameFromUI, rfh)); if (rvh) rvh->Send(new EwkViewMsg_SuspendScheduledTask(rvh->GetRoutingID())); @@ -611,11 +609,9 @@ void EWebView::Resume() { rfh->ResumeBlockedRequestsForFrame(); #endif #if 0 - content::BrowserThread::PostTask( - content::BrowserThread::IO, FROM_HERE, - base::BindOnce( - &content::ResourceDispatcherHost::ResumeBlockedRequestsForFrameFromUI, - rfh)); + content::GetIOThreadTaskRunner({})->PostTask(FROM_HERE, base::BindOnce( + &content::ResourceDispatcherHost::ResumeBlockedRequestsForFrameFromUI, + rfh)); if (rvh) rvh->Send(new EwkViewMsg_ResumeScheduledTasks(rvh->GetRoutingID())); @@ -2424,8 +2420,7 @@ void EWebView::SyncAcceptLanguages(const std::string& accept_languages) { } void EWebView::HandleRendererProcessCrash() { - base::ThreadPool::PostTask( - FROM_HERE, {BrowserThread::UI}, + content::GetUIThreadTaskRunner({})->PostTask(FROM_HERE, base::BindOnce(&EWebView::InvokeWebProcessCrashedCallback, base::Unretained(this))); } @@ -2741,8 +2736,7 @@ void EWebView::SendDelayedMessages(RenderViewHost* render_view_host) { DCHECK(render_view_host); if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { - base::ThreadPool::PostTask( - FROM_HERE, {BrowserThread::UI}, + content::GetUIThreadTaskRunner({})->PostTask(FROM_HERE, base::BindOnce(&EWebView::SendDelayedMessages, base::Unretained(this), render_view_host)); return; @@ -2838,8 +2832,7 @@ void EWebView::InvokeExceededIndexedDatabaseQuotaCallback( const GURL& origin, int64_t current_quota) { if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { - base::ThreadPool::PostTask( - FROM_HERE, {BrowserThread::UI}, + content::GetUIThreadTaskRunner({})->PostTask(FROM_HERE, base::BindOnce(&EWebView::InvokeExceededIndexedDatabaseQuotaCallback, base::Unretained(this), origin, current_quota)); return; diff --git a/tizen_src/ewk/efl_integration/url_request_context_getter_efl.cc b/tizen_src/ewk/efl_integration/url_request_context_getter_efl.cc index 2d320c3..82a6dce 100644 --- a/tizen_src/ewk/efl_integration/url_request_context_getter_efl.cc +++ b/tizen_src/ewk/efl_integration/url_request_context_getter_efl.cc @@ -249,8 +249,7 @@ void URLRequestContextGetterEfl::SetCookieStoragePath( } if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { - base::ThreadPool::PostTask( - FROM_HERE, {BrowserThread::IO}, + content::GetIOThreadTaskRunner({})->PostTask(FROM_HERE, base::BindOnce(&URLRequestContextGetterEfl::SetCookieStoragePath, this, path, persist_session_cookies, file_storage)); return;