Convert base::MemoryMappedFile to use File instead of PlatformFile.

This also modifies consumers of MemoryMappedFile and fixes double handle
close on MediaFileChecker, media_file_checker_unittest and data_pack_unittests.

BUG=322664
TEST=unit tests

[email protected], [email protected] (media)

TBR (owners):
[email protected] (resource)
[email protected] (chrome-content)
[email protected] (base)

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@242937 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/base/files/file_posix.cc b/base/files/file_posix.cc
index 9d97c33..e8b4d77 100644
--- a/base/files/file_posix.cc
+++ b/base/files/file_posix.cc
@@ -122,7 +122,7 @@
 // NaCl doesn't implement system calls to open files directly.
 #if !defined(OS_NACL)
 // TODO(erikkay): does it make sense to support FLAG_EXCLUSIVE_* here?
-void File::CreateBaseFileUnsafe(const FilePath& name, uint32 flags) {
+void File::InitializeUnsafe(const FilePath& name, uint32 flags) {
   base::ThreadRestrictions::AssertIOAllowed();
   DCHECK(!IsValid());
   DCHECK(!(flags & FLAG_ASYNC));
@@ -341,7 +341,17 @@
   return HANDLE_EINTR(write(file_, data, size));
 }
 
-bool File::Truncate(int64 length) {
+int64 File::GetLength() {
+  DCHECK(IsValid());
+
+  stat_wrapper_t file_info;
+  if (CallFstat(file_, &file_info))
+    return false;
+
+  return file_info.st_size;
+}
+
+bool File::SetLength(int64 length) {
   base::ThreadRestrictions::AssertIOAllowed();
   DCHECK(IsValid());
   return !CallFtruncate(file_, length);