summaryrefslogtreecommitdiffstats
path: root/net/base/upload_file_element_reader.h
diff options
context:
space:
mode:
Diffstat (limited to 'net/base/upload_file_element_reader.h')
-rw-r--r--net/base/upload_file_element_reader.h33
1 files changed, 31 insertions, 2 deletions
diff --git a/net/base/upload_file_element_reader.h b/net/base/upload_file_element_reader.h
index b5c4004..f85d45f 100644
--- a/net/base/upload_file_element_reader.h
+++ b/net/base/upload_file_element_reader.h
@@ -45,13 +45,11 @@ class NET_EXPORT UploadFileElementReader : public UploadElementReader {
// UploadElementReader overrides:
virtual const UploadFileElementReader* AsFileReader() const OVERRIDE;
virtual int Init(const CompletionCallback& callback) OVERRIDE;
- virtual int InitSync() OVERRIDE;
virtual uint64 GetContentLength() const OVERRIDE;
virtual uint64 BytesRemaining() const OVERRIDE;
virtual int Read(IOBuffer* buf,
int buf_length,
const CompletionCallback& callback) OVERRIDE;
- virtual int ReadSync(IOBuffer* buf, int buf_length) OVERRIDE;
private:
FRIEND_TEST_ALL_PREFIXES(UploadDataStreamTest, FileSmallerThanLength);
@@ -95,6 +93,37 @@ class NET_EXPORT UploadFileElementReader : public UploadElementReader {
DISALLOW_COPY_AND_ASSIGN(UploadFileElementReader);
};
+// An UploadElementReader implementation for file which performs file operation
+// synchronously.
+// Use this class only if the thread is IO allowed.
+class NET_EXPORT UploadFileElementReaderSync : public UploadElementReader {
+ public:
+ UploadFileElementReaderSync(const FilePath& path,
+ uint64 range_offset,
+ uint64 range_length,
+ const base::Time& expected_modification_time);
+ virtual ~UploadFileElementReaderSync();
+
+ // UploadElementReader overrides:
+ virtual int Init(const CompletionCallback& callback) OVERRIDE;
+ virtual uint64 GetContentLength() const OVERRIDE;
+ virtual uint64 BytesRemaining() const OVERRIDE;
+ virtual int Read(IOBuffer* buf,
+ int buf_length,
+ const CompletionCallback& callback) OVERRIDE;
+
+ private:
+ const FilePath path_;
+ const uint64 range_offset_;
+ const uint64 range_length_;
+ const base::Time expected_modification_time_;
+ scoped_ptr<FileStream> file_stream_;
+ uint64 content_length_;
+ uint64 bytes_remaining_;
+
+ DISALLOW_COPY_AND_ASSIGN(UploadFileElementReaderSync);
+};
+
} // namespace net
#endif // NET_BASE_UPLOAD_FILE_ELEMENT_READER_H_