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

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

Issue 1158923005: Use the exact-width integer types defined in <stdint.h> rather than (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tweak comments. Exclude mime_sniffer*. Rebase. Created 5 years, 6 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
OLDNEW
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 NET_BASE_UPLOAD_FILE_ELEMENT_READER_H_ 5 #ifndef NET_BASE_UPLOAD_FILE_ELEMENT_READER_H_
6 #define NET_BASE_UPLOAD_FILE_ELEMENT_READER_H_ 6 #define NET_BASE_UPLOAD_FILE_ELEMENT_READER_H_
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/files/file.h" 9 #include "base/files/file.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 11 matching lines...) Expand all
22 namespace net { 22 namespace net {
23 23
24 class FileStream; 24 class FileStream;
25 25
26 // An UploadElementReader implementation for file. 26 // An UploadElementReader implementation for file.
27 class NET_EXPORT UploadFileElementReader : public UploadElementReader { 27 class NET_EXPORT UploadFileElementReader : public UploadElementReader {
28 public: 28 public:
29 // |task_runner| is used to perform file operations. It must not be NULL. 29 // |task_runner| is used to perform file operations. It must not be NULL.
30 UploadFileElementReader(base::TaskRunner* task_runner, 30 UploadFileElementReader(base::TaskRunner* task_runner,
31 const base::FilePath& path, 31 const base::FilePath& path,
32 uint64 range_offset, 32 uint64_t range_offset,
33 uint64 range_length, 33 uint64_t range_length,
34 const base::Time& expected_modification_time); 34 const base::Time& expected_modification_time);
35 ~UploadFileElementReader() override; 35 ~UploadFileElementReader() override;
36 36
37 const base::FilePath& path() const { return path_; } 37 const base::FilePath& path() const { return path_; }
38 uint64 range_offset() const { return range_offset_; } 38 uint64_t range_offset() const { return range_offset_; }
39 uint64 range_length() const { return range_length_; } 39 uint64_t range_length() const { return range_length_; }
40 const base::Time& expected_modification_time() const { 40 const base::Time& expected_modification_time() const {
41 return expected_modification_time_; 41 return expected_modification_time_;
42 } 42 }
43 43
44 // UploadElementReader overrides: 44 // UploadElementReader overrides:
45 const UploadFileElementReader* AsFileReader() const override; 45 const UploadFileElementReader* AsFileReader() const override;
46 int Init(const CompletionCallback& callback) override; 46 int Init(const CompletionCallback& callback) override;
47 uint64 GetContentLength() const override; 47 uint64_t GetContentLength() const override;
48 uint64 BytesRemaining() const override; 48 uint64_t BytesRemaining() const override;
49 int Read(IOBuffer* buf, 49 int Read(IOBuffer* buf,
50 int buf_length, 50 int buf_length,
51 const CompletionCallback& callback) override; 51 const CompletionCallback& callback) override;
52 52
53 private: 53 private:
54 FRIEND_TEST_ALL_PREFIXES(ElementsUploadDataStreamTest, FileSmallerThanLength); 54 FRIEND_TEST_ALL_PREFIXES(ElementsUploadDataStreamTest, FileSmallerThanLength);
55 FRIEND_TEST_ALL_PREFIXES(HttpNetworkTransactionTest, 55 FRIEND_TEST_ALL_PREFIXES(HttpNetworkTransactionTest,
56 UploadFileSmallerThanLength); 56 UploadFileSmallerThanLength);
57 57
58 // Resets this instance to the uninitialized state. 58 // Resets this instance to the uninitialized state.
59 void Reset(); 59 void Reset();
60 60
61 // These methods are used to implement Init(). 61 // These methods are used to implement Init().
62 void OnOpenCompleted(const CompletionCallback& callback, int result); 62 void OnOpenCompleted(const CompletionCallback& callback, int result);
63 void OnSeekCompleted(const CompletionCallback& callback, int64 result); 63 void OnSeekCompleted(const CompletionCallback& callback, int64_t result);
64 void OnGetFileInfoCompleted(const CompletionCallback& callback, 64 void OnGetFileInfoCompleted(const CompletionCallback& callback,
65 base::File::Info* file_info, 65 base::File::Info* file_info,
66 bool result); 66 bool result);
67 67
68 // This method is used to implement Read(). 68 // This method is used to implement Read().
69 int OnReadCompleted(const CompletionCallback& callback, int result); 69 int OnReadCompleted(const CompletionCallback& callback, int result);
70 70
71 // Sets an value to override the result for GetContentLength(). 71 // Sets an value to override the result for GetContentLength().
72 // Used for tests. 72 // Used for tests.
73 struct NET_EXPORT_PRIVATE ScopedOverridingContentLengthForTests { 73 struct NET_EXPORT_PRIVATE ScopedOverridingContentLengthForTests {
74 explicit ScopedOverridingContentLengthForTests(uint64 value); 74 explicit ScopedOverridingContentLengthForTests(uint64_t value);
75 ~ScopedOverridingContentLengthForTests(); 75 ~ScopedOverridingContentLengthForTests();
76 }; 76 };
77 77
78 scoped_refptr<base::TaskRunner> task_runner_; 78 scoped_refptr<base::TaskRunner> task_runner_;
79 const base::FilePath path_; 79 const base::FilePath path_;
80 const uint64 range_offset_; 80 const uint64_t range_offset_;
81 const uint64 range_length_; 81 const uint64_t range_length_;
82 const base::Time expected_modification_time_; 82 const base::Time expected_modification_time_;
83 scoped_ptr<FileStream> file_stream_; 83 scoped_ptr<FileStream> file_stream_;
84 uint64 content_length_; 84 uint64_t content_length_;
85 uint64 bytes_remaining_; 85 uint64_t bytes_remaining_;
86 base::WeakPtrFactory<UploadFileElementReader> weak_ptr_factory_; 86 base::WeakPtrFactory<UploadFileElementReader> weak_ptr_factory_;
87 87
88 DISALLOW_COPY_AND_ASSIGN(UploadFileElementReader); 88 DISALLOW_COPY_AND_ASSIGN(UploadFileElementReader);
89 }; 89 };
90 90
91 } // namespace net 91 } // namespace net
92 92
93 #endif // NET_BASE_UPLOAD_FILE_ELEMENT_READER_H_ 93 #endif // NET_BASE_UPLOAD_FILE_ELEMENT_READER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698