Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(331)

Side by Side Diff: net/base/upload_file_element_reader.h

Issue 10868064: net: Move data reading functionalities from UploadElement to UploadElementReader (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/base/upload_element_reader.cc ('k') | net/base/upload_file_element_reader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 // Sets an value to override the result for GetContentLength().
36 // Used for tests.
37 struct NET_EXPORT ScopedOverridingContentLengthForTests {
38 ScopedOverridingContentLengthForTests(uint64 value);
39 ~ScopedOverridingContentLengthForTests();
40 };
41
42 FilePath path_;
43 uint64 range_offset_;
44 uint64 range_length_;
45 base::Time expected_modification_time_;
46 scoped_ptr<FileStream> file_stream_;
47 uint64 content_length_;
48 uint64 bytes_remaining_;
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_
OLDNEW
« no previous file with comments | « net/base/upload_element_reader.cc ('k') | net/base/upload_file_element_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698