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

Side by Side Diff: base/files/file_posix.cc

Issue 109273002: Convert base::MemoryMappedFile to use File instead of PlatformFile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/files/file.h" 5 #include "base/files/file.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <sys/stat.h> 9 #include <sys/stat.h>
10 #include <unistd.h> 10 #include <unistd.h>
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 NOTIMPLEMENTED(); // NaCl doesn't implement flock struct. 115 NOTIMPLEMENTED(); // NaCl doesn't implement flock struct.
116 return File::FILE_ERROR_INVALID_OPERATION; 116 return File::FILE_ERROR_INVALID_OPERATION;
117 } 117 }
118 #endif // defined(OS_NACL) 118 #endif // defined(OS_NACL)
119 119
120 } // namespace 120 } // namespace
121 121
122 // NaCl doesn't implement system calls to open files directly. 122 // NaCl doesn't implement system calls to open files directly.
123 #if !defined(OS_NACL) 123 #if !defined(OS_NACL)
124 // TODO(erikkay): does it make sense to support FLAG_EXCLUSIVE_* here? 124 // TODO(erikkay): does it make sense to support FLAG_EXCLUSIVE_* here?
125 void File::CreateBaseFileUnsafe(const FilePath& name, uint32 flags) { 125 void File::InitializeUnsafe(const FilePath& name, uint32 flags) {
126 base::ThreadRestrictions::AssertIOAllowed(); 126 base::ThreadRestrictions::AssertIOAllowed();
127 DCHECK(!IsValid()); 127 DCHECK(!IsValid());
128 DCHECK(!(flags & FLAG_ASYNC)); 128 DCHECK(!(flags & FLAG_ASYNC));
129 129
130 int open_flags = 0; 130 int open_flags = 0;
131 if (flags & FLAG_CREATE) 131 if (flags & FLAG_CREATE)
132 open_flags = O_CREAT | O_EXCL; 132 open_flags = O_CREAT | O_EXCL;
133 133
134 created_ = false; 134 created_ = false;
135 135
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 334
335 int File::WriteAtCurrentPosNoBestEffort(const char* data, int size) { 335 int File::WriteAtCurrentPosNoBestEffort(const char* data, int size) {
336 base::ThreadRestrictions::AssertIOAllowed(); 336 base::ThreadRestrictions::AssertIOAllowed();
337 DCHECK(IsValid()); 337 DCHECK(IsValid());
338 if (size < 0) 338 if (size < 0)
339 return -1; 339 return -1;
340 340
341 return HANDLE_EINTR(write(file_, data, size)); 341 return HANDLE_EINTR(write(file_, data, size));
342 } 342 }
343 343
344 bool File::Truncate(int64 length) { 344 int64 File::GetLength() {
345 DCHECK(IsValid());
346 int64 current = Seek(File::FROM_CURRENT, 0);
347 int64 len = Seek(File::FROM_END, 0);
348 Seek(File::FROM_BEGIN, current);
349 return len;
350 }
cpu_(ooo_6.6-7.5) 2013/12/21 22:59:33 ignorance: is seeking 3 times the way of the posix
rvargas (doing something else) 2013/12/27 23:54:39 definitely my bad.
351
352 bool File::SetLength(int64 length) {
345 base::ThreadRestrictions::AssertIOAllowed(); 353 base::ThreadRestrictions::AssertIOAllowed();
346 DCHECK(IsValid()); 354 DCHECK(IsValid());
347 return !CallFtruncate(file_, length); 355 return !CallFtruncate(file_, length);
348 } 356 }
349 357
350 bool File::Flush() { 358 bool File::Flush() {
351 base::ThreadRestrictions::AssertIOAllowed(); 359 base::ThreadRestrictions::AssertIOAllowed();
352 DCHECK(IsValid()); 360 DCHECK(IsValid());
353 return !CallFsync(file_); 361 return !CallFsync(file_);
354 } 362 }
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 return FILE_ERROR_FAILED; 469 return FILE_ERROR_FAILED;
462 } 470 }
463 } 471 }
464 472
465 void File::SetPlatformFile(PlatformFile file) { 473 void File::SetPlatformFile(PlatformFile file) {
466 DCHECK_EQ(file_, kInvalidPlatformFileValue); 474 DCHECK_EQ(file_, kInvalidPlatformFileValue);
467 file_ = file; 475 file_ = file;
468 } 476 }
469 477
470 } // namespace base 478 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698