Remove PlatforFile from fileapi/native_file_util

BUG=322664

Review URL: https://codereview.chromium.org/206783004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@259540 0039d316-1c4b-4281-b951-d872f2087c98


CrOS-Libchrome-Original-Commit: f4bc9f16e9b82645659403aa57ec9cabf20f514f
diff --git a/base/files/file.cc b/base/files/file.cc
index cd167b1..2a2f843 100644
--- a/base/files/file.cc
+++ b/base/files/file.cc
@@ -20,7 +20,7 @@
 
 File::File()
     : file_(kInvalidPlatformFileValue),
-      error_details_(FILE_OK),
+      error_details_(FILE_ERROR_FAILED),
       created_(false),
       async_(false) {
 }
@@ -45,6 +45,13 @@
 #endif
 }
 
+File::File(Error error_details)
+    : file_(kInvalidPlatformFileValue),
+      error_details_(error_details),
+      created_(false),
+      async_(false) {
+}
+
 File::File(RValue other)
     : file_(other.object->TakePlatformFile()),
       error_details_(other.object->error_details()),
diff --git a/base/files/file.h b/base/files/file.h
index dc7616b..a4aea07 100644
--- a/base/files/file.h
+++ b/base/files/file.h
@@ -149,6 +149,9 @@
   // Takes ownership of |platform_file|.
   explicit File(PlatformFile platform_file);
 
+  // Creates an object with a specific error_details code.
+  explicit File(Error error_details);
+
   // Move constructor for C++03 move emulation of this type.
   File(RValue other);
 
diff --git a/base/files/file_unittest.cc b/base/files/file_unittest.cc
index 59cba31..468b2a8 100644
--- a/base/files/file_unittest.cc
+++ b/base/files/file_unittest.cc
@@ -17,6 +17,17 @@
   FilePath file_path = temp_dir.path().AppendASCII("create_file_1");
 
   {
+    // Don't create a File at all.
+    File file;
+    EXPECT_FALSE(file.IsValid());
+    EXPECT_EQ(base::File::FILE_ERROR_FAILED, file.error_details());
+
+    File file2(base::File::FILE_ERROR_TOO_MANY_OPENED);
+    EXPECT_FALSE(file2.IsValid());
+    EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, file2.error_details());
+  }
+
+  {
     // Open a file that doesn't exist.
     File file(file_path, base::File::FLAG_OPEN | base::File::FLAG_READ);
     EXPECT_FALSE(file.IsValid());