summaryrefslogtreecommitdiffstats
path: root/chrome/browser/net
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-05 00:17:14 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-05 00:17:14 +0000
commit2bebd9963b25ad9e868a719fe56e348c6c153ba7 (patch)
tree49f998348a20ad7a70e36d83012adc851eb4b2c0 /chrome/browser/net
parent5e17ec91e76c813d8fd0aa189a20d51e47ce93ca (diff)
downloadchromium_src-2bebd9963b25ad9e868a719fe56e348c6c153ba7.zip
chromium_src-2bebd9963b25ad9e868a719fe56e348c6c153ba7.tar.gz
chromium_src-2bebd9963b25ad9e868a719fe56e348c6c153ba7.tar.bz2
This CL changes the CookieStore obect to be a refcounted object to get a better handle on its lifetime as there are cases where this object is handed out to URLRequestContext instances which outlive the URLRequestContext object which created it.
Partial fix for http://code.google.com/p/chromium/issues/detail?id=15289 Bug=15289 Review URL: http://codereview.chromium.org/197023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25558 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net')
-rw-r--r--chrome/browser/net/chrome_url_request_context.cc31
-rw-r--r--chrome/browser/net/chrome_url_request_context.h1
2 files changed, 12 insertions, 20 deletions
diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc
index 0bc5572..ed69b03 100644
--- a/chrome/browser/net/chrome_url_request_context.cc
+++ b/chrome/browser/net/chrome_url_request_context.cc
@@ -155,10 +155,12 @@ ChromeURLRequestContext* ChromeURLRequestContext::CreateOriginal(
// setup cookie store
if (!context->cookie_store_) {
DCHECK(!cookie_store_path.empty());
- context->cookie_db_.reset(new SQLitePersistentCookieStore(
- cookie_store_path.ToWStringHack(),
- g_browser_process->db_thread()->message_loop()));
- context->cookie_store_ = new net::CookieMonster(context->cookie_db_.get());
+
+ scoped_refptr<SQLitePersistentCookieStore> cookie_db =
+ new SQLitePersistentCookieStore(
+ cookie_store_path.ToWStringHack(),
+ g_browser_process->db_thread()->message_loop());
+ context->cookie_store_ = new net::CookieMonster(cookie_db.get());
}
return context;
@@ -180,11 +182,12 @@ ChromeURLRequestContext* ChromeURLRequestContext::CreateOriginalForExtensions(
// All we care about for extensions is the cookie store.
DCHECK(!cookie_store_path.empty());
- context->cookie_db_.reset(new SQLitePersistentCookieStore(
- cookie_store_path.ToWStringHack(),
- g_browser_process->db_thread()->message_loop()));
- net::CookieMonster* cookie_monster = new net::CookieMonster(
- context->cookie_db_.get());
+
+ scoped_refptr<SQLitePersistentCookieStore> cookie_db =
+ new SQLitePersistentCookieStore(
+ cookie_store_path.ToWStringHack(),
+ g_browser_process->db_thread()->message_loop());
+ net::CookieMonster* cookie_monster = new net::CookieMonster(cookie_db.get());
// Enable cookies for extension URLs only.
const char* schemes[] = {chrome::kExtensionScheme};
@@ -542,14 +545,4 @@ ChromeURLRequestContext::~ChromeURLRequestContext() {
delete ftp_transaction_factory_;
delete http_transaction_factory_;
-
- // Do not delete the cookie store in the case of the media context, as it is
- // owned by the original context.
- // TODO(eroman): The lifetime expectation of cookie_store_ is not right.
- // The assumption here is that the original request context (which owns
- // cookie_store_) is going to outlive the media context (which uses it).
- // However based on the destruction order of profiles this is not true.
- // http://crbug.com/15289.
- if (!is_media_)
- delete cookie_store_;
}
diff --git a/chrome/browser/net/chrome_url_request_context.h b/chrome/browser/net/chrome_url_request_context.h
index d0303d7..067cf10a 100644
--- a/chrome/browser/net/chrome_url_request_context.h
+++ b/chrome/browser/net/chrome_url_request_context.h
@@ -127,7 +127,6 @@ class ChromeURLRequestContext : public URLRequestContext,
scoped_refptr<ChromeAppCacheService> appcache_service_;
- scoped_ptr<SQLitePersistentCookieStore> cookie_db_;
PrefService* prefs_;
const Blacklist* blacklist_;
bool is_media_;