From e11049dc823a710f6161929a618eb7dd5e0a5ba6 Mon Sep 17 00:00:00 2001 From: Bakka Uday Kiran Date: Wed, 11 Jan 2023 10:43:40 +0530 Subject: [PATCH] [M108 Migration] Remove usage of deprecated BrowserThread::DB/FILE BrowserThread::DB/FILE have been deprecated in upstream chromium code. This commit removes EWK_BRINGUP macro by replacing BrowserThread::DB/FILE with SequencedTaskRunner. Reference: https://review.tizen.org/gerrit/281719 Change-Id: I29f08251a51aee73de96f4a3bea88e4994d22b5b Signed-off-by: Bakka Uday Kiran --- tizen_src/ewk/efl_integration/eweb_context.cc | 111 ++++++++++----------- tizen_src/ewk/efl_integration/eweb_context.h | 4 +- .../efl_integration/private/ewk_context_private.cc | 6 +- .../efl_integration/private/ewk_context_private.h | 5 +- .../ewk/efl_integration/public/ewk_context.cc | 3 +- .../url_request_context_getter_efl.cc | 20 ++-- 6 files changed, 67 insertions(+), 82 deletions(-) diff --git a/tizen_src/ewk/efl_integration/eweb_context.cc b/tizen_src/ewk/efl_integration/eweb_context.cc index 59b02c2..316070f 100644 --- a/tizen_src/ewk/efl_integration/eweb_context.cc +++ b/tizen_src/ewk/efl_integration/eweb_context.cc @@ -158,57 +158,33 @@ void OnTemporaryUsageAndQuotaObtained( base::BindOnce(callback, usage, user_data)); } -void OnGetWebDBOrigins(Ewk_Web_Database_Origins_Get_Callback callback, +void OnGetWebDBOrigins(storage::DatabaseQuotaClient* client, + Ewk_Web_Database_Origins_Get_Callback callback, void* user_data, - const std::set& origins_ref) { - Eina_List* origins = 0; - for (std::set::iterator iter = origins_ref.begin(); - iter != origins_ref.end(); ++iter) { - _Ewk_Security_Origin* sec_origin = new _Ewk_Security_Origin(*iter); - origins = eina_list_append(origins, sec_origin); + const std::vector& storage_keys) { + Eina_List* origin_list = nullptr; + for (const auto& key : storage_keys) { + _Ewk_Security_Origin* sec_origin = + 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, origins, user_data)); -} - -void GetWebDBOriginsOnDBThread(Ewk_Web_Database_Origins_Get_Callback callback, - void* user_data, - content::StoragePartition* partition) { -#if !defined(EWK_BRINGUP) // FIXME: m67 bringup - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); - storage::DatabaseQuotaClient client(partition->GetDatabaseTracker()); - client.GetOriginsForType( - storage::kStorageTypeTemporary, - base::BindOnce(&OnGetWebDBOrigins, callback, user_data)); -#endif + base::BindOnce(callback, origin_list, user_data)); } -void OnGetFileSystemOrigins(Ewk_Local_File_System_Origins_Get_Callback callback, - void* user_data, - const std::set& origins_ref) { - Eina_List* origins = 0; - for (std::set::iterator iter = origins_ref.begin(); - iter != origins_ref.end(); ++iter) { - _Ewk_Security_Origin* sec_origin = new _Ewk_Security_Origin(*iter); - origins = eina_list_append(origins, sec_origin); +void OnGetFileSystemOrigins( + storage::FileSystemQuotaClient* client, + Ewk_Local_File_System_Origins_Get_Callback callback, + void* user_data, + const std::vector& storage_keys) { + Eina_List* origin_list = nullptr; + for (const auto& key : storage_keys) { + _Ewk_Security_Origin* sec_origin = + 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, origins, user_data)); -} - -void GetFileSystemOriginsOnFILEThread( - Ewk_Web_Database_Origins_Get_Callback callback, - void* user_data, - content::StoragePartition* partition) { -#if !defined(EWK_BRINGUP) // FIXME: m76 bringup - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); - std::unique_ptr client( - new storage::FileSystemQuotaClient(partition->GetFileSystemContext(), - false)); - client->GetOriginsForType( - blink::mojom::StorageType::kTemporary, - base::BindOnce(&OnGetFileSystemOrigins, callback, user_data)); -#endif + base::BindOnce(callback, origin_list, user_data)); } } // namespace @@ -666,14 +642,16 @@ void EWebContext::WebDBDelete(const GURL& host) { void EWebContext::GetAllOriginsWithWebDB( Ewk_Web_Database_Origins_Get_Callback callback, void* user_data) { -#if !defined(EWK_BRINGUP) // FIXME: m67 bringup - content::StoragePartition* partition = - BrowserContext::GetStoragePartition(browser_context_.get(), NULL); - BrowserThread::ThreadPool::PostTask( - BrowserThread::DB, FROM_HERE, - base::BindOnce(&GetWebDBOriginsOnDBThread, callback, user_data, - partition)); -#endif + auto* storage_partition = browser_context()->GetDefaultStoragePartition(); + if (!storage_partition) + return; + + auto client = std::make_unique( + *storage_partition->GetDatabaseTracker()); + client->GetStorageKeysForType( + blink::mojom::StorageType::kTemporary, + base::BindOnce(&OnGetWebDBOrigins, base::Owned(std::move(client)), + callback, user_data)); } void EWebContext::FileSystemDelete(const GURL& host) { @@ -688,17 +666,28 @@ void EWebContext::FileSystemDelete(const GURL& host) { remover->RemoveImpl(BrowsingDataRemoverEfl::REMOVE_FILE_SYSTEMS, host); } -void EWebContext::GetAllOriginsWithFileSystem( +bool EWebContext::GetAllOriginsWithFileSystem( Ewk_Local_File_System_Origins_Get_Callback callback, void* user_data) const { -#if !defined(EWK_BRINGUP) // FIXME: m67 bringup - content::StoragePartition* partition = - BrowserContext::GetStoragePartition(browser_context_.get(), NULL); - BrowserThread::ThreadPool::PostTask( - BrowserThread::FILE, FROM_HERE, - base::BindOnce(&GetFileSystemOriginsOnFILEThread, callback, user_data, - partition)); -#endif + auto* storage_partition = browser_context()->GetDefaultStoragePartition(); + if (!storage_partition) { + LOG(ERROR) << "Unable to get StoragePartition."; + return false; + } + + auto* file_system_context = storage_partition->GetFileSystemContext(); + if (!file_system_context) { + LOG(ERROR) << "Unable to get FileSystemContext."; + return false; + } + + auto client = + std::make_unique(file_system_context); + client->GetStorageKeysForType( + blink::mojom::StorageType::kTemporary, + base::BindOnce(&OnGetFileSystemOrigins, base::Owned(std::move(client)), + callback, user_data)); + return true; } bool EWebContext::SetFaviconDatabasePath(const base::FilePath& path) { diff --git a/tizen_src/ewk/efl_integration/eweb_context.h b/tizen_src/ewk/efl_integration/eweb_context.h index 65a4168..795f308 100644 --- a/tizen_src/ewk/efl_integration/eweb_context.h +++ b/tizen_src/ewk/efl_integration/eweb_context.h @@ -130,7 +130,9 @@ class EWebContext { void WebStorageDeleteForOrigin(const GURL& origin); void WebStorageOriginsAllGet(Ewk_Web_Storage_Origins_Get_Callback callback, void* user_data); void FileSystemDelete(const GURL& host); - void GetAllOriginsWithFileSystem(Ewk_Local_File_System_Origins_Get_Callback callback, void* user_data) const; + bool GetAllOriginsWithFileSystem( + Ewk_Local_File_System_Origins_Get_Callback callback, + void* user_data) const; bool SetFaviconDatabasePath(const base::FilePath& path); Evas_Object *AddFaviconObject(const char *uri, Evas *canvas) const; diff --git a/tizen_src/ewk/efl_integration/private/ewk_context_private.cc b/tizen_src/ewk/efl_integration/private/ewk_context_private.cc index dce115c..6b97f16 100644 --- a/tizen_src/ewk/efl_integration/private/ewk_context_private.cc +++ b/tizen_src/ewk/efl_integration/private/ewk_context_private.cc @@ -189,8 +189,10 @@ void Ewk_Context::WebStorageDelete(const GURL& origin) { impl->WebStorageDeleteForOrigin(origin); } -void Ewk_Context::GetAllOriginsWithFileSystem(Ewk_Local_File_System_Origins_Get_Callback callback, void* user_data) const { - impl->GetAllOriginsWithFileSystem(callback, user_data); +bool Ewk_Context::GetAllOriginsWithFileSystem( + Ewk_Local_File_System_Origins_Get_Callback callback, + void* user_data) const { + return impl->GetAllOriginsWithFileSystem(callback, user_data); } void Ewk_Context::FileSystemDelete(const GURL& host) { diff --git a/tizen_src/ewk/efl_integration/private/ewk_context_private.h b/tizen_src/ewk/efl_integration/private/ewk_context_private.h index c4fcb01..c0940ef 100644 --- a/tizen_src/ewk/efl_integration/private/ewk_context_private.h +++ b/tizen_src/ewk/efl_integration/private/ewk_context_private.h @@ -91,8 +91,9 @@ struct Ewk_Context : public base::RefCounted { void ClearCandidateData(); // File System - void GetAllOriginsWithFileSystem( - Ewk_Local_File_System_Origins_Get_Callback callback, void* user_data) const; + bool GetAllOriginsWithFileSystem( + Ewk_Local_File_System_Origins_Get_Callback callback, + void* user_data) const; void FileSystemDelete(const GURL& host); // Favicon diff --git a/tizen_src/ewk/efl_integration/public/ewk_context.cc b/tizen_src/ewk/efl_integration/public/ewk_context.cc index 9b13510..e42cc9f 100644 --- a/tizen_src/ewk/efl_integration/public/ewk_context.cc +++ b/tizen_src/ewk/efl_integration/public/ewk_context.cc @@ -216,8 +216,7 @@ Eina_Bool ewk_context_local_file_system_origins_get(const Ewk_Context *context, { EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EINA_FALSE); EINA_SAFETY_ON_NULL_RETURN_VAL(context, EINA_FALSE); - context->GetAllOriginsWithFileSystem(callback, user_data); - return true; + return context->GetAllOriginsWithFileSystem(callback, user_data); } Eina_Bool ewk_context_web_database_delete_all(Ewk_Context* context) 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 b79993d..2d320c3 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 @@ -10,6 +10,7 @@ #include "base/memory/ptr_util.h" #include "base/strings/string_number_conversions.h" #include "base/task/bind_post_task.h" +#include "base/task/thread_pool.h" #include "components/network_session_configurator/common/network_switches.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/cookie_store_factory.h" @@ -257,16 +258,10 @@ void URLRequestContextGetterEfl::SetCookieStoragePath( DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); -// This was added as part of M67 Brinup to avoid crash related to -// CreateSQLitePersistentCookieStore. -#if !defined(EWK_BRINGUP) // FIXME: m67 bringup if (file_storage == EWK_COOKIE_PERSISTENT_STORAGE_SQLITE) CreateSQLitePersistentCookieStore(path, persist_session_cookies); else CreatePersistentCookieStore(path, persist_session_cookies); -#else - CreatePersistentCookieStore(path, persist_session_cookies); -#endif } void URLRequestContextGetterEfl::CreateSQLitePersistentCookieStore( @@ -282,14 +277,11 @@ void URLRequestContextGetterEfl::CreateSQLitePersistentCookieStore( if (base::DirectoryExists(path) || base::CreateDirectory(path)) { const base::FilePath& cookie_path = path.AppendASCII("Cookies"); persistent_store = new net::SQLitePersistentCookieStore( - cookie_path, - base::ThreadPool::CreateSingleThreadTaskRunner({BrowserThread::IO}), -#if !defined(EWK_BRINGUP) // FIXME: m67 bringup - BrowserThread::GetTaskRunnerForThread(BrowserThread::DB), -#else - base::ThreadPool::CreateSingleThreadTaskRunner({BrowserThread::UI}), -#endif - persist_session_cookies, NULL); + cookie_path, GetIOThreadTaskRunner({}), + base::ThreadPool::CreateSequencedTaskRunner( + {base::MayBlock(), net::GetCookieStoreBackgroundSequencePriority(), + base::TaskShutdownBehavior::BLOCK_SHUTDOWN}), + persist_session_cookies, nullptr); } else { NOTREACHED() << "The cookie storage directory could not be created"; return; -- 2.7.4