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

Unified Diff: webkit/appcache/appcache_response.cc

Issue 9110017: AppCache: Use WeakPtr instead of base::Unretained for DiskCache callbacks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 12 months 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/appcache/appcache_response.cc
diff --git a/webkit/appcache/appcache_response.cc b/webkit/appcache/appcache_response.cc
index dba2eadf8092b97b6c9e79341f7e0e6242353347..b60d38774481e55505a19cbe562ae2ce1a1ce69f 100644
--- a/webkit/appcache/appcache_response.cc
+++ b/webkit/appcache/appcache_response.cc
@@ -248,7 +248,7 @@ void AppCacheResponseReader::OpenEntryIfNeededAndContinue() {
} else if (!disk_cache_) {
rv = net::ERR_FAILED;
} else {
- entry_ptr = new(AppCacheDiskCacheInterface::Entry*);
+ entry_ptr = new AppCacheDiskCacheInterface::Entry*;
open_callback_ =
base::Bind(&AppCacheResponseReader::OnOpenEntryComplete,
weak_factory_.GetWeakPtr(), base::Owned(entry_ptr));
@@ -368,10 +368,10 @@ void AppCacheResponseWriter::CreateEntryIfNeededAndContinue() {
rv = net::ERR_FAILED;
} else {
creation_phase_ = INITIAL_ATTEMPT;
- entry_ptr = new(AppCacheDiskCacheInterface::Entry*);
+ entry_ptr = new AppCacheDiskCacheInterface::Entry*;
create_callback_ =
base::Bind(&AppCacheResponseWriter::OnCreateEntryComplete,
- base::Unretained(this), base::Owned(entry_ptr));
+ weak_factory_.GetWeakPtr(), base::Owned(entry_ptr));
rv = disk_cache_->CreateEntry(response_id_, entry_ptr, create_callback_);
}
if (rv != net::ERR_IO_PENDING)
@@ -382,8 +382,6 @@ void AppCacheResponseWriter::OnCreateEntryComplete(
AppCacheDiskCacheInterface::Entry** entry, int rv) {
DCHECK(info_buffer_.get() || buffer_.get());
- AppCacheDiskCacheInterface::Entry** entry_ptr = NULL;
-
if (creation_phase_ == INITIAL_ATTEMPT) {
if (rv != net::OK) {
// We may try to overwrite existing entries.
@@ -395,10 +393,11 @@ void AppCacheResponseWriter::OnCreateEntryComplete(
}
} else if (creation_phase_ == DOOM_EXISTING) {
creation_phase_ = SECOND_ATTEMPT;
- entry_ptr = new(AppCacheDiskCacheInterface::Entry*);
+ AppCacheDiskCacheInterface::Entry** entry_ptr =
+ new AppCacheDiskCacheInterface::Entry*;
create_callback_ =
base::Bind(&AppCacheResponseWriter::OnCreateEntryComplete,
- base::Unretained(this), base::Owned(entry_ptr));
+ weak_factory_.GetWeakPtr(), base::Owned(entry_ptr));
rv = disk_cache_->CreateEntry(response_id_, entry_ptr, create_callback_);
if (rv != net::ERR_IO_PENDING)
OnCreateEntryComplete(entry_ptr, rv);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698