Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6447)

Unified Diff: chrome/browser/profile.cc

Issue 13701: Use automatic memory management for URLRequestContext's members.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/build/net.vcproj » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/profile.cc
===================================================================
--- chrome/browser/profile.cc (revision 6881)
+++ chrome/browser/profile.cc (working copy)
@@ -110,7 +110,6 @@
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 @@
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 @@
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 @@
// 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 @@
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.
}
« no previous file with comments | « no previous file | net/build/net.vcproj » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698