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

Unified Diff: net/disk_cache/flash/storage.cc

Issue 125643002: Convert most of base and net to use base::File (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use error_details() Created 6 years, 11 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/flash/storage.cc
diff --git a/net/disk_cache/flash/storage.cc b/net/disk_cache/flash/storage.cc
index c7136ef869b039167c187a115822b331fdd6feb0..9359b66ee6ad810af9017566f078fe7063cdf2c9 100644
--- a/net/disk_cache/flash/storage.cc
+++ b/net/disk_cache/flash/storage.cc
@@ -7,7 +7,6 @@
#include <fcntl.h>
#include "base/logging.h"
-#include "base/platform_file.h"
#include "net/base/net_errors.h"
#include "net/disk_cache/flash/format.h"
@@ -22,41 +21,38 @@ Storage::Storage(const base::FilePath& path,
}
bool Storage::Init() {
- int flags = base::PLATFORM_FILE_READ |
- base::PLATFORM_FILE_WRITE |
- base::PLATFORM_FILE_OPEN_ALWAYS;
+ int flags = base::File::FLAG_READ |
+ base::File::FLAG_WRITE |
+ base::File::FLAG_OPEN_ALWAYS;
- file_ = base::CreatePlatformFile(path_, flags, NULL, NULL);
- if (file_ == base::kInvalidPlatformFileValue)
+ file_.Initialize(path_, flags);
+ if (!file_.IsValid())
return false;
// TODO(agayev): if file already exists, do some validation and return either
// true or false based on the result.
#if defined(OS_LINUX)
- fallocate(file_, 0, 0, size_);
+ fallocate(file_.GetPlatformFile(), 0, 0, size_);
#endif
return true;
}
Storage::~Storage() {
- base::ClosePlatformFile(file_);
}
bool Storage::Read(void* buffer, int32 size, int32 offset) {
DCHECK(offset >= 0 && offset + size <= size_);
- int rv = base::ReadPlatformFile(file_, offset, static_cast<char*>(buffer),
- size);
+ int rv = file_.Read(offset, static_cast<char*>(buffer), size);
return rv == size;
}
bool Storage::Write(const void* buffer, int32 size, int32 offset) {
DCHECK(offset >= 0 && offset + size <= size_);
- int rv = base::WritePlatformFile(file_, offset,
- static_cast<const char*>(buffer), size);
+ int rv = file_.Write(offset, static_cast<const char*>(buffer), size);
return rv == size;
}

Powered by Google App Engine
This is Rietveld 408576698