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/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "net/base/net_export.h" | 10 #include "net/base/net_export.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 bool is_chunked() const { return upload_data_->is_chunked(); } | 59 bool is_chunked() const { return upload_data_->is_chunked(); } |
60 | 60 |
61 // Returns true if all data has been consumed from this upload data | 61 // Returns true if all data has been consumed from this upload data |
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 private: |
| 69 friend class SpdyHttpStreamSpdy2Test; |
| 70 friend class SpdyHttpStreamSpdy3Test; |
| 71 friend class SpdyNetworkTransactionSpdy2Test; |
| 72 friend class SpdyNetworkTransactionSpdy3Test; |
| 73 |
| 74 // These methods are provided only to be used by unit tests. |
| 75 static void ResetMergeChunks(); |
69 static void set_merge_chunks(bool merge) { merge_chunks_ = merge; } | 76 static void set_merge_chunks(bool merge) { merge_chunks_ = merge; } |
70 | 77 |
71 private: | |
72 scoped_refptr<UploadData> upload_data_; | 78 scoped_refptr<UploadData> upload_data_; |
73 | 79 |
74 // Index of the current upload element (i.e. the element currently being | 80 // Index of the current upload element (i.e. the element currently being |
75 // read). The index is used as a cursor to iterate over elements in | 81 // read). The index is used as a cursor to iterate over elements in |
76 // |upload_data_|. | 82 // |upload_data_|. |
77 size_t element_index_; | 83 size_t element_index_; |
78 | 84 |
79 // Size and current read position within the upload data stream. | 85 // Size and current read position within the upload data stream. |
80 uint64 total_size_; | 86 uint64 total_size_; |
81 uint64 current_position_; | 87 uint64 current_position_; |
82 | 88 |
83 // True if the initialization was successful. | 89 // True if the initialization was successful. |
84 bool initialized_successfully_; | 90 bool initialized_successfully_; |
85 | 91 |
86 // TODO(satish): Remove this once we have a better way to unit test POST | 92 // TODO(satish): Remove this once we have a better way to unit test POST |
87 // requests with chunked uploads. | 93 // requests with chunked uploads. |
88 static bool merge_chunks_; | 94 static bool merge_chunks_; |
89 | 95 |
90 DISALLOW_COPY_AND_ASSIGN(UploadDataStream); | 96 DISALLOW_COPY_AND_ASSIGN(UploadDataStream); |
91 }; | 97 }; |
92 | 98 |
93 } // namespace net | 99 } // namespace net |
94 | 100 |
95 #endif // NET_BASE_UPLOAD_DATA_STREAM_H_ | 101 #endif // NET_BASE_UPLOAD_DATA_STREAM_H_ |
OLD | NEW |