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

Unified Diff: base/files/base_file.cc

Issue 82963004: Base: Move platform_file.* to files/base_file.* (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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: base/files/base_file.cc
diff --git a/base/platform_file.cc b/base/files/base_file.cc
similarity index 26%
copy from base/platform_file.cc
copy to base/files/base_file.cc
index bb411b893fef5c97289db470416eade7eb6074a7..c01b8b07116148014697c2645950f3d135fe4e23 100644
--- a/base/platform_file.cc
+++ b/base/files/base_file.cc
@@ -2,30 +2,63 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/files/base_file.h"
+
+// TODO(rvargas): remove this (needed for kInvalidPlatformFileValue).
#include "base/platform_file.h"
namespace base {
-PlatformFileInfo::PlatformFileInfo()
+BaseFileInfo::BaseFileInfo()
: size(0),
is_directory(false),
is_symbolic_link(false) {
}
-PlatformFileInfo::~PlatformFileInfo() {}
+BaseFileInfo::~BaseFileInfo() {
+}
+
+BaseFile::BaseFile()
+ : file_(kInvalidPlatformFileValue),
+ error_(BASE_FILE_OK),
+ created_(false),
+ async_(false) {
+}
#if !defined(OS_NACL)
-PlatformFile CreatePlatformFile(const FilePath& name,
- int flags,
- bool* created,
- PlatformFileError* error) {
+BaseFile::BaseFile(const FilePath& name, int flags)
+ : file_(kInvalidPlatformFileValue),
+ error_(BASE_FILE_OK),
+ created_(false),
+ async_(false) {
if (name.ReferencesParent()) {
- if (error)
- *error = PLATFORM_FILE_ERROR_ACCESS_DENIED;
- return kInvalidPlatformFileValue;
+ error_ = BASE_FILE_ERROR_ACCESS_DENIED;
+ return;
}
- return CreatePlatformFileUnsafe(name, flags, created, error);
+ CreateBaseFileUnsafe(name, flags);
}
#endif
+BaseFile::BaseFile(RValue other)
+ : file_(other.object->TakePlatformFile()),
+ error_(other.object->error()),
+ created_(other.object->created()),
+ async_(other.object->async_) {
+}
+
+BaseFile::~BaseFile() {
+ Close();
+}
+
+BaseFile& BaseFile::operator=(RValue other) {
+ if (this != other.object) {
+ Close();
+ SetPlatformFile(other.object->TakePlatformFile());
+ error_ = other.object->error();
+ created_ = other.object->created();
+ async_ = other.object->async_;
+ }
+ return *this;
+}
+
} // namespace base

Powered by Google App Engine
This is Rietveld 408576698