From a0a0ae326cde3210f8f4f8366154c262c822111c Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Mon, 1 Jun 2009 14:12:34 +0000 Subject: [PATCH] libcef: - Initialize WebKit in the UI thread to avoid asserts due to WTF::isMainThread() returning false. (Issue #21, Issue #24). git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@27 5089003a-bbd8-11dd-ad1f-f1f9622dbc98 --- libcef/context.cc | 15 ++++++++++++--- libcef/context.h | 7 ++++--- libcef/v8_impl.cc | 1 + 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/libcef/context.cc b/libcef/context.cc index 2e8b0cef1..7d7d75d92 100644 --- a/libcef/context.cc +++ b/libcef/context.cc @@ -9,6 +9,7 @@ #include "browser_resource_loader_bridge.h" #include "browser_request_context.h" #include "browser_webkit_glue.h" +#include "browser_webkit_init.h" #include "../include/cef_nplugin.h" #include "base/command_line.h" @@ -162,6 +163,12 @@ bool CefContext::DoInitialize() // Initialize the global CommandLine object. CommandLine::Init(0, NULL); + // Initialize WebKit. + webkit_init_ = new BrowserWebKitInit(); + + // Initialize WebKit encodings + webkit_glue::InitializeTextEncoding(); + // Initializing with a default context, which means no on-disk cookie DB, // and no support for directory listings. //PathService::Get(base::DIR_EXE, &cache_path); @@ -209,6 +216,10 @@ void CefContext::DoUninitialize() delete statstable_; statstable_ = NULL; + // Shut down WebKit. + delete webkit_init_; + webkit_init_ = NULL; + // Uninitialize COM stuff OleUninitialize(); @@ -249,6 +260,7 @@ CefContext::CefContext() webprefs_ = NULL; hinstance_ = ::GetModuleHandle(NULL); next_browser_id_ = 1; + webkit_init_ = NULL; } CefContext::~CefContext() @@ -292,9 +304,6 @@ bool CefContext::Initialize(bool multi_threaded_message_loop, }; RegisterClassEx(&wcex); - // Initialize WebKit encodings - webkit_glue::InitializeTextEncoding(); - #ifndef _DEBUG // Only log error messages and above in release build. logging::SetMinLogLevel(logging::LOG_ERROR); diff --git a/libcef/context.h b/libcef/context.h index 86ecc763e..338b779ac 100644 --- a/libcef/context.h +++ b/libcef/context.h @@ -9,10 +9,11 @@ #include "../include/cef.h" #include "base/at_exit.h" #include "base/message_loop.h" +#include "base/stats_table.h" #include "base/gfx/native_widget_types.h" #include "webkit/glue/webpreferences.h" -#include "browser_webkit_init.h" +class BrowserWebKitInit; class CefBrowserImpl; class CefContext : public CefThreadSafeBase @@ -78,8 +79,8 @@ protected: // Initialize the AtExitManager to avoid asserts and possible memory leaks. base::AtExitManager at_exit_manager_; - // Initialize WebKit for this scope. - BrowserWebKitInit webkit_init_; + // WebKit implementation class. + BrowserWebKitInit* webkit_init_; // Used for assigning unique IDs to browser instances. int next_browser_id_; diff --git a/libcef/v8_impl.cc b/libcef/v8_impl.cc index 99b321337..10224a6ef 100644 --- a/libcef/v8_impl.cc +++ b/libcef/v8_impl.cc @@ -7,6 +7,7 @@ #include "context.h" #include "tracker.h" #include "base/lazy_instance.h" +#include "base/string_util.h" #include "webkit/api/public/WebKit.h"