OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_ |
11 #define NET_BASE_FILE_STREAM_H_ | 11 #define NET_BASE_FILE_STREAM_H_ |
12 #pragma once | 12 #pragma once |
13 | 13 |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/platform_file.h" | 15 #include "base/platform_file.h" |
16 #include "net/base/completion_callback.h" | 16 #include "net/base/completion_callback.h" |
17 #include "net/base/net_api.h" | 17 #include "net/base/net_export.h" |
18 | 18 |
19 class FilePath; | 19 class FilePath; |
20 | 20 |
21 namespace net { | 21 namespace net { |
22 | 22 |
23 // TODO(darin): Move this to a more generic location. | 23 // TODO(darin): Move this to a more generic location. |
24 // This explicit mapping matches both FILE_ on Windows and SEEK_ on Linux. | 24 // This explicit mapping matches both FILE_ on Windows and SEEK_ on Linux. |
25 enum Whence { | 25 enum Whence { |
26 FROM_BEGIN = 0, | 26 FROM_BEGIN = 0, |
27 FROM_CURRENT = 1, | 27 FROM_CURRENT = 1, |
28 FROM_END = 2 | 28 FROM_END = 2 |
29 }; | 29 }; |
30 | 30 |
31 class NET_API FileStream { | 31 class NET_EXPORT FileStream { |
32 public: | 32 public: |
33 FileStream(); | 33 FileStream(); |
34 | 34 |
35 // Construct a FileStream with an existing file handle and opening flags. | 35 // Construct a FileStream with an existing file handle and opening flags. |
36 // |file| is valid file handle. | 36 // |file| is valid file handle. |
37 // |flags| is a bitfield of base::PlatformFileFlags when the file handle was | 37 // |flags| is a bitfield of base::PlatformFileFlags when the file handle was |
38 // opened. | 38 // opened. |
39 // The already opened file will not be automatically closed when FileStream | 39 // The already opened file will not be automatically closed when FileStream |
40 // is destructed. | 40 // is destructed. |
41 FileStream(base::PlatformFile file, int flags); | 41 FileStream(base::PlatformFile file, int flags); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 base::PlatformFile file_; | 143 base::PlatformFile file_; |
144 int open_flags_; | 144 int open_flags_; |
145 bool auto_closed_; | 145 bool auto_closed_; |
146 | 146 |
147 DISALLOW_COPY_AND_ASSIGN(FileStream); | 147 DISALLOW_COPY_AND_ASSIGN(FileStream); |
148 }; | 148 }; |
149 | 149 |
150 } // namespace net | 150 } // namespace net |
151 | 151 |
152 #endif // NET_BASE_FILE_STREAM_H_ | 152 #endif // NET_BASE_FILE_STREAM_H_ |
OLD | NEW |