Windows: cefclient: Fix assertions with --use-views --multi-threaded-message-loop
This commit is contained in:
parent
319de22d89
commit
f9706f260a
|
@ -107,8 +107,7 @@ class ClientRequestContextHandler : public CefRequestContextHandler,
|
|||
} // namespace
|
||||
|
||||
RootWindowManager::RootWindowManager(bool terminate_when_all_windows_closed)
|
||||
: terminate_when_all_windows_closed_(terminate_when_all_windows_closed),
|
||||
image_cache_(new ImageCache) {
|
||||
: terminate_when_all_windows_closed_(terminate_when_all_windows_closed) {
|
||||
CefRefPtr<CefCommandLine> command_line =
|
||||
CefCommandLine::GetGlobalCommandLine();
|
||||
DCHECK(command_line.get());
|
||||
|
@ -354,8 +353,11 @@ CefRefPtr<CefRequestContext> RootWindowManager::GetRequestContext(
|
|||
}
|
||||
|
||||
scoped_refptr<ImageCache> RootWindowManager::GetImageCache() {
|
||||
REQUIRE_MAIN_THREAD();
|
||||
CEF_REQUIRE_UI_THREAD();
|
||||
|
||||
if (!image_cache_) {
|
||||
image_cache_ = new ImageCache;
|
||||
}
|
||||
return image_cache_;
|
||||
}
|
||||
|
||||
|
@ -446,6 +448,10 @@ void RootWindowManager::CleanupOnUIThread() {
|
|||
temp_window_.reset(nullptr);
|
||||
}
|
||||
|
||||
if (image_cache_) {
|
||||
image_cache_ = nullptr;
|
||||
}
|
||||
|
||||
// Quit the main message loop.
|
||||
MainMessageLoop::Get()->Quit();
|
||||
}
|
||||
|
|
|
@ -59,8 +59,8 @@ void RootWindowViews::Init(RootWindow::Delegate* delegate,
|
|||
CreateClientHandler(config.url);
|
||||
initialized_ = true;
|
||||
|
||||
// Continue initialization on the main thread.
|
||||
InitOnMainThread(settings, config.url);
|
||||
// Continue initialization on the UI thread.
|
||||
InitOnUIThread(settings, config.url, delegate_->GetRequestContext(this));
|
||||
}
|
||||
|
||||
void RootWindowViews::InitAsPopup(RootWindow::Delegate* delegate,
|
||||
|
@ -187,17 +187,17 @@ ClientWindowHandle RootWindowViews::GetWindowHandle() const {
|
|||
}
|
||||
|
||||
bool RootWindowViews::WithExtension() const {
|
||||
REQUIRE_MAIN_THREAD();
|
||||
DCHECK(initialized_);
|
||||
return with_extension_;
|
||||
}
|
||||
|
||||
bool RootWindowViews::WithControls() {
|
||||
CEF_REQUIRE_UI_THREAD();
|
||||
DCHECK(initialized_);
|
||||
return with_controls_;
|
||||
}
|
||||
|
||||
bool RootWindowViews::WithExtension() {
|
||||
REQUIRE_MAIN_THREAD();
|
||||
DCHECK(initialized_);
|
||||
return with_extension_;
|
||||
}
|
||||
|
||||
|
@ -475,12 +475,14 @@ void RootWindowViews::CreateClientHandler(const std::string& url) {
|
|||
client_handler_->set_download_favicon_images(true);
|
||||
}
|
||||
|
||||
void RootWindowViews::InitOnMainThread(const CefBrowserSettings& settings,
|
||||
const std::string& startup_url) {
|
||||
if (!CURRENTLY_ON_MAIN_THREAD()) {
|
||||
// Execute this method on the main thread.
|
||||
MAIN_POST_CLOSURE(base::Bind(&RootWindowViews::InitOnMainThread, this,
|
||||
settings, startup_url));
|
||||
void RootWindowViews::InitOnUIThread(
|
||||
const CefBrowserSettings& settings,
|
||||
const std::string& startup_url,
|
||||
CefRefPtr<CefRequestContext> request_context) {
|
||||
if (!CefCurrentlyOn(TID_UI)) {
|
||||
// Execute this method on the UI thread.
|
||||
CefPostTask(TID_UI, base::Bind(&RootWindowViews::InitOnUIThread, this,
|
||||
settings, startup_url, request_context));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -493,7 +495,7 @@ void RootWindowViews::InitOnMainThread(const CefBrowserSettings& settings,
|
|||
|
||||
image_cache_->LoadImages(
|
||||
image_set, base::Bind(&RootWindowViews::CreateViewsWindow, this, settings,
|
||||
startup_url, delegate_->GetRequestContext(this)));
|
||||
startup_url, request_context));
|
||||
}
|
||||
|
||||
void RootWindowViews::CreateViewsWindow(
|
||||
|
|
|
@ -89,8 +89,9 @@ class RootWindowViews : public RootWindow,
|
|||
private:
|
||||
void CreateClientHandler(const std::string& url);
|
||||
|
||||
void InitOnMainThread(const CefBrowserSettings& settings,
|
||||
const std::string& startup_url);
|
||||
void InitOnUIThread(const CefBrowserSettings& settings,
|
||||
const std::string& startup_url,
|
||||
CefRefPtr<CefRequestContext> request_context);
|
||||
void CreateViewsWindow(const CefBrowserSettings& settings,
|
||||
const std::string& startup_url,
|
||||
CefRefPtr<CefRequestContext> request_context,
|
||||
|
|
Loading…
Reference in New Issue