- 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.
- Add thread-related DCHECKS in browser_resource_loader_bridge.cc.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@650 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2012-05-25 20:44:34 +00:00
parent ab96ec27a4
commit cf5665ca3e
6 changed files with 102 additions and 22 deletions

View File

@ -180,9 +180,6 @@ CefBrowserImpl::CefBrowserImpl(const CefWindowInfo& windowInfo,
popup_delegate_.reset(new BrowserWebViewDelegate(this)); popup_delegate_.reset(new BrowserWebViewDelegate(this));
nav_controller_.reset(new BrowserNavigationController(this)); nav_controller_.reset(new BrowserNavigationController(this));
request_context_proxy_.reset(
new BrowserRequestContextProxy(_Context->request_context(), this));
if (!file_system_root_.CreateUniqueTempDir()) { if (!file_system_root_.CreateUniqueTempDir()) {
LOG(WARNING) << "Failed to create a temp dir for the filesystem." LOG(WARNING) << "Failed to create a temp dir for the filesystem."
"FileSystem feature will be disabled."; "FileSystem feature will be disabled.";
@ -785,7 +782,10 @@ void CefBrowserImpl::UIT_DestroyBrowser() {
UIT_ClearMainWndHandle(); UIT_ClearMainWndHandle();
main_frame_ = NULL; main_frame_ = NULL;
request_context_proxy_.reset(NULL);
// Delete the proxy on the IO thread.
CefThread::DeleteSoon(CefThread::IO, FROM_HERE,
request_context_proxy_.release());
// Remove the reference added in UIT_CreateBrowser(). // Remove the reference added in UIT_CreateBrowser().
Release(); Release();
@ -1585,6 +1585,16 @@ GURL CefBrowserImpl::pending_url() {
return pending_url_; return pending_url_;
} }
net::URLRequestContext* CefBrowserImpl::request_context_proxy() {
DCHECK(CefThread::CurrentlyOn(CefThread::IO));
if (!request_context_proxy_.get()) {
request_context_proxy_.reset(
new BrowserRequestContextProxy(_Context->request_context(), this));
}
return request_context_proxy_.get();
}
void CefBrowserImpl::UIT_CreateDevToolsClient(BrowserDevToolsAgent *agent) { void CefBrowserImpl::UIT_CreateDevToolsClient(BrowserDevToolsAgent *agent) {
dev_tools_client_.reset(new BrowserDevToolsClient(this, agent)); dev_tools_client_.reset(new BrowserDevToolsClient(this, agent));
} }

View File

@ -356,9 +356,7 @@ class CefBrowserImpl : public CefBrowser {
void set_popup_rect(const gfx::Rect& rect) { popup_rect_ = rect; } void set_popup_rect(const gfx::Rect& rect) { popup_rect_ = rect; }
net::URLRequestContext* request_context_proxy() { net::URLRequestContext* request_context_proxy();
return request_context_proxy_.get();
}
static bool ImplementsThreadSafeReferenceCounting() { return true; } static bool ImplementsThreadSafeReferenceCounting() { return true; }

View File

@ -3,6 +3,7 @@
// be found in the LICENSE file. // be found in the LICENSE file.
#include "libcef/browser_request_context_proxy.h" #include "libcef/browser_request_context_proxy.h"
#include "libcef/browser_impl.h"
#include "libcef/browser_request_context.h" #include "libcef/browser_request_context.h"
#include "libcef/cookie_store_proxy.h" #include "libcef/cookie_store_proxy.h"

View File

@ -7,15 +7,16 @@
#pragma once #pragma once
#include <string> #include <string>
#include "include/cef_base.h"
#include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context.h"
class BrowserRequestContext; class BrowserRequestContext;
class CefBrowserImpl; class CefBrowserImpl;
// A basic URLRequestContext that only provides an in-memory cookie store. // A URLRequestContext implementation that proxies cookie requests to the
// client.
class BrowserRequestContextProxy : public net::URLRequestContext { class BrowserRequestContextProxy : public net::URLRequestContext {
public: public:
// Use an in-memory cache
BrowserRequestContextProxy(BrowserRequestContext* context, BrowserRequestContextProxy(BrowserRequestContext* context,
CefBrowserImpl* browser); CefBrowserImpl* browser);
@ -23,7 +24,7 @@ class BrowserRequestContextProxy : public net::URLRequestContext {
private: private:
BrowserRequestContext* context_; BrowserRequestContext* context_;
CefBrowserImpl* browser_; CefRefPtr<CefBrowserImpl> browser_;
}; };
#endif // CEF_LIBCEF_BROWSER_REQUEST_CONTEXT_PROXY_H_ #endif // CEF_LIBCEF_BROWSER_REQUEST_CONTEXT_PROXY_H_

View File

@ -196,12 +196,15 @@ class RequestProxy : public net::URLRequest::Delegate,
file_stream_(NULL), file_stream_(NULL),
buf_(new net::IOBuffer(kDataSize)), buf_(new net::IOBuffer(kDataSize)),
browser_(browser), browser_(browser),
owner_loop_(NULL),
peer_(NULL),
last_upload_position_(0), last_upload_position_(0),
defers_loading_(false), defers_loading_(false),
defers_loading_want_read_(false) { defers_loading_want_read_(false) {
} }
void DropPeer() { void DropPeer() {
DCHECK(MessageLoop::current() == owner_loop_);
peer_ = NULL; peer_ = NULL;
} }
@ -217,6 +220,8 @@ class RequestProxy : public net::URLRequest::Delegate,
} }
void Cancel() { void Cancel() {
DCHECK(MessageLoop::current() == owner_loop_);
if (download_handler_.get()) { if (download_handler_.get()) {
// WebKit will try to cancel the download but we won't allow it. // WebKit will try to cancel the download but we won't allow it.
return; return;
@ -228,6 +233,8 @@ class RequestProxy : public net::URLRequest::Delegate,
} }
void SetDefersLoading(bool defer) { void SetDefersLoading(bool defer) {
DCHECK(MessageLoop::current() == owner_loop_);
CefThread::PostTask(CefThread::IO, FROM_HERE, base::Bind( CefThread::PostTask(CefThread::IO, FROM_HERE, base::Bind(
&RequestProxy::AsyncSetDefersLoading, this, defer)); &RequestProxy::AsyncSetDefersLoading, this, defer));
} }
@ -251,6 +258,8 @@ class RequestProxy : public net::URLRequest::Delegate,
void NotifyReceivedRedirect(const GURL& new_url, void NotifyReceivedRedirect(const GURL& new_url,
const ResourceResponseInfo& info) { const ResourceResponseInfo& info) {
DCHECK(MessageLoop::current() == owner_loop_);
bool has_new_first_party_for_cookies = false; bool has_new_first_party_for_cookies = false;
GURL new_first_party_for_cookies; GURL new_first_party_for_cookies;
if (peer_ && peer_->OnReceivedRedirect(new_url, info, if (peer_ && peer_->OnReceivedRedirect(new_url, info,
@ -266,6 +275,8 @@ class RequestProxy : public net::URLRequest::Delegate,
void NotifyReceivedResponse(const ResourceResponseInfo& info, void NotifyReceivedResponse(const ResourceResponseInfo& info,
const GURL& url, bool allow_download) { const GURL& url, bool allow_download) {
DCHECK(MessageLoop::current() == owner_loop_);
if (browser_.get() && info.headers.get()) { if (browser_.get() && info.headers.get()) {
CefRefPtr<CefClient> client = browser_->GetClient(); CefRefPtr<CefClient> client = browser_->GetClient();
CefRefPtr<CefRequestHandler> handler; CefRefPtr<CefRequestHandler> handler;
@ -316,6 +327,8 @@ class RequestProxy : public net::URLRequest::Delegate,
} }
void NotifyReceivedData(int bytes_read) { void NotifyReceivedData(int bytes_read) {
DCHECK(MessageLoop::current() == owner_loop_);
if (!peer_) if (!peer_)
return; return;
@ -359,6 +372,8 @@ class RequestProxy : public net::URLRequest::Delegate,
} }
void NotifyDownloadedData(int bytes_read) { void NotifyDownloadedData(int bytes_read) {
DCHECK(MessageLoop::current() == owner_loop_);
if (!peer_) if (!peer_)
return; return;
@ -372,6 +387,8 @@ class RequestProxy : public net::URLRequest::Delegate,
void NotifyCompletedRequest(const net::URLRequestStatus& status, void NotifyCompletedRequest(const net::URLRequestStatus& status,
const std::string& security_info, const std::string& security_info,
const base::TimeTicks& complete_time) { const base::TimeTicks& complete_time) {
DCHECK(MessageLoop::current() == owner_loop_);
// Drain the content filter of all remaining data // Drain the content filter of all remaining data
if (content_filter_.get()) { if (content_filter_.get()) {
CefRefPtr<CefStreamReader> remainder; CefRefPtr<CefStreamReader> remainder;
@ -411,6 +428,8 @@ class RequestProxy : public net::URLRequest::Delegate,
} }
void NotifyUploadProgress(uint64 position, uint64 size) { void NotifyUploadProgress(uint64 position, uint64 size) {
DCHECK(MessageLoop::current() == owner_loop_);
if (peer_) if (peer_)
peer_->OnUploadProgress(position, size); peer_->OnUploadProgress(position, size);
} }
@ -420,6 +439,8 @@ class RequestProxy : public net::URLRequest::Delegate,
// actions performed on the owner's thread. // actions performed on the owner's thread.
void AsyncStart(RequestParams* params) { void AsyncStart(RequestParams* params) {
DCHECK(CefThread::CurrentlyOn(CefThread::IO));
bool handled = false; bool handled = false;
if (browser_.get()) { if (browser_.get()) {
@ -605,6 +626,8 @@ class RequestProxy : public net::URLRequest::Delegate,
} }
void AsyncCancel() { void AsyncCancel() {
DCHECK(CefThread::CurrentlyOn(CefThread::IO));
// This can be null in cases where the request is already done. // This can be null in cases where the request is already done.
if (!resource_stream_.get() && !request_.get()) if (!resource_stream_.get() && !request_.get())
return; return;
@ -616,6 +639,8 @@ class RequestProxy : public net::URLRequest::Delegate,
void AsyncFollowDeferredRedirect(bool has_new_first_party_for_cookies, void AsyncFollowDeferredRedirect(bool has_new_first_party_for_cookies,
const GURL& new_first_party_for_cookies) { const GURL& new_first_party_for_cookies) {
DCHECK(CefThread::CurrentlyOn(CefThread::IO));
// This can be null in cases where the request is already done. // This can be null in cases where the request is already done.
if (!request_.get()) if (!request_.get())
return; return;
@ -626,6 +651,8 @@ class RequestProxy : public net::URLRequest::Delegate,
} }
void AsyncSetDefersLoading(bool defer) { void AsyncSetDefersLoading(bool defer) {
DCHECK(CefThread::CurrentlyOn(CefThread::IO));
if (defers_loading_ != defer) { if (defers_loading_ != defer) {
defers_loading_ = defer; defers_loading_ = defer;
if (!defers_loading_ && defers_loading_want_read_) { if (!defers_loading_ && defers_loading_want_read_) {
@ -637,6 +664,8 @@ class RequestProxy : public net::URLRequest::Delegate,
} }
void AsyncReadData() { void AsyncReadData() {
DCHECK(CefThread::CurrentlyOn(CefThread::IO));
// Pause downloading if we're in deferred mode. // Pause downloading if we're in deferred mode.
if (defers_loading_) { if (defers_loading_) {
defers_loading_want_read_ = true; defers_loading_want_read_ = true;
@ -679,6 +708,8 @@ class RequestProxy : public net::URLRequest::Delegate,
const GURL& new_url, const GURL& new_url,
const ResourceResponseInfo& info, const ResourceResponseInfo& info,
bool* defer_redirect) { bool* defer_redirect) {
DCHECK(CefThread::CurrentlyOn(CefThread::IO));
*defer_redirect = true; // See AsyncFollowDeferredRedirect *defer_redirect = true; // See AsyncFollowDeferredRedirect
owner_loop_->PostTask(FROM_HERE, base::Bind( owner_loop_->PostTask(FROM_HERE, base::Bind(
&RequestProxy::NotifyReceivedRedirect, this, new_url, info)); &RequestProxy::NotifyReceivedRedirect, this, new_url, info));
@ -688,6 +719,8 @@ class RequestProxy : public net::URLRequest::Delegate,
const ResourceResponseInfo& info, const ResourceResponseInfo& info,
// only used when loading from a resource stream // only used when loading from a resource stream
const GURL& simulated_url) { const GURL& simulated_url) {
DCHECK(CefThread::CurrentlyOn(CefThread::IO));
GURL url; GURL url;
bool allow_download(false); bool allow_download(false);
if (request_.get()) { if (request_.get()) {
@ -706,6 +739,8 @@ class RequestProxy : public net::URLRequest::Delegate,
} }
virtual void OnReceivedData(int bytes_read) { virtual void OnReceivedData(int bytes_read) {
DCHECK(CefThread::CurrentlyOn(CefThread::IO));
if (download_to_file_) { if (download_to_file_) {
file_stream_.WriteSync(buf_->data(), bytes_read); file_stream_.WriteSync(buf_->data(), bytes_read);
owner_loop_->PostTask(FROM_HERE, base::Bind( owner_loop_->PostTask(FROM_HERE, base::Bind(
@ -720,6 +755,8 @@ class RequestProxy : public net::URLRequest::Delegate,
virtual void OnCompletedRequest(const net::URLRequestStatus& status, virtual void OnCompletedRequest(const net::URLRequestStatus& status,
const std::string& security_info, const std::string& security_info,
const base::TimeTicks& complete_time) { const base::TimeTicks& complete_time) {
DCHECK(CefThread::CurrentlyOn(CefThread::IO));
if (download_to_file_) if (download_to_file_)
file_stream_.CloseSync(); file_stream_.CloseSync();
@ -734,6 +771,8 @@ class RequestProxy : public net::URLRequest::Delegate,
virtual void OnReceivedRedirect(net::URLRequest* request, virtual void OnReceivedRedirect(net::URLRequest* request,
const GURL& new_url, const GURL& new_url,
bool* defer_redirect) OVERRIDE { bool* defer_redirect) OVERRIDE {
DCHECK(CefThread::CurrentlyOn(CefThread::IO));
DCHECK(request->status().is_success()); DCHECK(request->status().is_success());
ResourceResponseInfo info; ResourceResponseInfo info;
PopulateResponseInfo(request, &info); PopulateResponseInfo(request, &info);
@ -741,6 +780,8 @@ class RequestProxy : public net::URLRequest::Delegate,
} }
virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE { virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE {
DCHECK(CefThread::CurrentlyOn(CefThread::IO));
if (request->status().is_success()) { if (request->status().is_success()) {
ResourceResponseInfo info; ResourceResponseInfo info;
PopulateResponseInfo(request, &info); PopulateResponseInfo(request, &info);
@ -753,6 +794,8 @@ class RequestProxy : public net::URLRequest::Delegate,
virtual void OnAuthRequired(net::URLRequest* request, virtual void OnAuthRequired(net::URLRequest* request,
net::AuthChallengeInfo* auth_info) OVERRIDE { net::AuthChallengeInfo* auth_info) OVERRIDE {
DCHECK(CefThread::CurrentlyOn(CefThread::IO));
if (browser_.get()) { if (browser_.get()) {
CefRefPtr<CefClient> client = browser_->GetClient(); CefRefPtr<CefClient> client = browser_->GetClient();
if (client.get()) { if (client.get()) {
@ -779,12 +822,16 @@ class RequestProxy : public net::URLRequest::Delegate,
virtual void OnSSLCertificateError(net::URLRequest* request, virtual void OnSSLCertificateError(net::URLRequest* request,
const net::SSLInfo& ssl_info, const net::SSLInfo& ssl_info,
bool fatal) OVERRIDE { bool fatal) OVERRIDE {
DCHECK(CefThread::CurrentlyOn(CefThread::IO));
// Allow all certificate errors. // Allow all certificate errors.
request->ContinueDespiteLastError(); request->ContinueDespiteLastError();
} }
virtual void OnReadCompleted(net::URLRequest* request, virtual void OnReadCompleted(net::URLRequest* request,
int bytes_read) OVERRIDE { int bytes_read) OVERRIDE {
DCHECK(CefThread::CurrentlyOn(CefThread::IO));
if (request->status().is_success() && bytes_read > 0) { if (request->status().is_success() && bytes_read > 0) {
OnReceivedData(bytes_read); OnReceivedData(bytes_read);
} else { } else {
@ -796,6 +843,8 @@ class RequestProxy : public net::URLRequest::Delegate,
// Helpers and data: // Helpers and data:
void Done() { void Done() {
DCHECK(CefThread::CurrentlyOn(CefThread::IO));
if (resource_stream_.get()) { if (resource_stream_.get()) {
// Resource stream reads always complete successfully // Resource stream reads always complete successfully
OnCompletedRequest(URLRequestStatus(URLRequestStatus::SUCCESS, 0), OnCompletedRequest(URLRequestStatus(URLRequestStatus::SUCCESS, 0),
@ -812,8 +861,9 @@ class RequestProxy : public net::URLRequest::Delegate,
} }
} }
// Called on the IO thread.
void MaybeUpdateUploadProgress() { void MaybeUpdateUploadProgress() {
DCHECK(CefThread::CurrentlyOn(CefThread::IO));
// If a redirect is received upload is cancelled in net::URLRequest, we // If a redirect is received upload is cancelled in net::URLRequest, we
// should try to stop the |upload_progress_timer_| timer and return. // should try to stop the |upload_progress_timer_| timer and return.
if (!request_->has_upload()) { if (!request_->has_upload()) {
@ -851,6 +901,8 @@ class RequestProxy : public net::URLRequest::Delegate,
void PopulateResponseInfo(net::URLRequest* request, void PopulateResponseInfo(net::URLRequest* request,
ResourceResponseInfo* info) const { ResourceResponseInfo* info) const {
DCHECK(CefThread::CurrentlyOn(CefThread::IO));
info->request_time = request->request_time(); info->request_time = request->request_time();
info->response_time = request->response_time(); info->response_time = request->response_time();
info->headers = request->response_headers(); info->headers = request->response_headers();
@ -926,6 +978,8 @@ class SyncRequestProxy : public RequestProxy {
const GURL& new_url, const GURL& new_url,
const ResourceResponseInfo& info, const ResourceResponseInfo& info,
bool* defer_redirect) { bool* defer_redirect) {
DCHECK(CefThread::CurrentlyOn(CefThread::IO));
// TODO(darin): It would be much better if this could live in WebCore, but // TODO(darin): It would be much better if this could live in WebCore, but
// doing so requires API changes at all levels. Similar code exists in // doing so requires API changes at all levels. Similar code exists in
// WebCore/platform/network/cf/ResourceHandleCFNet.cpp :-( // WebCore/platform/network/cf/ResourceHandleCFNet.cpp :-(
@ -939,10 +993,14 @@ class SyncRequestProxy : public RequestProxy {
virtual void OnReceivedResponse(const ResourceResponseInfo& info, virtual void OnReceivedResponse(const ResourceResponseInfo& info,
const GURL&) { const GURL&) {
DCHECK(CefThread::CurrentlyOn(CefThread::IO));
*static_cast<ResourceResponseInfo*>(result_) = info; *static_cast<ResourceResponseInfo*>(result_) = info;
} }
virtual void OnReceivedData(int bytes_read) { virtual void OnReceivedData(int bytes_read) {
DCHECK(CefThread::CurrentlyOn(CefThread::IO));
if (download_to_file_) if (download_to_file_)
file_stream_.WriteSync(buf_->data(), bytes_read); file_stream_.WriteSync(buf_->data(), bytes_read);
else else
@ -953,6 +1011,8 @@ class SyncRequestProxy : public RequestProxy {
virtual void OnCompletedRequest(const net::URLRequestStatus& status, virtual void OnCompletedRequest(const net::URLRequestStatus& status,
const std::string& security_info, const std::string& security_info,
const base::TimeTicks& complete_time) { const base::TimeTicks& complete_time) {
DCHECK(CefThread::CurrentlyOn(CefThread::IO));
if (download_to_file_) if (download_to_file_)
file_stream_.CloseSync(); file_stream_.CloseSync();
@ -975,7 +1035,8 @@ class SyncRequestProxy : public RequestProxy {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class ResourceLoaderBridgeImpl : public ResourceLoaderBridge { class ResourceLoaderBridgeImpl : public ResourceLoaderBridge,
public base::NonThreadSafe {
public: public:
ResourceLoaderBridgeImpl(CefRefPtr<CefBrowserImpl> browser, ResourceLoaderBridgeImpl(CefRefPtr<CefBrowserImpl> browser,
const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info) const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info)
@ -998,7 +1059,7 @@ class ResourceLoaderBridgeImpl : public ResourceLoaderBridge {
if (proxy_) { if (proxy_) {
proxy_->DropPeer(); proxy_->DropPeer();
// Let the proxy die on the IO thread // Let the proxy die on the IO thread
CefThread::ReleaseSoon(CefThread::IO, FROM_HERE, proxy_); CefThread::ReleaseSoon(CefThread::IO, FROM_HERE, proxy_.release());
} }
} }
@ -1006,6 +1067,7 @@ class ResourceLoaderBridgeImpl : public ResourceLoaderBridge {
// ResourceLoaderBridge implementation: // ResourceLoaderBridge implementation:
virtual void AppendDataToUpload(const char* data, int data_len) OVERRIDE { virtual void AppendDataToUpload(const char* data, int data_len) OVERRIDE {
DCHECK(CalledOnValidThread());
DCHECK(params_.get()); DCHECK(params_.get());
if (!params_->upload) if (!params_->upload)
params_->upload = new net::UploadData(); params_->upload = new net::UploadData();
@ -1017,6 +1079,7 @@ class ResourceLoaderBridgeImpl : public ResourceLoaderBridge {
uint64 offset, uint64 offset,
uint64 length, uint64 length,
const base::Time& expected_modification_time) OVERRIDE { const base::Time& expected_modification_time) OVERRIDE {
DCHECK(CalledOnValidThread());
DCHECK(params_.get()); DCHECK(params_.get());
if (!params_->upload) if (!params_->upload)
params_->upload = new net::UploadData(); params_->upload = new net::UploadData();
@ -1025,6 +1088,7 @@ class ResourceLoaderBridgeImpl : public ResourceLoaderBridge {
} }
virtual void AppendBlobToUpload(const GURL& blob_url) OVERRIDE { virtual void AppendBlobToUpload(const GURL& blob_url) OVERRIDE {
DCHECK(CalledOnValidThread());
DCHECK(params_.get()); DCHECK(params_.get());
if (!params_->upload) if (!params_->upload)
params_->upload = new net::UploadData(); params_->upload = new net::UploadData();
@ -1032,6 +1096,7 @@ class ResourceLoaderBridgeImpl : public ResourceLoaderBridge {
} }
virtual void SetUploadIdentifier(int64 identifier) OVERRIDE { virtual void SetUploadIdentifier(int64 identifier) OVERRIDE {
DCHECK(CalledOnValidThread());
DCHECK(params_.get()); DCHECK(params_.get());
if (!params_->upload) if (!params_->upload)
params_->upload = new net::UploadData(); params_->upload = new net::UploadData();
@ -1039,38 +1104,38 @@ class ResourceLoaderBridgeImpl : public ResourceLoaderBridge {
} }
virtual bool Start(Peer* peer) OVERRIDE { virtual bool Start(Peer* peer) OVERRIDE {
DCHECK(CalledOnValidThread());
DCHECK(!proxy_); DCHECK(!proxy_);
proxy_ = new RequestProxy(browser_); proxy_ = new RequestProxy(browser_);
proxy_->AddRef();
proxy_->Start(peer, params_.release()); proxy_->Start(peer, params_.release());
return true; // Any errors will be reported asynchronously. return true; // Any errors will be reported asynchronously.
} }
virtual void Cancel() OVERRIDE { virtual void Cancel() OVERRIDE {
DCHECK(CalledOnValidThread());
DCHECK(proxy_); DCHECK(proxy_);
proxy_->Cancel(); proxy_->Cancel();
} }
virtual void SetDefersLoading(bool value) OVERRIDE { virtual void SetDefersLoading(bool value) OVERRIDE {
DCHECK(CalledOnValidThread());
DCHECK(proxy_); DCHECK(proxy_);
proxy_->SetDefersLoading(value); proxy_->SetDefersLoading(value);
} }
virtual void SyncLoad(SyncLoadResponse* response) OVERRIDE { virtual void SyncLoad(SyncLoadResponse* response) OVERRIDE {
DCHECK(CalledOnValidThread());
DCHECK(!proxy_); DCHECK(!proxy_);
// this may change as the result of a redirect // this may change as the result of a redirect
response->url = params_->url; response->url = params_->url;
proxy_ = new SyncRequestProxy(browser_, response); proxy_ = new SyncRequestProxy(browser_, response);
proxy_->AddRef();
proxy_->Start(NULL, params_.release()); proxy_->Start(NULL, params_.release());
static_cast<SyncRequestProxy*>(proxy_)->WaitForCompletion(); static_cast<SyncRequestProxy*>(proxy_.get())->WaitForCompletion();
} }
virtual void UpdateRoutingId(int new_routing_id) OVERRIDE {} virtual void UpdateRoutingId(int new_routing_id) OVERRIDE {}
@ -1083,7 +1148,7 @@ class ResourceLoaderBridgeImpl : public ResourceLoaderBridge {
// The request proxy is allocated when we start the request, and then it // The request proxy is allocated when we start the request, and then it
// sticks around until this ResourceLoaderBridge is destroyed. // sticks around until this ResourceLoaderBridge is destroyed.
RequestProxy* proxy_; scoped_refptr<RequestProxy> proxy_;
}; };
} // anonymous namespace } // anonymous namespace
@ -1093,6 +1158,8 @@ class ResourceLoaderBridgeImpl : public ResourceLoaderBridge {
// static // static
webkit_glue::ResourceLoaderBridge* BrowserResourceLoaderBridge::Create( webkit_glue::ResourceLoaderBridge* BrowserResourceLoaderBridge::Create(
const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info) { const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info) {
DCHECK(CefThread::CurrentlyOn(CefThread::UI));
CefRefPtr<CefBrowserImpl> browser = CefRefPtr<CefBrowserImpl> browser =
_Context->GetBrowserByID(request_info.routing_id); _Context->GetBrowserByID(request_info.routing_id);
return new ResourceLoaderBridgeImpl(browser.get(), request_info); return new ResourceLoaderBridgeImpl(browser.get(), request_info);

View File

@ -353,11 +353,14 @@ WebWidgetHost::WebWidgetHost()
} }
WebWidgetHost::~WebWidgetHost() { WebWidgetHost::~WebWidgetHost() {
if (view_)
ui::SetWindowUserData(view_, 0);
TrackMouseLeave(false); TrackMouseLeave(false);
ResetTooltip(); ResetTooltip();
if (view_) {
ui::SetWindowUserData(view_, 0);
ui::SetWindowProc(view_, DefWindowProc);
view_ = NULL;
}
} }
bool WebWidgetHost::WndProc(UINT message, WPARAM wparam, LPARAM lparam) { bool WebWidgetHost::WndProc(UINT message, WPARAM wparam, LPARAM lparam) {