Moving file_util::FileInfo to base::PlatformFileInfo, and adding the
last_accessed and creation_time fields.

BUG=none
TEST=none


Review URL: http://codereview.chromium.org/3347005

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


CrOS-Libchrome-Original-Commit: 2f0193c279b1b40a82a6ad027ec9468272eb25b2
diff --git a/base/file_util.cc b/base/file_util.cc
index 4dae03b..e618903 100644
--- a/base/file_util.cc
+++ b/base/file_util.cc
@@ -185,7 +185,7 @@
 }
 
 bool GetFileSize(const FilePath& file_path, int64* file_size) {
-  FileInfo info;
+  base::PlatformFileInfo info;
   if (!GetFileInfo(file_path, &info))
     return false;
   *file_size = info.size;
diff --git a/base/file_util.h b/base/file_util.h
index ce30b5e..415a192 100644
--- a/base/file_util.h
+++ b/base/file_util.h
@@ -315,22 +315,8 @@
 bool NormalizeToNativeFilePath(const FilePath& path, FilePath* nt_path);
 #endif
 
-// Used to hold information about a given file path.  See GetFileInfo below.
-struct FileInfo {
-  // The size of the file in bytes.  Undefined when is_directory is true.
-  int64 size;
-
-  // True if the file corresponds to a directory.
-  bool is_directory;
-
-  // The last modified time of a file.
-  base::Time last_modified;
-
-  // Add additional fields here as needed.
-};
-
 // Returns information about the given file path.
-bool GetFileInfo(const FilePath& file_path, FileInfo* info);
+bool GetFileInfo(const FilePath& file_path, base::PlatformFileInfo* info);
 
 // Set the time of the last modification. Useful for unit tests.
 bool SetLastModifiedTime(const FilePath& file_path, base::Time last_modified);
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc
index 13798d3..99e15fe 100644
--- a/base/file_util_posix.cc
+++ b/base/file_util_posix.cc
@@ -474,13 +474,15 @@
   return true;
 }
 
-bool GetFileInfo(const FilePath& file_path, FileInfo* results) {
+bool GetFileInfo(const FilePath& file_path, base::PlatformFileInfo* results) {
   stat_wrapper_t file_info;
   if (CallStat(file_path.value().c_str(), &file_info) != 0)
     return false;
   results->is_directory = S_ISDIR(file_info.st_mode);
   results->size = file_info.st_size;
   results->last_modified = base::Time::FromTimeT(file_info.st_mtime);
+  results->last_accessed = base::Time::FromTimeT(file_info.st_atime);
+  results->creation_time = base::Time::FromTimeT(file_info.st_ctime);
   return true;
 }
 
diff --git a/base/file_util_proxy.cc b/base/file_util_proxy.cc
index d356ed3..1e6100e 100644
--- a/base/file_util_proxy.cc
+++ b/base/file_util_proxy.cc
@@ -423,7 +423,7 @@
  private:
   base::FileUtilProxy::GetFileInfoCallback* callback_;
   FilePath file_path_;
-  file_util::FileInfo file_info_;
+  base::PlatformFileInfo file_info_;
 };
 
 bool Start(const tracked_objects::Location& from_here,
diff --git a/base/file_util_proxy.h b/base/file_util_proxy.h
index 3fe7d58..9e9b95e 100644
--- a/base/file_util_proxy.h
+++ b/base/file_util_proxy.h
@@ -14,10 +14,6 @@
 #include "base/ref_counted.h"
 #include "base/tracked_objects.h"
 
-namespace file_util {
-struct FileInfo;
-}
-
 namespace base {
 
 namespace file_util_proxy {
@@ -31,6 +27,7 @@
 }  // namespace file_util_proxy
 
 class MessageLoopProxy;
+class Time;
 
 // This class provides asynchronous access to common file routines.
 class FileUtilProxy {
@@ -68,7 +65,7 @@
   // Retrieves the information about a file. It is invalid to pass NULL for the
   // callback.
   typedef Callback2<base::PlatformFileError /* error code */,
-                    const file_util::FileInfo& /*file_info*/
+                    const base::PlatformFileInfo& /* file_info */
                     >::Type GetFileInfoCallback;
   static bool GetFileInfo(
       scoped_refptr<MessageLoopProxy> message_loop_proxy,
diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc
index 26eb42d..b0bd274 100644
--- a/base/file_util_unittest.cc
+++ b/base/file_util_unittest.cc
@@ -1777,7 +1777,7 @@
   ASSERT_TRUE(base::Time::FromString(L"Tue, 15 Nov 1994, 12:45:26 GMT",
               &modification_time));
   ASSERT_TRUE(file_util::SetLastModifiedTime(foobar, modification_time));
-  file_util::FileInfo file_info;
+  base::PlatformFileInfo file_info;
   ASSERT_TRUE(file_util::GetFileInfo(foobar, &file_info));
   ASSERT_TRUE(file_info.last_modified == modification_time);
 }
diff --git a/base/platform_file.h b/base/platform_file.h
index 0e4d05c..802102c 100644
--- a/base/platform_file.h
+++ b/base/platform_file.h
@@ -6,7 +6,9 @@
 #define BASE_PLATFORM_FILE_H_
 #pragma once
 
+#include "base/basictypes.h"
 #include "build/build_config.h"
+#include "base/time.h"
 #if defined(OS_WIN)
 #include <windows.h>
 #endif
@@ -55,6 +57,28 @@
   PLATFORM_FILE_ERROR_INVALID_OPERATION = -10
 };
 
+// Used to hold information about a given file.
+// If you add more fields to this structure (platform-specific fields are OK),
+// make sure to update all functions that use it in file_util_{win|posix}.cc
+// too, and the ParamTraits<base::PlatformFileInfo> implementation in
+// chrome/common/common_param_traits.cc.
+struct PlatformFileInfo {
+  // The size of the file in bytes.  Undefined when is_directory is true.
+  int64 size;
+
+  // True if the file corresponds to a directory.
+  bool is_directory;
+
+  // The last modified time of a file.
+  base::Time last_modified;
+
+  // The last accessed time of a file.
+  base::Time last_accessed;
+
+  // The creation time of a file.
+  base::Time creation_time;
+};
+
 // Creates or opens the given file. If PLATFORM_FILE_OPEN_ALWAYS is used, and
 // |created| is provided, |created| will be set to true if the file was created
 // or to false in case the file was just opened. |error_code| can be NULL.
diff --git a/base/time.h b/base/time.h
index 539cc14..0f5eb5d 100644
--- a/base/time.h
+++ b/base/time.h
@@ -259,6 +259,7 @@
 #if defined(OS_WIN)
   static Time FromFileTime(FILETIME ft);
   FILETIME ToFileTime() const;
+  static Time FromLargeInteger(LARGE_INTEGER li);
 
   // The minimum time of a low resolution timer.  This is basically a windows
   // constant of ~15.6ms.  While it does vary on some older OS versions, we'll