Destroy CefResponseManager on the correct thread (issue #570).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@632 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2012-05-18 21:18:01 +00:00
parent 9c9711c2d8
commit 8b1748bbf5
4 changed files with 18 additions and 11 deletions

View File

@ -499,6 +499,7 @@ void CefBrowserHostImpl::DestroyBrowser() {
} }
registrar_.reset(NULL); registrar_.reset(NULL);
response_manager_.reset(NULL);
content::WebContentsObserver::Observe(NULL); content::WebContentsObserver::Observe(NULL);
web_contents_.reset(NULL); web_contents_.reset(NULL);
@ -669,7 +670,7 @@ void CefBrowserHostImpl::SendCommand(
params.user_initiated = false; params.user_initiated = false;
if (responseHandler.get()) { if (responseHandler.get()) {
params.request_id = response_manager_.RegisterHandler(responseHandler); params.request_id = response_manager_->RegisterHandler(responseHandler);
params.expect_response = true; params.expect_response = true;
} else { } else {
params.request_id = -1; params.request_id = -1;
@ -705,7 +706,7 @@ void CefBrowserHostImpl::SendCode(
params.user_initiated = false; params.user_initiated = false;
if (responseHandler.get()) { if (responseHandler.get()) {
params.request_id = response_manager_.RegisterHandler(responseHandler); params.request_id = response_manager_->RegisterHandler(responseHandler);
params.expect_response = true; params.expect_response = true;
} else { } else {
params.request_id = -1; params.request_id = -1;
@ -1031,13 +1032,13 @@ void CefBrowserHostImpl::OnRequest(const Cef_Request_Params& params) {
} }
void CefBrowserHostImpl::OnResponse(const Cef_Response_Params& params) { void CefBrowserHostImpl::OnResponse(const Cef_Response_Params& params) {
response_manager_.RunHandler(params); response_manager_->RunHandler(params);
if (params.expect_response_ack) if (params.expect_response_ack)
Send(new CefMsg_ResponseAck(routing_id(), params.request_id)); Send(new CefMsg_ResponseAck(routing_id(), params.request_id));
} }
void CefBrowserHostImpl::OnResponseAck(int request_id) { void CefBrowserHostImpl::OnResponseAck(int request_id) {
response_manager_.RunAckHandler(request_id); response_manager_->RunAckHandler(request_id);
} }
@ -1102,6 +1103,7 @@ CefBrowserHostImpl::CefBrowserHostImpl(const CefWindowInfo& window_info,
registrar_.reset(new content::NotificationRegistrar); registrar_.reset(new content::NotificationRegistrar);
registrar_->Add(this, content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED, registrar_->Add(this, content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED,
content::Source<content::WebContents>(web_contents)); content::Source<content::WebContents>(web_contents));
response_manager_.reset(new CefResponseManager);
placeholder_frame_ = placeholder_frame_ =
new CefFrameHostImpl(this, CefFrameHostImpl::kInvalidFrameId, true); new CefFrameHostImpl(this, CefFrameHostImpl::kInvalidFrameId, true);

View File

@ -353,15 +353,15 @@ class CefBrowserHostImpl : public CefBrowserHost,
// Used when no other frame exists. Provides limited functionality. // Used when no other frame exists. Provides limited functionality.
CefRefPtr<CefFrameHostImpl> placeholder_frame_; CefRefPtr<CefFrameHostImpl> placeholder_frame_;
// Manages response registrations.
CefResponseManager response_manager_;
// Used for managing notification subscriptions. // Used for managing notification subscriptions.
scoped_ptr<content::NotificationRegistrar> registrar_; scoped_ptr<content::NotificationRegistrar> registrar_;
// Used for proxying cookie requests. // Used for proxying cookie requests.
scoped_refptr<CefURLRequestContextGetterProxy> request_context_proxy_; scoped_refptr<CefURLRequestContextGetterProxy> request_context_proxy_;
// Manages response registrations.
scoped_ptr<CefResponseManager> response_manager_;
// Used for creating and managing JavaScript dialogs. // Used for creating and managing JavaScript dialogs.
scoped_ptr<CefJavaScriptDialogCreator> dialog_creator_; scoped_ptr<CefJavaScriptDialogCreator> dialog_creator_;

View File

@ -11,6 +11,7 @@
#include "libcef/common/cef_messages.h" #include "libcef/common/cef_messages.h"
#include "libcef/common/content_client.h" #include "libcef/common/content_client.h"
#include "libcef/common/process_message_impl.h" #include "libcef/common/process_message_impl.h"
#include "libcef/common/response_manager.h"
#include "libcef/renderer/content_renderer_client.h" #include "libcef/renderer/content_renderer_client.h"
#include "libcef/renderer/thread_util.h" #include "libcef/renderer/thread_util.h"
#include "libcef/renderer/webkit_glue.h" #include "libcef/renderer/webkit_glue.h"
@ -261,6 +262,7 @@ CefBrowserImpl::CefBrowserImpl(content::RenderView* render_view)
browser_window_id_(kInvalidBrowserId), browser_window_id_(kInvalidBrowserId),
is_popup_(false), is_popup_(false),
last_focused_frame_id_(kInvalidFrameId) { last_focused_frame_id_(kInvalidFrameId) {
response_manager_.reset(new CefResponseManager);
} }
CefBrowserImpl::~CefBrowserImpl() { CefBrowserImpl::~CefBrowserImpl() {
@ -424,6 +426,8 @@ void CefBrowserImpl::OnDestruct() {
handler->OnBrowserDestroyed(this); handler->OnBrowserDestroyed(this);
} }
response_manager_.reset(NULL);
CefContentRendererClient::Get()->OnBrowserDestroyed(this); CefContentRendererClient::Get()->OnBrowserDestroyed(this);
} }
@ -655,11 +659,11 @@ void CefBrowserImpl::OnRequest(const Cef_Request_Params& params) {
} }
void CefBrowserImpl::OnResponse(const Cef_Response_Params& params) { void CefBrowserImpl::OnResponse(const Cef_Response_Params& params) {
response_manager_.RunHandler(params); response_manager_->RunHandler(params);
if (params.expect_response_ack) if (params.expect_response_ack)
Send(new CefHostMsg_ResponseAck(routing_id(), params.request_id)); Send(new CefHostMsg_ResponseAck(routing_id(), params.request_id));
} }
void CefBrowserImpl::OnResponseAck(int request_id) { void CefBrowserImpl::OnResponseAck(int request_id) {
response_manager_.RunAckHandler(request_id); response_manager_->RunAckHandler(request_id);
} }

View File

@ -13,10 +13,10 @@
#include "include/cef_browser.h" #include "include/cef_browser.h"
#include "include/cef_client.h" #include "include/cef_client.h"
#include "libcef/common/response_manager.h"
#include "libcef/common/tracker.h" #include "libcef/common/tracker.h"
#include "libcef/renderer/frame_impl.h" #include "libcef/renderer/frame_impl.h"
#include "base/memory/scoped_ptr.h"
#include "content/public/renderer/render_view_observer.h" #include "content/public/renderer/render_view_observer.h"
class GURL; class GURL;
@ -24,6 +24,7 @@ struct CefMsg_LoadRequest_Params;
struct Cef_Request_Params; struct Cef_Request_Params;
struct Cef_Response_Params; struct Cef_Response_Params;
class CefContentRendererClient; class CefContentRendererClient;
class CefResponseManager;
namespace base { namespace base {
class ListValue; class ListValue;
@ -125,7 +126,7 @@ class CefBrowserImpl : public CefBrowser,
FrameObjectMap frame_objects_; FrameObjectMap frame_objects_;
// Manages response registrations. // Manages response registrations.
CefResponseManager response_manager_; scoped_ptr<CefResponseManager> response_manager_;
IMPLEMENT_REFCOUNTING(CefBrowserImpl); IMPLEMENT_REFCOUNTING(CefBrowserImpl);
DISALLOW_COPY_AND_ASSIGN(CefBrowserImpl); DISALLOW_COPY_AND_ASSIGN(CefBrowserImpl);