summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-13 03:44:24 +0000
committerericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-13 03:44:24 +0000
commitd49801990067e7fe9a3caf141f31c6e6ba58fcfc (patch)
tree502fef7a064f7e1b67291d418b897117e2427822 /chrome
parent96508147cf0947fdd4ae19d9ee7f5f2e13268a5f (diff)
downloadchromium_src-d49801990067e7fe9a3caf141f31c6e6ba58fcfc.zip
chromium_src-d49801990067e7fe9a3caf141f31c6e6ba58fcfc.tar.gz
chromium_src-d49801990067e7fe9a3caf141f31c6e6ba58fcfc.tar.bz2
Use automatic memory management for URLRequestContext's members.
Also make ProxyService refcounted so the sharing between profiles is explicit. Review URL: http://codereview.chromium.org/13701 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6966 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/profile.cc26
1 files changed, 8 insertions, 18 deletions
diff --git a/chrome/browser/profile.cc b/chrome/browser/profile.cc
index d8f2f64..8cd01f8 100644
--- a/chrome/browser/profile.cc
+++ b/chrome/browser/profile.cc
@@ -110,7 +110,6 @@ class ProfileImpl::RequestContext : public URLRequestContext,
const std::wstring& disk_cache_path,
PrefService* prefs)
: prefs_(prefs) {
- cookie_store_ = NULL;
// setup user agent
user_agent_ = webkit_glue::GetUserAgent();
@@ -135,18 +134,18 @@ class ProfileImpl::RequestContext : public URLRequestContext,
if (record_mode || playback_mode) {
// Don't use existing cookies and use an in-memory store.
- cookie_store_ = new net::CookieMonster();
+ cookie_store_.reset(new net::CookieMonster());
cache->set_mode(
record_mode ? net::HttpCache::RECORD : net::HttpCache::PLAYBACK);
}
- http_transaction_factory_ = cache;
+ http_transaction_factory_.reset(cache);
// setup cookie store
- if (!cookie_store_) {
+ if (!cookie_store_.get()) {
DCHECK(!cookie_store_path.empty());
cookie_db_.reset(new SQLitePersistentCookieStore(
cookie_store_path, g_browser_process->db_thread()->message_loop()));
- cookie_store_ = new net::CookieMonster(cookie_db_.get());
+ cookie_store_.reset(new net::CookieMonster(cookie_db_.get()));
}
cookie_policy_.SetType(net::CookiePolicy::FromInt(
@@ -216,10 +215,6 @@ class ProfileImpl::RequestContext : public URLRequestContext,
virtual ~RequestContext() {
DCHECK(NULL == prefs_);
- delete cookie_store_;
- delete http_transaction_factory_;
- delete proxy_service_;
-
if (default_request_context_ == this)
default_request_context_ = NULL;
}
@@ -254,13 +249,12 @@ class OffTheRecordRequestContext : public URLRequestContext,
// context to make sure it doesn't go away when we delete the object graph.
original_context_ = profile->GetRequestContext();
- // Share the same proxy service as the original profile. This proxy
- // service's lifespan is dependent on the lifespan of the original profile,
- // which we reference (see above).
+ // Share the same proxy service as the original profile (adds a reference).
proxy_service_ = original_context_->proxy_service();
- http_transaction_factory_ = new net::HttpCache(proxy_service_, 0);
- cookie_store_ = new net::CookieMonster;
+ http_transaction_factory_.reset(
+ new net::HttpCache(proxy_service_, 0));
+ cookie_store_.reset(new net::CookieMonster);
cookie_policy_.SetType(net::CookiePolicy::FromInt(
prefs_->GetInteger(prefs::kCookieBehavior)));
user_agent_ = original_context_->user_agent();
@@ -326,10 +320,6 @@ class OffTheRecordRequestContext : public URLRequestContext,
virtual ~OffTheRecordRequestContext() {
DCHECK(NULL == prefs_);
- delete cookie_store_;
- delete http_transaction_factory_;
- // NOTE: do not delete |proxy_service_| as is owned by the original profile.
-
// The OffTheRecordRequestContext simply act as a proxy to the real context.
// There is nothing else to delete.
}