From f2cb8680ba25d4da53d045bc804c302accd9afe0 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Fri, 25 May 2012 20:46:44 +0000 Subject: [PATCH] Merge revision 650 changes: - Make sure BrowserRequestContextProxy is only used on the IO thread (issue #542). - Windows: Reset the window procedure in the WebWidgetHost destructor to avoid crashes if messages are delivered after the window is destroyed. git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/963@651 5089003a-bbd8-11dd-ad1f-f1f9622dbc98 --- libcef/browser_impl.cc | 18 ++++++++++++++---- libcef/browser_impl.h | 4 +--- libcef/browser_request_context_proxy.cc | 1 + libcef/browser_request_context_proxy.h | 3 ++- libcef/webwidget_host_win.cc | 9 ++++++--- 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/libcef/browser_impl.cc b/libcef/browser_impl.cc index 67632c4fb..49b523203 100644 --- a/libcef/browser_impl.cc +++ b/libcef/browser_impl.cc @@ -180,9 +180,6 @@ CefBrowserImpl::CefBrowserImpl(const CefWindowInfo& windowInfo, popup_delegate_.reset(new BrowserWebViewDelegate(this)); nav_controller_.reset(new BrowserNavigationController(this)); - request_context_proxy_ = - new BrowserRequestContextProxy(_Context->request_context(), this); - if (!file_system_root_.CreateUniqueTempDir()) { LOG(WARNING) << "Failed to create a temp dir for the filesystem." "FileSystem feature will be disabled."; @@ -791,7 +788,10 @@ void CefBrowserImpl::UIT_DestroyBrowser() { UIT_ClearMainWndHandle(); main_frame_ = NULL; - request_context_proxy_ = NULL; + + // Release the proxy on the IO thread. + CefThread::ReleaseSoon(CefThread::IO, FROM_HERE, + request_context_proxy_.release()); // Remove the reference added in UIT_CreateBrowser(). Release(); @@ -1591,6 +1591,16 @@ GURL CefBrowserImpl::pending_url() { return pending_url_; } +net::URLRequestContext* CefBrowserImpl::request_context_proxy() { + DCHECK(CefThread::CurrentlyOn(CefThread::IO)); + + if (!request_context_proxy_) { + request_context_proxy_ = + new BrowserRequestContextProxy(_Context->request_context(), this); + } + return request_context_proxy_; +} + void CefBrowserImpl::UIT_CreateDevToolsClient(BrowserDevToolsAgent *agent) { dev_tools_client_.reset(new BrowserDevToolsClient(this, agent)); } diff --git a/libcef/browser_impl.h b/libcef/browser_impl.h index ef643dd65..414fe078f 100644 --- a/libcef/browser_impl.h +++ b/libcef/browser_impl.h @@ -356,9 +356,7 @@ class CefBrowserImpl : public CefBrowser { void set_popup_rect(const gfx::Rect& rect) { popup_rect_ = rect; } - net::URLRequestContext* request_context_proxy() { - return request_context_proxy_; - } + net::URLRequestContext* request_context_proxy(); static bool ImplementsThreadSafeReferenceCounting() { return true; } diff --git a/libcef/browser_request_context_proxy.cc b/libcef/browser_request_context_proxy.cc index 444464ab2..701ea9252 100644 --- a/libcef/browser_request_context_proxy.cc +++ b/libcef/browser_request_context_proxy.cc @@ -3,6 +3,7 @@ // be found in the LICENSE file. #include "libcef/browser_request_context_proxy.h" +#include "libcef/browser_impl.h" #include "libcef/browser_request_context.h" #include "libcef/cookie_store_proxy.h" diff --git a/libcef/browser_request_context_proxy.h b/libcef/browser_request_context_proxy.h index 4678b184a..efebbe4aa 100644 --- a/libcef/browser_request_context_proxy.h +++ b/libcef/browser_request_context_proxy.h @@ -7,6 +7,7 @@ #pragma once #include +#include "include/cef.h" #include "net/url_request/url_request_context.h" class BrowserRequestContext; @@ -23,7 +24,7 @@ class BrowserRequestContextProxy : public net::URLRequestContext { private: BrowserRequestContext* context_; - CefBrowserImpl* browser_; + CefRefPtr browser_; }; #endif // CEF_LIBCEF_BROWSER_REQUEST_CONTEXT_PROXY_H_ diff --git a/libcef/webwidget_host_win.cc b/libcef/webwidget_host_win.cc index a8ec09157..92db81b66 100644 --- a/libcef/webwidget_host_win.cc +++ b/libcef/webwidget_host_win.cc @@ -353,11 +353,14 @@ WebWidgetHost::WebWidgetHost() } WebWidgetHost::~WebWidgetHost() { - if (view_) - ui::SetWindowUserData(view_, 0); - TrackMouseLeave(false); ResetTooltip(); + + if (view_) { + ui::SetWindowUserData(view_, 0); + ui::SetWindowProc(view_, DefWindowProc); + view_ = NULL; + } } bool WebWidgetHost::WndProc(UINT message, WPARAM wparam, LPARAM lparam) {