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 NET_BASE_UPLOAD_DATA_STREAM_H_ | 5 #ifndef NET_BASE_UPLOAD_DATA_STREAM_H_ |
6 #define NET_BASE_UPLOAD_DATA_STREAM_H_ | 6 #define NET_BASE_UPLOAD_DATA_STREAM_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "net/base/net_export.h" | 10 #include "net/base/net_export.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 // stream. | 62 // stream. |
63 bool IsEOF() const; | 63 bool IsEOF() const; |
64 | 64 |
65 // Returns true if the upload data in the stream is entirely in memory. | 65 // Returns true if the upload data in the stream is entirely in memory. |
66 bool IsInMemory() const; | 66 bool IsInMemory() const; |
67 | 67 |
68 // This method is provided only to be used by unit tests. | 68 // This method is provided only to be used by unit tests. |
69 static void set_merge_chunks(bool merge) { merge_chunks_ = merge; } | 69 static void set_merge_chunks(bool merge) { merge_chunks_ = merge; } |
70 | 70 |
71 private: | 71 private: |
72 // Advances to the next element. Updates the internal states. | |
73 void AdvanceToNextElement(); | |
74 | |
75 scoped_refptr<UploadData> upload_data_; | 72 scoped_refptr<UploadData> upload_data_; |
76 | 73 |
77 // Index of the current upload element (i.e. the element currently being | 74 // Index of the current upload element (i.e. the element currently being |
78 // read). The index is used as a cursor to iterate over elements in | 75 // read). The index is used as a cursor to iterate over elements in |
79 // |upload_data_|. | 76 // |upload_data_|. |
80 size_t element_index_; | 77 size_t element_index_; |
81 | 78 |
82 // The byte offset into the current element's data buffer if the current | |
83 // element is a TYPE_BYTES or TYPE_DATA element. | |
84 size_t element_offset_; | |
85 | |
86 // A stream to the currently open file, for the current element if the | |
87 // current element is a TYPE_FILE element. | |
88 scoped_ptr<FileStream> element_file_stream_; | |
89 | |
90 // The number of bytes remaining to be read from the currently open file | |
91 // if the current element is of TYPE_FILE. | |
92 uint64 element_file_bytes_remaining_; | |
93 | |
94 // Size and current read position within the upload data stream. | 79 // Size and current read position within the upload data stream. |
95 uint64 total_size_; | 80 uint64 total_size_; |
96 uint64 current_position_; | 81 uint64 current_position_; |
97 | 82 |
98 // True if the initialization was successful. | 83 // True if the initialization was successful. |
99 bool initialized_successfully_; | 84 bool initialized_successfully_; |
100 | 85 |
101 // TODO(satish): Remove this once we have a better way to unit test POST | 86 // TODO(satish): Remove this once we have a better way to unit test POST |
102 // requests with chunked uploads. | 87 // requests with chunked uploads. |
103 static bool merge_chunks_; | 88 static bool merge_chunks_; |
104 | 89 |
105 DISALLOW_COPY_AND_ASSIGN(UploadDataStream); | 90 DISALLOW_COPY_AND_ASSIGN(UploadDataStream); |
106 }; | 91 }; |
107 | 92 |
108 } // namespace net | 93 } // namespace net |
109 | 94 |
110 #endif // NET_BASE_UPLOAD_DATA_STREAM_H_ | 95 #endif // NET_BASE_UPLOAD_DATA_STREAM_H_ |
OLD | NEW |