Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef NET_BASE_UPLOAD_FILE_ELEMENT_READER_H_ | |
| 6 #define NET_BASE_UPLOAD_FILE_ELEMENT_READER_H_ | |
| 7 | |
| 8 #include "base/compiler_specific.h" | |
| 9 #include "base/file_path.h" | |
| 10 #include "base/gtest_prod_util.h" | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "base/time.h" | |
| 13 #include "net/base/upload_element_reader.h" | |
| 14 | |
| 15 namespace net { | |
| 16 | |
| 17 class FileStream; | |
| 18 | |
| 19 // An UploadElementReader implementation for file. | |
| 20 class NET_EXPORT_PRIVATE UploadFileElementReader : public UploadElementReader { | |
| 21 public: | |
| 22 UploadFileElementReader(const FilePath& path, | |
| 23 uint64 range_offset, | |
| 24 uint64 range_length, | |
| 25 const base::Time& expected_modification_time); | |
| 26 virtual ~UploadFileElementReader(); | |
| 27 | |
| 28 // UploadElementReader overrides: | |
| 29 virtual int InitSync() OVERRIDE; | |
| 30 virtual uint64 GetContentLength() const OVERRIDE; | |
| 31 virtual uint64 BytesRemaining() const OVERRIDE; | |
| 32 virtual int ReadSync(char* buf, int buf_length) OVERRIDE; | |
| 33 | |
| 34 private: | |
| 35 FilePath path_; | |
| 36 uint64 range_offset_; | |
| 37 uint64 range_length_; | |
| 38 base::Time expected_modification_time_; | |
| 39 scoped_ptr<FileStream> file_stream_; | |
| 40 uint64 content_length_; | |
| 41 uint64 bytes_remaining_; | |
| 42 | |
| 43 // Sets an value to override the result for GetContentLength(). | |
| 44 // Used for tests. | |
| 45 struct NET_EXPORT ScopedOverridingContentLengthForTests { | |
|
willchan no longer on Chromium
2012/09/06 01:06:01
Types need to be declared at the beginning of the
hashimoto
2012/09/06 01:55:39
Done.
| |
| 46 ScopedOverridingContentLengthForTests(uint64 value); | |
| 47 ~ScopedOverridingContentLengthForTests(); | |
| 48 }; | |
| 49 | |
| 50 FRIEND_TEST_ALL_PREFIXES(UploadDataStreamTest, FileSmallerThanLength); | |
| 51 FRIEND_TEST_ALL_PREFIXES(HttpNetworkTransactionTest, | |
| 52 UploadFileSmallerThanLength); | |
| 53 FRIEND_TEST_ALL_PREFIXES(HttpNetworkTransactionSpdy2Test, | |
| 54 UploadFileSmallerThanLength); | |
| 55 FRIEND_TEST_ALL_PREFIXES(HttpNetworkTransactionSpdy3Test, | |
| 56 UploadFileSmallerThanLength); | |
| 57 | |
| 58 DISALLOW_COPY_AND_ASSIGN(UploadFileElementReader); | |
| 59 }; | |
| 60 | |
| 61 } // namespace net | |
| 62 | |
| 63 #endif // NET_BASE_UPLOAD_FILE_ELEMENT_READER_H_ | |
| OLD | NEW |