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 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_vector.h" |
9 #include "net/base/net_export.h" | 10 #include "net/base/net_export.h" |
10 #include "net/base/upload_data.h" | 11 #include "net/base/upload_data.h" |
11 | 12 |
12 namespace net { | 13 namespace net { |
13 | 14 |
14 class FileStream; | |
15 class IOBuffer; | 15 class IOBuffer; |
| 16 class UploadElementReader; |
16 | 17 |
17 class NET_EXPORT UploadDataStream { | 18 class NET_EXPORT UploadDataStream { |
18 public: | 19 public: |
19 explicit UploadDataStream(UploadData* upload_data); | 20 explicit UploadDataStream(UploadData* upload_data); |
20 ~UploadDataStream(); | 21 ~UploadDataStream(); |
21 | 22 |
22 // Initializes the stream. This function must be called exactly once, | 23 // Initializes the stream. This function must be called exactly once, |
23 // before calling any other method. It is not valid to call any method | 24 // before calling any other method. It is not valid to call any method |
24 // (other than the destructor) if Init() returns a failure. | 25 // (other than the destructor) if Init() returns a failure. |
25 // | 26 // |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 friend class SpdyHttpStreamSpdy2Test; | 69 friend class SpdyHttpStreamSpdy2Test; |
69 friend class SpdyHttpStreamSpdy3Test; | 70 friend class SpdyHttpStreamSpdy3Test; |
70 friend class SpdyNetworkTransactionSpdy2Test; | 71 friend class SpdyNetworkTransactionSpdy2Test; |
71 friend class SpdyNetworkTransactionSpdy3Test; | 72 friend class SpdyNetworkTransactionSpdy3Test; |
72 | 73 |
73 // These methods are provided only to be used by unit tests. | 74 // These methods are provided only to be used by unit tests. |
74 static void ResetMergeChunks(); | 75 static void ResetMergeChunks(); |
75 static void set_merge_chunks(bool merge) { merge_chunks_ = merge; } | 76 static void set_merge_chunks(bool merge) { merge_chunks_ = merge; } |
76 | 77 |
77 scoped_refptr<UploadData> upload_data_; | 78 scoped_refptr<UploadData> upload_data_; |
| 79 ScopedVector<UploadElementReader> element_readers_; |
78 | 80 |
79 // Index of the current upload element (i.e. the element currently being | 81 // Index of the current upload element (i.e. the element currently being |
80 // read). The index is used as a cursor to iterate over elements in | 82 // read). The index is used as a cursor to iterate over elements in |
81 // |upload_data_|. | 83 // |upload_data_|. |
82 size_t element_index_; | 84 size_t element_index_; |
83 | 85 |
84 // Size and current read position within the upload data stream. | 86 // Size and current read position within the upload data stream. |
85 uint64 total_size_; | 87 uint64 total_size_; |
86 uint64 current_position_; | 88 uint64 current_position_; |
87 | 89 |
88 // True if the initialization was successful. | 90 // True if the initialization was successful. |
89 bool initialized_successfully_; | 91 bool initialized_successfully_; |
90 | 92 |
91 // TODO(satish): Remove this once we have a better way to unit test POST | 93 // TODO(satish): Remove this once we have a better way to unit test POST |
92 // requests with chunked uploads. | 94 // requests with chunked uploads. |
93 static bool merge_chunks_; | 95 static bool merge_chunks_; |
94 | 96 |
95 DISALLOW_COPY_AND_ASSIGN(UploadDataStream); | 97 DISALLOW_COPY_AND_ASSIGN(UploadDataStream); |
96 }; | 98 }; |
97 | 99 |
98 } // namespace net | 100 } // namespace net |
99 | 101 |
100 #endif // NET_BASE_UPLOAD_DATA_STREAM_H_ | 102 #endif // NET_BASE_UPLOAD_DATA_STREAM_H_ |
OLD | NEW |