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

Side by Side Diff: net/base/file_stream_posix.cc

Issue 6314010: Even more reordering the methods in headers and implementation in net/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/base/file_stream.h ('k') | net/base/filter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 // For 64-bit file access (off_t = off64_t, lseek64, etc). 5 // For 64-bit file access (off_t = off64_t, lseek64, etc).
6 #define _FILE_OFFSET_BITS 64 6 #define _FILE_OFFSET_BITS 64
7 7
8 #include "net/base/file_stream.h" 8 #include "net/base/file_stream.h"
9 9
10 #include <sys/types.h> 10 #include <sys/types.h>
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 DCHECK(open_flags_ & base::PLATFORM_FILE_ASYNC); 447 DCHECK(open_flags_ & base::PLATFORM_FILE_ASYNC);
448 // If we're in async, make sure we don't have a request in flight. 448 // If we're in async, make sure we don't have a request in flight.
449 DCHECK(!async_context_->callback()); 449 DCHECK(!async_context_->callback());
450 async_context_->InitiateAsyncWrite(file_, buf, buf_len, callback); 450 async_context_->InitiateAsyncWrite(file_, buf, buf_len, callback);
451 return ERR_IO_PENDING; 451 return ERR_IO_PENDING;
452 } else { 452 } else {
453 return WriteFile(file_, buf, buf_len); 453 return WriteFile(file_, buf, buf_len);
454 } 454 }
455 } 455 }
456 456
457 int FileStream::Flush() {
458 if (!IsOpen())
459 return ERR_UNEXPECTED;
460
461 return FlushFile(file_);
462 }
463
464 int64 FileStream::Truncate(int64 bytes) { 457 int64 FileStream::Truncate(int64 bytes) {
465 if (!IsOpen()) 458 if (!IsOpen())
466 return ERR_UNEXPECTED; 459 return ERR_UNEXPECTED;
467 460
468 // We better be open for reading. 461 // We better be open for reading.
469 DCHECK(open_flags_ & base::PLATFORM_FILE_WRITE); 462 DCHECK(open_flags_ & base::PLATFORM_FILE_WRITE);
470 463
471 // Seek to the position to truncate from. 464 // Seek to the position to truncate from.
472 int64 seek_position = Seek(FROM_BEGIN, bytes); 465 int64 seek_position = Seek(FROM_BEGIN, bytes);
473 if (seek_position != bytes) 466 if (seek_position != bytes)
474 return ERR_UNEXPECTED; 467 return ERR_UNEXPECTED;
475 468
476 // And truncate the file. 469 // And truncate the file.
477 int result = ftruncate(file_, bytes); 470 int result = ftruncate(file_, bytes);
478 return result == 0 ? seek_position : MapErrorCode(errno); 471 return result == 0 ? seek_position : MapErrorCode(errno);
479 } 472 }
480 473
474 int FileStream::Flush() {
475 if (!IsOpen())
476 return ERR_UNEXPECTED;
477
478 return FlushFile(file_);
479 }
480
481 } // namespace net 481 } // namespace net
OLDNEW
« no previous file with comments | « net/base/file_stream.h ('k') | net/base/filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698