Only support seeking file streams from the beginning of the file.

On Windows file streams are backed by files opened for overlapped I/O.
In this mode SetFilePointerEx (used for seeking) will return a write-
protected media error if the file is on write-protected media. This is
even if the file is opened read-only! Since no code (except for the
FileStream tests) calls Seek with anything other than File::FROM_BEGIN
it is simplest to simply remove this capability. That way we can update
the offset in the FileStream context's overlapped structure without
going through a call to Windows.

BUG=478227

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

Cr-Commit-Position: refs/heads/master@{#334518}


CrOS-Libchrome-Original-Commit: aa435e70c70364430093361b5b8c460831f80bb4
diff --git a/base/files/file.cc b/base/files/file.cc
index 58f80c5..6dfeb91 100644
--- a/base/files/file.cc
+++ b/base/files/file.cc
@@ -63,6 +63,15 @@
   Close();
 }
 
+// static
+File File::CreateForAsyncHandle(PlatformFile platform_file) {
+  File file(platform_file);
+  // It would be nice if we could validate that |platform_file| was opened with
+  // FILE_FLAG_OVERLAPPED on Windows but this doesn't appear to be possible.
+  file.async_ = true;
+  return file.Pass();
+}
+
 File& File::operator=(RValue other) {
   if (this != other.object) {
     Close();