Fix external message pump (issue #2493)

This commit is contained in:
Marshall Greenblatt 2018-09-06 14:40:36 +02:00
parent fd089efa24
commit 01f9a30b1d
4 changed files with 11 additions and 12 deletions

View File

@ -10,7 +10,6 @@
#include "libcef/browser/browser_context_impl.h" #include "libcef/browser/browser_context_impl.h"
#include "libcef/browser/browser_context_keyed_service_factories.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/content_browser_client.h"
#include "libcef/browser/context.h" #include "libcef/browser/context.h"
#include "libcef/browser/devtools_manager_delegate.h" #include "libcef/browser/devtools_manager_delegate.h"
@ -107,11 +106,6 @@ void CefBrowserMainParts::ToolkitInitialized() {
} }
void CefBrowserMainParts::PreMainMessageLoopStart() { 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) for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
chrome_extra_parts_[i]->PreMainMessageLoopStart(); chrome_extra_parts_[i]->PreMainMessageLoopStart();
} }

View File

@ -16,11 +16,6 @@
#include "content/public/browser/browser_main_parts.h" #include "content/public/browser/browser_main_parts.h"
#include "net/url_request/url_request_context_getter.h" #include "net/url_request/url_request_context_getter.h"
namespace base {
class MessageLoop;
class Thread;
} // namespace base
namespace content { namespace content {
struct MainFunctionParams; struct MainFunctionParams;
} }
@ -89,7 +84,6 @@ class CefBrowserMainParts : public content::BrowserMainParts {
CefRefPtr<CefRequestContextImpl> global_request_context_; CefRefPtr<CefRequestContextImpl> global_request_context_;
CefDevToolsDelegate* devtools_delegate_; // Deletes itself. CefDevToolsDelegate* devtools_delegate_; // Deletes itself.
std::unique_ptr<base::MessageLoop> message_loop_;
std::unique_ptr<extensions::ExtensionsClient> extensions_client_; std::unique_ptr<extensions::ExtensionsClient> extensions_client_;
std::unique_ptr<extensions::ExtensionsBrowserClient> std::unique_ptr<extensions::ExtensionsBrowserClient>

View File

@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "libcef/common/main_delegate.h" #include "libcef/common/main_delegate.h"
#include "libcef/browser/browser_message_loop.h"
#include "libcef/browser/content_browser_client.h" #include "libcef/browser/content_browser_client.h"
#include "libcef/browser/context.h" #include "libcef/browser/context.h"
#include "libcef/common/cef_switches.h" #include "libcef/common/cef_switches.h"
@ -290,6 +291,11 @@ CefMainDelegate::CefMainDelegate(CefRefPtr<CefApp> application)
CefMainDelegate::~CefMainDelegate() {} CefMainDelegate::~CefMainDelegate() {}
void CefMainDelegate::PreContentInitialization() {
// Create the main message loop.
message_loop_.reset(new CefBrowserMessageLoop());
}
bool CefMainDelegate::BasicStartupComplete(int* exit_code) { bool CefMainDelegate::BasicStartupComplete(int* exit_code) {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
std::string process_type = std::string process_type =
@ -641,6 +647,8 @@ void CefMainDelegate::ShutdownBrowser() {
ui_thread_->Stop(); ui_thread_->Stop();
ui_thread_.reset(); ui_thread_.reset();
} }
message_loop_.reset();
} }
void CefMainDelegate::InitializeResourceBundle() { void CefMainDelegate::InitializeResourceBundle() {

View File

@ -16,6 +16,7 @@
namespace base { namespace base {
class CommandLine; class CommandLine;
class MessageLoop;
class Thread; class Thread;
} // namespace base } // namespace base
@ -32,6 +33,7 @@ class CefMainDelegate : public content::ContentMainDelegate {
explicit CefMainDelegate(CefRefPtr<CefApp> application); explicit CefMainDelegate(CefRefPtr<CefApp> application);
~CefMainDelegate() override; ~CefMainDelegate() override;
void PreContentInitialization() override;
bool BasicStartupComplete(int* exit_code) override; bool BasicStartupComplete(int* exit_code) override;
void PreSandboxStartup() override; void PreSandboxStartup() override;
void SandboxInitialized(const std::string& process_type) override; void SandboxInitialized(const std::string& process_type) override;
@ -55,6 +57,7 @@ class CefMainDelegate : public content::ContentMainDelegate {
private: private:
void InitializeResourceBundle(); void InitializeResourceBundle();
std::unique_ptr<base::MessageLoop> message_loop_;
std::unique_ptr<content::BrowserMainRunner> browser_runner_; std::unique_ptr<content::BrowserMainRunner> browser_runner_;
std::unique_ptr<base::Thread> ui_thread_; std::unique_ptr<base::Thread> ui_thread_;