From 01f9a30b1d3fd2fd445844051eb175547d4c8b7c Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Thu, 6 Sep 2018 14:40:36 +0200 Subject: [PATCH] Fix external message pump (issue #2493) --- libcef/browser/browser_main.cc | 6 ------ libcef/browser/browser_main.h | 6 ------ libcef/common/main_delegate.cc | 8 ++++++++ libcef/common/main_delegate.h | 3 +++ 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/libcef/browser/browser_main.cc b/libcef/browser/browser_main.cc index 3872e69dc..abf8033fc 100644 --- a/libcef/browser/browser_main.cc +++ b/libcef/browser/browser_main.cc @@ -10,7 +10,6 @@ #include "libcef/browser/browser_context_impl.h" #include "libcef/browser/browser_context_keyed_service_factories.h" -#include "libcef/browser/browser_message_loop.h" #include "libcef/browser/content_browser_client.h" #include "libcef/browser/context.h" #include "libcef/browser/devtools_manager_delegate.h" @@ -107,11 +106,6 @@ void CefBrowserMainParts::ToolkitInitialized() { } void CefBrowserMainParts::PreMainMessageLoopStart() { - if (!base::MessageLoop::current()) { - // Create the browser message loop. - message_loop_.reset(new CefBrowserMessageLoop()); - } - for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) chrome_extra_parts_[i]->PreMainMessageLoopStart(); } diff --git a/libcef/browser/browser_main.h b/libcef/browser/browser_main.h index 563274f87..b845812b9 100644 --- a/libcef/browser/browser_main.h +++ b/libcef/browser/browser_main.h @@ -16,11 +16,6 @@ #include "content/public/browser/browser_main_parts.h" #include "net/url_request/url_request_context_getter.h" -namespace base { -class MessageLoop; -class Thread; -} // namespace base - namespace content { struct MainFunctionParams; } @@ -89,7 +84,6 @@ class CefBrowserMainParts : public content::BrowserMainParts { CefRefPtr global_request_context_; CefDevToolsDelegate* devtools_delegate_; // Deletes itself. - std::unique_ptr message_loop_; std::unique_ptr extensions_client_; std::unique_ptr diff --git a/libcef/common/main_delegate.cc b/libcef/common/main_delegate.cc index cacdd6ba2..b2bff392e 100644 --- a/libcef/common/main_delegate.cc +++ b/libcef/common/main_delegate.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "libcef/common/main_delegate.h" +#include "libcef/browser/browser_message_loop.h" #include "libcef/browser/content_browser_client.h" #include "libcef/browser/context.h" #include "libcef/common/cef_switches.h" @@ -290,6 +291,11 @@ CefMainDelegate::CefMainDelegate(CefRefPtr application) CefMainDelegate::~CefMainDelegate() {} +void CefMainDelegate::PreContentInitialization() { + // Create the main message loop. + message_loop_.reset(new CefBrowserMessageLoop()); +} + bool CefMainDelegate::BasicStartupComplete(int* exit_code) { base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); std::string process_type = @@ -641,6 +647,8 @@ void CefMainDelegate::ShutdownBrowser() { ui_thread_->Stop(); ui_thread_.reset(); } + + message_loop_.reset(); } void CefMainDelegate::InitializeResourceBundle() { diff --git a/libcef/common/main_delegate.h b/libcef/common/main_delegate.h index bf70c5529..9309e4c84 100644 --- a/libcef/common/main_delegate.h +++ b/libcef/common/main_delegate.h @@ -16,6 +16,7 @@ namespace base { class CommandLine; +class MessageLoop; class Thread; } // namespace base @@ -32,6 +33,7 @@ class CefMainDelegate : public content::ContentMainDelegate { explicit CefMainDelegate(CefRefPtr application); ~CefMainDelegate() override; + void PreContentInitialization() override; bool BasicStartupComplete(int* exit_code) override; void PreSandboxStartup() override; void SandboxInitialized(const std::string& process_type) override; @@ -55,6 +57,7 @@ class CefMainDelegate : public content::ContentMainDelegate { private: void InitializeResourceBundle(); + std::unique_ptr message_loop_; std::unique_ptr browser_runner_; std::unique_ptr ui_thread_;