OLD | NEW |
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_ |
11 #define NET_BASE_FILE_STREAM_H_ | 11 #define NET_BASE_FILE_STREAM_H_ |
12 | 12 |
13 #include "base/platform_file.h" | 13 #include "base/platform_file.h" |
14 #include "base/task_runner.h" | 14 #include "base/task_runner.h" |
15 #include "net/base/completion_callback.h" | 15 #include "net/base/completion_callback.h" |
16 #include "net/base/file_stream_whence.h" | 16 #include "net/base/file_stream_whence.h" |
17 #include "net/base/net_export.h" | 17 #include "net/base/net_export.h" |
18 #include "net/base/net_log.h" | 18 #include "net/base/net_log.h" |
19 | 19 |
| 20 #if defined(OS_ANDROID) |
| 21 #include "url/gurl.h" |
| 22 #endif |
| 23 |
20 namespace base { | 24 namespace base { |
21 class FilePath; | 25 class FilePath; |
22 } | 26 } |
23 | 27 |
24 namespace net { | 28 namespace net { |
25 | 29 |
26 class IOBuffer; | 30 class IOBuffer; |
27 | 31 |
28 class NET_EXPORT FileStream { | 32 class NET_EXPORT FileStream { |
29 public: | 33 public: |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 | 78 |
75 // Call this method to open the FileStream synchronously. | 79 // Call this method to open the FileStream synchronously. |
76 // The remaining methods cannot be used unless this method returns OK. If | 80 // The remaining methods cannot be used unless this method returns OK. If |
77 // the file cannot be opened then an error code is returned. open_flags is | 81 // the file cannot be opened then an error code is returned. open_flags is |
78 // a bitfield of base::PlatformFileFlags | 82 // a bitfield of base::PlatformFileFlags |
79 // | 83 // |
80 // If the file stream is not closed manually, the underlying file will be | 84 // If the file stream is not closed manually, the underlying file will be |
81 // automatically closed when FileStream is destructed. | 85 // automatically closed when FileStream is destructed. |
82 virtual int OpenSync(const base::FilePath& path, int open_flags); | 86 virtual int OpenSync(const base::FilePath& path, int open_flags); |
83 | 87 |
| 88 #if defined(OS_ANDROID) |
| 89 // Similar to the above open() and OpenSync() call, except that the file |
| 90 // stream is specified by a content URI. |
| 91 virtual int OpenContentUrl(const GURL& content_url, int open_flags, |
| 92 const CompletionCallback& callback); |
| 93 // Similar to the above OpenSync() call, except that the file stream is |
| 94 // specified by a content URI. |
| 95 virtual int OpenContentUrlSync(const GURL& content_url, int open_flags); |
| 96 #endif |
| 97 |
84 // Returns ERR_IO_PENDING and closes the file asynchronously, calling | 98 // Returns ERR_IO_PENDING and closes the file asynchronously, calling |
85 // |callback| when done. | 99 // |callback| when done. |
86 // It is invalid to request any asynchronous operations while there is an | 100 // It is invalid to request any asynchronous operations while there is an |
87 // in-flight asynchronous operation. | 101 // in-flight asynchronous operation. |
88 virtual int Close(const CompletionCallback& callback); | 102 virtual int Close(const CompletionCallback& callback); |
89 | 103 |
90 // Closes the file immediately and returns OK. If the file is open | 104 // Closes the file immediately and returns OK. If the file is open |
91 // asynchronously, Close(const CompletionCallback&) should be used instead. | 105 // asynchronously, Close(const CompletionCallback&) should be used instead. |
92 virtual int CloseSync(); | 106 virtual int CloseSync(); |
93 | 107 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 // delaying FileStream's destructor. To perform all that separate object is | 270 // delaying FileStream's destructor. To perform all that separate object is |
257 // necessary. | 271 // necessary. |
258 scoped_ptr<Context> context_; | 272 scoped_ptr<Context> context_; |
259 | 273 |
260 DISALLOW_COPY_AND_ASSIGN(FileStream); | 274 DISALLOW_COPY_AND_ASSIGN(FileStream); |
261 }; | 275 }; |
262 | 276 |
263 } // namespace net | 277 } // namespace net |
264 | 278 |
265 #endif // NET_BASE_FILE_STREAM_H_ | 279 #endif // NET_BASE_FILE_STREAM_H_ |
OLD | NEW |