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

Unified Diff: base/files/file_posix.cc

Issue 189393002: net: Update FileStream to use base::File instead of PlatformFile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use OPEN_ALWAYS on the async unit test Created 6 years, 9 months 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
« no previous file with comments | « base/files/file.h ('k') | base/files/file_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/files/file_posix.cc
diff --git a/base/files/file_posix.cc b/base/files/file_posix.cc
index f62491d21782b9d4791ddbb5663d98b4c00afce2..46d6d94eaaf77c42044bf39146cf05281d0ffc8e 100644
--- a/base/files/file_posix.cc
+++ b/base/files/file_posix.cc
@@ -125,7 +125,6 @@ static File::Error CallFctnlFlock(PlatformFile file, bool do_lock) {
void File::InitializeUnsafe(const FilePath& name, uint32 flags) {
base::ThreadRestrictions::AssertIOAllowed();
DCHECK(!IsValid());
- DCHECK(!(flags & FLAG_ASYNC));
int open_flags = 0;
if (flags & FLAG_CREATE)
@@ -191,17 +190,19 @@ void File::InitializeUnsafe(const FilePath& name, uint32 flags) {
}
}
- if (descriptor >= 0 && (flags & (FLAG_CREATE_ALWAYS | FLAG_CREATE)))
+ if (descriptor < 0) {
+ error_details_ = File::OSErrorToFileError(errno);
+ return;
+ }
+
+ if (flags & (FLAG_CREATE_ALWAYS | FLAG_CREATE))
created_ = true;
- if ((descriptor >= 0) && (flags & FLAG_DELETE_ON_CLOSE))
+ if (flags & FLAG_DELETE_ON_CLOSE)
unlink(name.value().c_str());
- if (descriptor >= 0)
- error_details_ = FILE_OK;
- else
- error_details_ = File::OSErrorToFileError(errno);
-
+ async_ = ((flags & FLAG_ASYNC) == FLAG_ASYNC);
+ error_details_ = FILE_OK;
file_.reset(descriptor);
}
#endif // !defined(OS_NACL)
« no previous file with comments | « base/files/file.h ('k') | base/files/file_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698