mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-18 13:10:42 +01:00
- Fix a crash caused by CefBrowserHostImpl being deleted before CefCookieStoreProxy (issue #810).
- Add documentation explaining the relationship between network request processing classes. - Remove stale code in url_request_context_getter_proxy.cc. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@935 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
parent
ea920a4d9e
commit
c3bbaac18f
@ -286,6 +286,9 @@ CefRefPtr<CefBrowser> CefBrowserHost::CreateBrowserSync(
|
|||||||
// CefBrowserHostImpl static methods.
|
// CefBrowserHostImpl static methods.
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
CefBrowserHostImpl::~CefBrowserHostImpl() {
|
||||||
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
CefRefPtr<CefBrowserHostImpl> CefBrowserHostImpl::Create(
|
CefRefPtr<CefBrowserHostImpl> CefBrowserHostImpl::Create(
|
||||||
const CefWindowInfo& window_info,
|
const CefWindowInfo& window_info,
|
||||||
|
@ -75,7 +75,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
|||||||
virtual void OnResponse(const std::string& response) =0;
|
virtual void OnResponse(const std::string& response) =0;
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual ~CefBrowserHostImpl() {}
|
virtual ~CefBrowserHostImpl();
|
||||||
|
|
||||||
// Create a new CefBrowserHostImpl instance.
|
// Create a new CefBrowserHostImpl instance.
|
||||||
static CefRefPtr<CefBrowserHostImpl> Create(
|
static CefRefPtr<CefBrowserHostImpl> Create(
|
||||||
|
@ -143,6 +143,7 @@ CefURLRequestContextGetter::CefURLRequestContextGetter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
CefURLRequestContextGetter::~CefURLRequestContextGetter() {
|
CefURLRequestContextGetter::~CefURLRequestContextGetter() {
|
||||||
|
CEF_REQUIRE_IOT();
|
||||||
STLDeleteElements(&url_request_context_proxies_);
|
STLDeleteElements(&url_request_context_proxies_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,45 @@ class URLRequestJobFactory;
|
|||||||
class URLSecurityManager;
|
class URLSecurityManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Classes used in network request processing:
|
||||||
|
//
|
||||||
|
// RC = net::URLRequestContext
|
||||||
|
// Owns various network-related objects including the global cookie manager.
|
||||||
|
//
|
||||||
|
// RCP = CefURLRequestContextProxy
|
||||||
|
// Creates the CSP and forwards requests to the objects owned by RC.
|
||||||
|
//
|
||||||
|
// CSP = CefCookieStoreProxy
|
||||||
|
// Gives the CefCookieManager associated with CefBrowserHostImpl an
|
||||||
|
// opportunity to handle cookie requests. Otherwise forwards requests via RC
|
||||||
|
// to the global cookie manager.
|
||||||
|
//
|
||||||
|
// RCG = CefURLRequestContextGetter
|
||||||
|
// Creates the RC and manages RCP lifespan.
|
||||||
|
//
|
||||||
|
// RCGP = CefURLRequestContextGetterProxy
|
||||||
|
// Causes the RCG to create and destroy browser-specific RCPs.
|
||||||
|
//
|
||||||
|
// Relationship diagram:
|
||||||
|
// ref = reference (scoped_refptr)
|
||||||
|
// own = ownership (scoped_ptr)
|
||||||
|
// ptr = raw pointer
|
||||||
|
//
|
||||||
|
// global cookie manager, etc...
|
||||||
|
// ^
|
||||||
|
// |
|
||||||
|
// /-own-> RC <-ptr-\
|
||||||
|
// / \
|
||||||
|
// / /<-ptr-\ \
|
||||||
|
// / / \ \
|
||||||
|
// CefBrowserContext -ref-> RCG --own-> RCP --ref-> CSP
|
||||||
|
// ^ ^ /
|
||||||
|
// ref ptr /
|
||||||
|
// | / /
|
||||||
|
// CefBrowserHostImpl -ref-> RCGP----/ /
|
||||||
|
// ^ /
|
||||||
|
// \-ref--------------------------/
|
||||||
|
|
||||||
class CefURLRequestContextGetter : public net::URLRequestContextGetter {
|
class CefURLRequestContextGetter : public net::URLRequestContextGetter {
|
||||||
public:
|
public:
|
||||||
CefURLRequestContextGetter(
|
CefURLRequestContextGetter(
|
||||||
|
@ -3,125 +3,10 @@
|
|||||||
// be found in the LICENSE file.
|
// be found in the LICENSE file.
|
||||||
|
|
||||||
#include "libcef/browser/url_request_context_getter_proxy.h"
|
#include "libcef/browser/url_request_context_getter_proxy.h"
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "libcef/browser/browser_host_impl.h"
|
|
||||||
#include "libcef/browser/cookie_manager_impl.h"
|
|
||||||
#include "libcef/browser/thread_util.h"
|
#include "libcef/browser/thread_util.h"
|
||||||
#include "libcef/browser/url_request_context_getter.h"
|
#include "libcef/browser/url_request_context_getter.h"
|
||||||
#include "libcef/browser/url_request_context_proxy.h"
|
#include "libcef/browser/url_request_context_proxy.h"
|
||||||
|
|
||||||
#include "base/logging.h"
|
|
||||||
#include "base/message_loop_proxy.h"
|
|
||||||
#include "net/cookies/cookie_store.h"
|
|
||||||
#include "net/url_request/url_request_context.h"
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
class CefCookieStoreProxy : public net::CookieStore {
|
|
||||||
public:
|
|
||||||
explicit CefCookieStoreProxy(CefBrowserHostImpl* browser,
|
|
||||||
net::URLRequestContext* parent)
|
|
||||||
: parent_(parent),
|
|
||||||
browser_(browser) {
|
|
||||||
}
|
|
||||||
|
|
||||||
// net::CookieStore methods.
|
|
||||||
virtual void SetCookieWithOptionsAsync(
|
|
||||||
const GURL& url,
|
|
||||||
const std::string& cookie_line,
|
|
||||||
const net::CookieOptions& options,
|
|
||||||
const SetCookiesCallback& callback) OVERRIDE {
|
|
||||||
scoped_refptr<net::CookieStore> cookie_store = GetCookieStore();
|
|
||||||
cookie_store->SetCookieWithOptionsAsync(url, cookie_line, options,
|
|
||||||
callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void GetCookiesWithOptionsAsync(
|
|
||||||
const GURL& url, const net::CookieOptions& options,
|
|
||||||
const GetCookiesCallback& callback) OVERRIDE {
|
|
||||||
scoped_refptr<net::CookieStore> cookie_store = GetCookieStore();
|
|
||||||
cookie_store->GetCookiesWithOptionsAsync(url, options, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GetCookiesWithInfoAsync(
|
|
||||||
const GURL& url,
|
|
||||||
const net::CookieOptions& options,
|
|
||||||
const GetCookieInfoCallback& callback) OVERRIDE {
|
|
||||||
scoped_refptr<net::CookieStore> cookie_store = GetCookieStore();
|
|
||||||
cookie_store->GetCookiesWithInfoAsync(url, options, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void DeleteCookieAsync(const GURL& url,
|
|
||||||
const std::string& cookie_name,
|
|
||||||
const base::Closure& callback) OVERRIDE {
|
|
||||||
scoped_refptr<net::CookieStore> cookie_store = GetCookieStore();
|
|
||||||
cookie_store->DeleteCookieAsync(url, cookie_name, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void DeleteAllCreatedBetweenAsync(const base::Time& delete_begin,
|
|
||||||
const base::Time& delete_end,
|
|
||||||
const DeleteCallback& callback)
|
|
||||||
OVERRIDE {
|
|
||||||
scoped_refptr<net::CookieStore> cookie_store = GetCookieStore();
|
|
||||||
cookie_store->DeleteAllCreatedBetweenAsync(delete_begin, delete_end,
|
|
||||||
callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void DeleteSessionCookiesAsync(const DeleteCallback& callback)
|
|
||||||
OVERRIDE {
|
|
||||||
scoped_refptr<net::CookieStore> cookie_store = GetCookieStore();
|
|
||||||
cookie_store->DeleteSessionCookiesAsync(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual net::CookieMonster* GetCookieMonster() OVERRIDE {
|
|
||||||
scoped_refptr<net::CookieStore> cookie_store = GetCookieStore();
|
|
||||||
return cookie_store->GetCookieMonster();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
net::CookieStore* GetCookieStore() {
|
|
||||||
CEF_REQUIRE_IOT();
|
|
||||||
|
|
||||||
scoped_refptr<net::CookieStore> cookie_store;
|
|
||||||
|
|
||||||
CefRefPtr<CefClient> client = browser_->GetClient();
|
|
||||||
if (client.get()) {
|
|
||||||
CefRefPtr<CefRequestHandler> handler = client->GetRequestHandler();
|
|
||||||
if (handler.get()) {
|
|
||||||
// Get the manager from the handler.
|
|
||||||
CefRefPtr<CefCookieManager> manager =
|
|
||||||
handler->GetCookieManager(browser_,
|
|
||||||
browser_->GetLoadingURL().spec());
|
|
||||||
if (manager.get()) {
|
|
||||||
cookie_store =
|
|
||||||
reinterpret_cast<CefCookieManagerImpl*>(
|
|
||||||
manager.get())->cookie_monster();
|
|
||||||
DCHECK(cookie_store);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!cookie_store) {
|
|
||||||
// Use the global cookie store.
|
|
||||||
cookie_store = parent_->cookie_store();
|
|
||||||
}
|
|
||||||
|
|
||||||
DCHECK(cookie_store);
|
|
||||||
return cookie_store;
|
|
||||||
}
|
|
||||||
|
|
||||||
// This pointer is guaranteed by the CefRequestContextProxy object.
|
|
||||||
net::URLRequestContext* parent_;
|
|
||||||
CefBrowserHostImpl* browser_;
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(CefCookieStoreProxy);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
|
|
||||||
CefURLRequestContextGetterProxy::CefURLRequestContextGetterProxy(
|
CefURLRequestContextGetterProxy::CefURLRequestContextGetterProxy(
|
||||||
CefBrowserHostImpl* browser,
|
CefBrowserHostImpl* browser,
|
||||||
CefURLRequestContextGetter* parent)
|
CefURLRequestContextGetter* parent)
|
||||||
@ -133,6 +18,7 @@ CefURLRequestContextGetterProxy::CefURLRequestContextGetterProxy(
|
|||||||
}
|
}
|
||||||
|
|
||||||
CefURLRequestContextGetterProxy::~CefURLRequestContextGetterProxy() {
|
CefURLRequestContextGetterProxy::~CefURLRequestContextGetterProxy() {
|
||||||
|
CEF_REQUIRE_IOT();
|
||||||
if (context_proxy_)
|
if (context_proxy_)
|
||||||
parent_->ReleaseURLRequestContextProxy(context_proxy_);
|
parent_->ReleaseURLRequestContextProxy(context_proxy_);
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,9 @@ class CefCookieStoreProxy : public net::CookieStore {
|
|||||||
: parent_(parent),
|
: parent_(parent),
|
||||||
browser_(browser) {
|
browser_(browser) {
|
||||||
}
|
}
|
||||||
|
virtual ~CefCookieStoreProxy() {
|
||||||
|
CEF_REQUIRE_IOT();
|
||||||
|
}
|
||||||
|
|
||||||
// net::CookieStore methods.
|
// net::CookieStore methods.
|
||||||
virtual void SetCookieWithOptionsAsync(
|
virtual void SetCookieWithOptionsAsync(
|
||||||
@ -90,7 +93,7 @@ class CefCookieStoreProxy : public net::CookieStore {
|
|||||||
if (handler.get()) {
|
if (handler.get()) {
|
||||||
// Get the manager from the handler.
|
// Get the manager from the handler.
|
||||||
CefRefPtr<CefCookieManager> manager =
|
CefRefPtr<CefCookieManager> manager =
|
||||||
handler->GetCookieManager(browser_,
|
handler->GetCookieManager(browser_.get(),
|
||||||
browser_->GetLoadingURL().spec());
|
browser_->GetLoadingURL().spec());
|
||||||
if (manager.get()) {
|
if (manager.get()) {
|
||||||
cookie_store =
|
cookie_store =
|
||||||
@ -112,7 +115,7 @@ class CefCookieStoreProxy : public net::CookieStore {
|
|||||||
|
|
||||||
// This pointer is guaranteed by the CefRequestContextProxy object.
|
// This pointer is guaranteed by the CefRequestContextProxy object.
|
||||||
net::URLRequestContext* parent_;
|
net::URLRequestContext* parent_;
|
||||||
CefBrowserHostImpl* browser_;
|
CefRefPtr<CefBrowserHostImpl> browser_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(CefCookieStoreProxy);
|
DISALLOW_COPY_AND_ASSIGN(CefCookieStoreProxy);
|
||||||
};
|
};
|
||||||
@ -127,6 +130,7 @@ CefURLRequestContextProxy::CefURLRequestContextProxy(
|
|||||||
}
|
}
|
||||||
|
|
||||||
CefURLRequestContextProxy::~CefURLRequestContextProxy() {
|
CefURLRequestContextProxy::~CefURLRequestContextProxy() {
|
||||||
|
CEF_REQUIRE_IOT();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefURLRequestContextProxy::Initialize(CefBrowserHostImpl* browser) {
|
void CefURLRequestContextProxy::Initialize(CefBrowserHostImpl* browser) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user