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

Side by Side Diff: net/base/file_stream.h

Issue 21363: Adds a new method ReadUntilComplete to FileStream which ensure that a... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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 | « no previous file | net/base/file_stream_posix.cc » ('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) 2008 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 // This file defines FileStream, a basic interface for reading and writing files 5 // This file defines FileStream, a basic interface for reading and writing files
6 // synchronously or asynchronously with support for seeking to an offset. 6 // synchronously or asynchronously with support for seeking to an offset.
7 // Note that even when used asynchronously, only one operation is supported at 7 // Note that even when used asynchronously, only one operation is supported at
8 // a time. 8 // a time.
9 9
10 #ifndef NET_BASE_FILE_STREAM_H_ 10 #ifndef NET_BASE_FILE_STREAM_H_
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 // In the case of an asychronous read, the memory pointed to by |buf| must 74 // In the case of an asychronous read, the memory pointed to by |buf| must
75 // remain valid until the callback is notified. However, it is valid to 75 // remain valid until the callback is notified. However, it is valid to
76 // destroy or close the file stream while there is an asynchronous read in 76 // destroy or close the file stream while there is an asynchronous read in
77 // progress. That will cancel the read and allow the buffer to be freed. 77 // progress. That will cancel the read and allow the buffer to be freed.
78 // 78 //
79 // This method should not be called if the stream was opened WRITE_ONLY. 79 // This method should not be called if the stream was opened WRITE_ONLY.
80 // 80 //
81 // You can pass NULL as the callback for synchronous I/O. 81 // You can pass NULL as the callback for synchronous I/O.
82 int Read(char* buf, int buf_len, CompletionCallback* callback); 82 int Read(char* buf, int buf_len, CompletionCallback* callback);
83 83
84 // Performs the same as Read, but ensures that exactly buf_len bytes
85 // are copied into buf. A partial read may occur, but only as a result of
86 // end-of-file or fatal error. Returns the number of bytes copied into buf,
87 // 0 if at end-of-file and no bytes have been read into buf yet,
88 // or an error code if the operation could not be performed.
89 int ReadUntilComplete(char *buf, int buf_len);
90
84 // Call this method to write data at the current stream position. Up to 91 // Call this method to write data at the current stream position. Up to
85 // buf_len bytes will be written from buf. (In other words, partial writes are 92 // buf_len bytes will be written from buf. (In other words, partial writes are
86 // allowed.) Returns the number of bytes written, or an error code if the 93 // allowed.) Returns the number of bytes written, or an error code if the
87 // operation could not be performed. 94 // operation could not be performed.
88 // 95 //
89 // If opened with PLATFORM_FILE_ASYNC, then a non-null callback 96 // If opened with PLATFORM_FILE_ASYNC, then a non-null callback
90 // must be passed to this method. In asynchronous mode, if the write could 97 // must be passed to this method. In asynchronous mode, if the write could
91 // not complete synchronously, then ERR_IO_PENDING is returned, and the 98 // not complete synchronously, then ERR_IO_PENDING is returned, and the
92 // callback will be notified on the current thread (via the MessageLoop) when 99 // callback will be notified on the current thread (via the MessageLoop) when
93 // the write has completed. 100 // the write has completed.
(...skipping 18 matching lines...) Expand all
112 119
113 base::PlatformFile file_; 120 base::PlatformFile file_;
114 int open_flags_; 121 int open_flags_;
115 122
116 DISALLOW_COPY_AND_ASSIGN(FileStream); 123 DISALLOW_COPY_AND_ASSIGN(FileStream);
117 }; 124 };
118 125
119 } // namespace net 126 } // namespace net
120 127
121 #endif // NET_BASE_FILE_STREAM_H_ 128 #endif // NET_BASE_FILE_STREAM_H_
OLDNEW
« no previous file with comments | « no previous file | net/base/file_stream_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698