| 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 #ifndef WEBKIT_BLOB_FILE_STREAM_READER_H_ | 5 #ifndef WEBKIT_BLOB_FILE_STREAM_READER_H_ |
| 6 #define WEBKIT_BLOB_FILE_STREAM_READER_H_ | 6 #define WEBKIT_BLOB_FILE_STREAM_READER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
| 11 #include "net/base/completion_callback.h" | 11 #include "net/base/completion_callback.h" |
| 12 #include "webkit/browser/webkit_storage_browser_export.h" | 12 #include "webkit/browser/storage_export.h" |
| 13 | 13 |
| 14 namespace base { | 14 namespace base { |
| 15 class FilePath; | 15 class FilePath; |
| 16 class TaskRunner; | 16 class TaskRunner; |
| 17 class Time; | 17 class Time; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace net { | 20 namespace net { |
| 21 class IOBuffer; | 21 class IOBuffer; |
| 22 } | 22 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 33 public: | 33 public: |
| 34 // Creates a new FileReader for a local file |file_path|. | 34 // Creates a new FileReader for a local file |file_path|. |
| 35 // |initial_offset| specifies the offset in the file where the first read | 35 // |initial_offset| specifies the offset in the file where the first read |
| 36 // should start. If the given offset is out of the file range any | 36 // should start. If the given offset is out of the file range any |
| 37 // read operation may error out with net::ERR_REQUEST_RANGE_NOT_SATISFIABLE. | 37 // read operation may error out with net::ERR_REQUEST_RANGE_NOT_SATISFIABLE. |
| 38 // |expected_modification_time| specifies the expected last modification | 38 // |expected_modification_time| specifies the expected last modification |
| 39 // If the value is non-null, the reader will check the underlying file's | 39 // If the value is non-null, the reader will check the underlying file's |
| 40 // actual modification time to see if the file has been modified, and if | 40 // actual modification time to see if the file has been modified, and if |
| 41 // it does any succeeding read operations should fail with | 41 // it does any succeeding read operations should fail with |
| 42 // ERR_UPLOAD_FILE_CHANGED error. | 42 // ERR_UPLOAD_FILE_CHANGED error. |
| 43 WEBKIT_STORAGE_BROWSER_EXPORT static FileStreamReader* | 43 STORAGE_EXPORT static FileStreamReader* |
| 44 CreateForLocalFile(base::TaskRunner* task_runner, | 44 CreateForLocalFile(base::TaskRunner* task_runner, |
| 45 const base::FilePath& file_path, | 45 const base::FilePath& file_path, |
| 46 int64 initial_offset, | 46 int64 initial_offset, |
| 47 const base::Time& expected_modification_time); | 47 const base::Time& expected_modification_time); |
| 48 | 48 |
| 49 // Creates a new reader for a filesystem URL |url| form |initial_offset|. | 49 // Creates a new reader for a filesystem URL |url| form |initial_offset|. |
| 50 // |expected_modification_time| specifies the expected last modification if | 50 // |expected_modification_time| specifies the expected last modification if |
| 51 // the value is non-null, the reader will check the underlying file's actual | 51 // the value is non-null, the reader will check the underlying file's actual |
| 52 // modification time to see if the file has been modified, and if it does any | 52 // modification time to see if the file has been modified, and if it does any |
| 53 // succeeding read operations should fail with ERR_UPLOAD_FILE_CHANGED error. | 53 // succeeding read operations should fail with ERR_UPLOAD_FILE_CHANGED error. |
| 54 WEBKIT_STORAGE_BROWSER_EXPORT static FileStreamReader* | 54 STORAGE_EXPORT static FileStreamReader* |
| 55 CreateForFileSystemFile(storage::FileSystemContext* context, | 55 CreateForFileSystemFile(storage::FileSystemContext* context, |
| 56 const storage::FileSystemURL& url, | 56 const storage::FileSystemURL& url, |
| 57 int64 initial_offset, | 57 int64 initial_offset, |
| 58 const base::Time& expected_modification_time); | 58 const base::Time& expected_modification_time); |
| 59 | 59 |
| 60 // Verify if the underlying file has not been modified. | 60 // Verify if the underlying file has not been modified. |
| 61 WEBKIT_STORAGE_BROWSER_EXPORT static bool VerifySnapshotTime( | 61 STORAGE_EXPORT static bool VerifySnapshotTime( |
| 62 const base::Time& expected_modification_time, | 62 const base::Time& expected_modification_time, |
| 63 const base::File::Info& file_info); | 63 const base::File::Info& file_info); |
| 64 | 64 |
| 65 // It is valid to delete the reader at any time. If the stream is deleted | 65 // It is valid to delete the reader at any time. If the stream is deleted |
| 66 // while it has a pending read, its callback will not be called. | 66 // while it has a pending read, its callback will not be called. |
| 67 virtual ~FileStreamReader() {} | 67 virtual ~FileStreamReader() {} |
| 68 | 68 |
| 69 // Reads from the current cursor position asynchronously. | 69 // Reads from the current cursor position asynchronously. |
| 70 // | 70 // |
| 71 // Up to buf_len bytes will be copied into buf. (In other words, partial | 71 // Up to buf_len bytes will be copied into buf. (In other words, partial |
| (...skipping 18 matching lines...) Expand all Loading... |
| 90 // |callback| will not be called. | 90 // |callback| will not be called. |
| 91 // Note that the return type is int64 to return a larger file's size (a file | 91 // Note that the return type is int64 to return a larger file's size (a file |
| 92 // larger than 2G) but an error code should fit in the int range (may be | 92 // larger than 2G) but an error code should fit in the int range (may be |
| 93 // smaller than int64 range). | 93 // smaller than int64 range). |
| 94 virtual int64 GetLength(const net::Int64CompletionCallback& callback) = 0; | 94 virtual int64 GetLength(const net::Int64CompletionCallback& callback) = 0; |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 } // namespace storage | 97 } // namespace storage |
| 98 | 98 |
| 99 #endif // WEBKIT_BLOB_FILE_STREAM_READER_H_ | 99 #endif // WEBKIT_BLOB_FILE_STREAM_READER_H_ |
| OLD | NEW |