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

Unified Diff: net/disk_cache/block_files.cc

Issue 164336: Disk Cache: cleanup of OpenBlockFile.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 4 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 | « net/disk_cache/block_files.h ('k') | net/disk_cache/block_files_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/block_files.cc
===================================================================
--- net/disk_cache/block_files.cc (revision 22968)
+++ net/disk_cache/block_files.cc (working copy)
@@ -237,24 +237,18 @@
}
std::wstring name = Name(index);
- MappedFile* file = new MappedFile();
- file->AddRef();
+ scoped_refptr<MappedFile> file(new MappedFile());
if (!file->Init(name, kBlockHeaderSize)) {
- NOTREACHED();
LOG(ERROR) << "Failed to open " << name;
- file->Release();
return false;
}
if (file->GetLength() < static_cast<size_t>(kBlockHeaderSize)) {
LOG(ERROR) << "File too small " << name;
- file->Release();
return false;
}
- block_files_[index] = file;
-
BlockFileHeader* header = reinterpret_cast<BlockFileHeader*>(file->buffer());
if (kBlockMagic != header->magic || kCurrentVersion != header->version) {
LOG(ERROR) << "Invalid file version or magic";
@@ -266,6 +260,9 @@
if (!FixBlockFileHeader(file))
return false;
}
+
+ DCHECK(!block_files_[index]);
+ file.swap(&block_files_[index]);
return true;
}
« no previous file with comments | « net/disk_cache/block_files.h ('k') | net/disk_cache/block_files_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698