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

Unified Diff: net/disk_cache/simple/simple_synchronous_entry.cc

Issue 15563005: **STILLBAKING** Switch SimpleCache to SequencedWorkerPool. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 7 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
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) {

Powered by Google App Engine
This is Rietveld 408576698