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

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

Issue 10701050: net: Implement canceling of all async operations in FileStream. (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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
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 // 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 22 matching lines...) Expand all
33 // attached. |net_log| may be NULL if no logging is needed. 33 // attached. |net_log| may be NULL if no logging is needed.
34 explicit FileStream(net::NetLog* net_log); 34 explicit FileStream(net::NetLog* net_log);
35 35
36 // Construct a FileStream with an existing file handle and opening flags. 36 // Construct a FileStream with an existing file handle and opening flags.
37 // |file| is valid file handle. 37 // |file| is valid file handle.
38 // |flags| is a bitfield of base::PlatformFileFlags when the file handle was 38 // |flags| is a bitfield of base::PlatformFileFlags when the file handle was
39 // opened. 39 // opened.
40 // |net_log| is the net log pointer to use to create a |BoundNetLog|. May be 40 // |net_log| is the net log pointer to use to create a |BoundNetLog|. May be
41 // NULL if logging is not needed. 41 // NULL if logging is not needed.
42 // The already opened file will not be automatically closed when FileStream 42 // The already opened file will not be automatically closed when FileStream
43 // is destructed. 43 // is destroyed.
44 // Note: new FileStream object takes ownership of the PlatformFile and will
willchan no longer on Chromium 2012/08/14 19:23:26 Nit: grammar is a bit off. Either it should be "th
45 // close it on destruction.
44 FileStream(base::PlatformFile file, int flags, net::NetLog* net_log); 46 FileStream(base::PlatformFile file, int flags, net::NetLog* net_log);
45 47
46 // If the file stream was opened with Open() or OpenSync(), the underlying 48 // If the file stream was opened with Open() or OpenSync(), the underlying
47 // file will be closed automatically by the destructor, if not closed 49 // file will be closed automatically by the destructor, if not closed
48 // manually. 50 // manually.
49 virtual ~FileStream(); 51 virtual ~FileStream();
50 52
51 // Call this method to close the FileStream, which was previously opened in 53 // Call this method to close the FileStream, which was previously opened in
52 // the async mode (PLATFORM_FILE_ASYNC) asynchronously. 54 // the async mode (PLATFORM_FILE_ASYNC) asynchronously.
53 // 55 //
54 // Once the operation is done, |callback| will be run on the thread where 56 // Once the operation is done, |callback| will be run on the thread where
55 // Close() was called, with OK (i.e. an error is not propagated just like 57 // Close() was called, with OK (i.e. an error is not propagated just like
56 // CloseSync() does not). 58 // CloseSync() does not).
57 // 59 //
58 // It is not OK to call Close() multiple times. The behavior is not defined. 60 // It is not OK to call Close() multiple times. The behavior is not defined.
59 // Note that there must never be any pending async operations. 61 // Note that there must never be any pending async operations.
60 virtual void Close(const CompletionCallback& callback); 62 virtual void Close(const CompletionCallback& callback);
61 63
62 // Call this method to close the FileStream synchronously. 64 // Call this method to close the FileStream synchronously.
63 // It is OK to call CloseSync() multiple times. Redundant calls are 65 // It is OK to call CloseSync() multiple times. Redundant calls are
64 // ignored. Note that if there are any pending async operations, they'll 66 // ignored. Note that if there are any pending async operations, they'll
65 // be aborted. 67 // be aborted and actual closing of the stream will happen asynchronously
68 // (to avoid races with async operation).
66 virtual void CloseSync(); 69 virtual void CloseSync();
67 70
68 // Call this method to open the FileStream asynchronously. The remaining 71 // Call this method to open the FileStream asynchronously. The remaining
69 // methods cannot be used unless the file is opened successfully. Returns 72 // methods cannot be used unless the file is opened successfully. Returns
70 // ERR_IO_PENDING if the operation is started. If the operation cannot be 73 // ERR_IO_PENDING if the operation is started. If the operation cannot be
71 // started then an error code is returned. 74 // started then an error code is returned.
72 // 75 //
73 // Once the operation is done, |callback| will be run on the thread where 76 // Once the operation is done, |callback| will be run on the thread where
74 // Open() was called, with the result code. open_flags is a bitfield of 77 // Open() was called, with the result code. open_flags is a bitfield of
75 // base::PlatformFileFlags. 78 // base::PlatformFileFlags.
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 #elif defined(OS_POSIX) 224 #elif defined(OS_POSIX)
222 FileStreamPosix impl_; 225 FileStreamPosix impl_;
223 #endif 226 #endif
224 227
225 DISALLOW_COPY_AND_ASSIGN(FileStream); 228 DISALLOW_COPY_AND_ASSIGN(FileStream);
226 }; 229 };
227 230
228 } // namespace net 231 } // namespace net
229 232
230 #endif // NET_BASE_FILE_STREAM_H_ 233 #endif // NET_BASE_FILE_STREAM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698