| Index: net/disk_cache/simple/simple_synchronous_entry.cc
|
| diff --git a/net/disk_cache/simple/simple_synchronous_entry.cc b/net/disk_cache/simple/simple_synchronous_entry.cc
|
| index 6e74fe92d30c92fef7b0ed87e1f24beab82df99a..c67e0cbaf77d63aab2bec48fa045d19fa2d81e76 100644
|
| --- a/net/disk_cache/simple/simple_synchronous_entry.cc
|
| +++ b/net/disk_cache/simple/simple_synchronous_entry.cc
|
| @@ -138,44 +138,50 @@ SimpleSynchronousEntry::CRCRecord::CRCRecord(int index_p,
|
| data_crc32(data_crc32_p) {
|
| }
|
|
|
| -// static
|
| +SimpleSynchronousEntry::SimpleSynchronousEntry(
|
| + const FilePath& path,
|
| + const std::string& key,
|
| + const uint64 entry_hash)
|
| + : path_(path),
|
| + key_(key),
|
| + entry_hash_(entry_hash),
|
| + have_open_files_(false),
|
| + initialized_(false) {
|
| + COMPILE_ASSERT(arraysize(data_size_) == arraysize(files_),
|
| + array_sizes_must_be_equal);
|
| + for (int i = 0; i < kSimpleEntryFileCount; ++i) {
|
| + files_[i] = kInvalidPlatformFileValue;
|
| + }
|
| +}
|
| +
|
| void SimpleSynchronousEntry::OpenEntry(
|
| const FilePath& path,
|
| const std::string& key,
|
| const uint64 entry_hash,
|
| - SimpleSynchronousEntry** out_entry,
|
| int* out_result) {
|
| DCHECK_EQ(entry_hash, simple_util::GetEntryHashKey(key));
|
| - SimpleSynchronousEntry* sync_entry = new SimpleSynchronousEntry(path, key,
|
| - entry_hash);
|
| - *out_result = sync_entry->InitializeForOpen();
|
| +
|
| + *out_result = InitializeForOpen();
|
| if (*out_result != net::OK) {
|
| - sync_entry->Doom();
|
| - delete sync_entry;
|
| - *out_entry = NULL;
|
| - return;
|
| + Doom();
|
| + if (have_open_files_)
|
| + CloseFiles();
|
| }
|
| - *out_entry = sync_entry;
|
| }
|
|
|
| -// static
|
| void SimpleSynchronousEntry::CreateEntry(
|
| const FilePath& path,
|
| const std::string& key,
|
| const uint64 entry_hash,
|
| - SimpleSynchronousEntry** out_entry,
|
| int* out_result) {
|
| DCHECK_EQ(entry_hash, GetEntryHashKey(key));
|
| - SimpleSynchronousEntry* sync_entry = new SimpleSynchronousEntry(path, key,
|
| - entry_hash);
|
| - *out_result = sync_entry->InitializeForCreate();
|
| - if (*out_result != net::OK) {
|
| - if (*out_result != net::ERR_FILE_EXISTS)
|
| - sync_entry->Doom();
|
| - delete sync_entry;
|
| - return;
|
| +
|
| + *out_result = InitializeForCreate();
|
| + if (*out_result != net::OK && *out_result != net::ERR_FILE_EXISTS) {
|
| + Doom();
|
| + if (have_open_files_)
|
| + CloseFiles();
|
| }
|
| - *out_entry = sync_entry;
|
| }
|
|
|
| // TODO(gavinp): Move this function to its correct location in this .cc file.
|
| @@ -370,26 +376,8 @@ int64 SimpleSynchronousEntry::GetFileSize() const {
|
| return file_size;
|
| }
|
|
|
| -SimpleSynchronousEntry::SimpleSynchronousEntry(
|
| - const FilePath& path,
|
| - const std::string& key,
|
| - const uint64 entry_hash)
|
| - : path_(path),
|
| - key_(key),
|
| - entry_hash_(entry_hash),
|
| - have_open_files_(false),
|
| - initialized_(false) {
|
| - COMPILE_ASSERT(arraysize(data_size_) == arraysize(files_),
|
| - array_sizes_must_be_equal);
|
| - for (int i = 0; i < kSimpleEntryFileCount; ++i) {
|
| - files_[i] = kInvalidPlatformFileValue;
|
| - }
|
| -}
|
| -
|
| SimpleSynchronousEntry::~SimpleSynchronousEntry() {
|
| - DCHECK(!(have_open_files_ && initialized_));
|
| - if (have_open_files_)
|
| - CloseFiles();
|
| + DCHECK(!have_open_files_);
|
| }
|
|
|
| bool SimpleSynchronousEntry::OpenOrCreateFiles(bool create) {
|
|
|