From 2c4b9898c3629ce54d46990650fa00298633b3c4 Mon Sep 17 00:00:00 2001 From: Chandan Padhi Date: Thu, 25 Apr 2019 03:31:48 -0700 Subject: [PATCH] [M73 Dev][EFL] Use unique pointers instead of raw pointers in EwkGlobalData As per changes in chromium upstream code, BrowserMainRunner::Create() now returns a unique pointer. This commit adapts code in EwkGlobalData accordingly to fix crash at webview launch. Change-Id: I325d5cc8a7294eee9e40cdce711533f20601ef84 Signed-off-by: Chandan Padhi --- .../efl_integration/browser/permission_manager_efl.cc | 2 +- tizen_src/ewk/efl_integration/ewk_global_data.cc | 17 +++++------------ tizen_src/ewk/efl_integration/ewk_global_data.h | 15 +++++++++------ .../ewk/efl_integration/public/ewk_notification.cc | 3 ++- 4 files changed, 17 insertions(+), 20 deletions(-) diff --git a/tizen_src/ewk/efl_integration/browser/permission_manager_efl.cc b/tizen_src/ewk/efl_integration/browser/permission_manager_efl.cc index 6f66972..6f09829 100644 --- a/tizen_src/ewk/efl_integration/browser/permission_manager_efl.cc +++ b/tizen_src/ewk/efl_integration/browser/permission_manager_efl.cc @@ -68,7 +68,7 @@ int PermissionManagerEfl::RequestPermission( { #if defined(ENABLE_NOTIFICATIONS) ContentMainDelegateEfl& cmde = - EwkGlobalData::GetInstance()->GetContentMainDelegatEfl(); + EwkGlobalData::GetInstance()->GetContentMainDelegateEfl(); ContentBrowserClientEfl* cbce = static_cast(cmde.GetContentBrowserClient()); if (!cbce) { diff --git a/tizen_src/ewk/efl_integration/ewk_global_data.cc b/tizen_src/ewk/efl_integration/ewk_global_data.cc index 99f3adf..a947a39 100644 --- a/tizen_src/ewk/efl_integration/ewk_global_data.cc +++ b/tizen_src/ewk/efl_integration/ewk_global_data.cc @@ -63,7 +63,8 @@ std::unique_ptr MessagePumpFactory() { } // namespace EwkGlobalData::EwkGlobalData() - : content_main_runner_(ContentMainRunner::Create()) {} + : content_main_runner_(ContentMainRunner::Create()), + content_main_delegate_efl_(new ContentMainDelegateEfl) {} EwkGlobalData::~EwkGlobalData() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -93,14 +94,6 @@ EwkGlobalData::~EwkGlobalData() { // FIXME: EWK_BRINGUP definition should be removed. loop->RunUntilIdle(); #endif // !defined(EWK_BRINGUP) - - // browser_main_runner must be deleted first as it depends on - // content_main_runner - delete browser_main_runner_; - delete content_main_runner_; - - // content_main_delegate_efl_ must be deleted after content_main_runner_ - delete content_main_delegate_efl_; } EwkGlobalData* EwkGlobalData::GetInstance() { @@ -127,8 +120,8 @@ EwkGlobalData* EwkGlobalData::GetInstance() { ui::InstallScreenInstance(); efl::WindowFactory::SetDelegate(&EWebView::GetHostWindowDelegate); - instance_->content_main_delegate_efl_ = new ContentMainDelegateEfl(); - content::ContentMainParams params(instance_->content_main_delegate_efl_); + content::ContentMainParams params( + instance_->content_main_delegate_efl_.get()); params.argc = CommandLineEfl::GetArgc(); params.argv = CommandLineEfl::GetArgv(); @@ -156,7 +149,7 @@ EwkGlobalData* EwkGlobalData::GetInstance() { content::StartBrowserTaskScheduler(); content::BrowserTaskExecutor::Create(); - instance_->browser_main_runner_ = BrowserMainRunner::Create().get(); + instance_->browser_main_runner_ = BrowserMainRunner::Create(); instance_->browser_main_runner_->Initialize(main_funtion_params); base::ThreadRestrictions::SetIOAllowed(true); diff --git a/tizen_src/ewk/efl_integration/ewk_global_data.h b/tizen_src/ewk/efl_integration/ewk_global_data.h index 8f0f9e9..5200cfc 100644 --- a/tizen_src/ewk/efl_integration/ewk_global_data.h +++ b/tizen_src/ewk/efl_integration/ewk_global_data.h @@ -22,8 +22,8 @@ class EwkGlobalData static void Delete(); static bool IsInitialized(); - content::ContentMainDelegateEfl& GetContentMainDelegatEfl() const { - return *content_main_delegate_efl_; + content::ContentMainDelegateEfl& GetContentMainDelegateEfl() const { + return *content_main_delegate_efl_.get(); } content::URLRequestContextGetterEfl* GetSystemRequestContextGetter(); @@ -34,11 +34,14 @@ class EwkGlobalData static EwkGlobalData* instance_; - content::ContentMainRunner* content_main_runner_; - content::BrowserMainRunner* browser_main_runner_; - content::ContentMainDelegateEfl* content_main_delegate_efl_; - scoped_refptr system_request_context_; + // |browser_main_runner_| must be deleted first as it depends on + // |content_main_runner_|. |content_main_delegate_efl_| must be deleted after + // |content_main_runner_|. + std::unique_ptr content_main_delegate_efl_; + std::unique_ptr content_main_runner_; + std::unique_ptr browser_main_runner_; + scoped_refptr system_request_context_; DISALLOW_COPY_AND_ASSIGN(EwkGlobalData); }; diff --git a/tizen_src/ewk/efl_integration/public/ewk_notification.cc b/tizen_src/ewk/efl_integration/public/ewk_notification.cc index b05e9e5..5327cf8 100644 --- a/tizen_src/ewk/efl_integration/public/ewk_notification.cc +++ b/tizen_src/ewk/efl_integration/public/ewk_notification.cc @@ -50,7 +50,8 @@ ContentBrowserClientEfl* GetContentBrowserClient() return nullptr; } - ContentMainDelegateEfl& cmde = EwkGlobalData::GetInstance()->GetContentMainDelegatEfl(); + ContentMainDelegateEfl& cmde = + EwkGlobalData::GetInstance()->GetContentMainDelegateEfl(); ContentBrowserClientEfl* cbce = static_cast(cmde.GetContentBrowserClient()); return cbce; -- 2.7.4