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 #include "net/base/upload_data_stream.h" | 5 #include "net/base/upload_data_stream.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "net/base/io_buffer.h" | 8 #include "net/base/io_buffer.h" |
9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
10 #include "net/base/upload_bytes_element_reader.h" | 10 #include "net/base/upload_bytes_element_reader.h" |
11 #include "net/base/upload_element_reader.h" | 11 #include "net/base/upload_element_reader.h" |
12 | 12 |
13 namespace net { | 13 namespace net { |
14 | 14 |
15 namespace { | |
16 | |
17 // A subclass of UplodBytesElementReader which owns the data given as a vector. | |
18 class UploadOwnedBytesElementReader : public UploadBytesElementReader { | |
19 public: | |
20 UploadOwnedBytesElementReader(std::vector<char>* data) | |
21 : UploadBytesElementReader(&(*data)[0], data->size()) { | |
22 data_.swap(*data); | |
23 } | |
24 | |
25 virtual ~UploadOwnedBytesElementReader() {} | |
26 | |
27 private: | |
28 std::vector<char> data_; | |
29 }; | |
30 | |
31 } // namespace | |
32 | |
33 bool UploadDataStream::merge_chunks_ = true; | 15 bool UploadDataStream::merge_chunks_ = true; |
34 | 16 |
35 // static | 17 // static |
36 void UploadDataStream::ResetMergeChunks() { | 18 void UploadDataStream::ResetMergeChunks() { |
37 // WARNING: merge_chunks_ must match the above initializer. | 19 // WARNING: merge_chunks_ must match the above initializer. |
38 merge_chunks_ = true; | 20 merge_chunks_ = true; |
39 } | 21 } |
40 | 22 |
41 UploadDataStream::UploadDataStream( | 23 UploadDataStream::UploadDataStream( |
42 ScopedVector<UploadElementReader>* element_readers, | 24 ScopedVector<UploadElementReader>* element_readers, |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 // Add the last result. | 263 // Add the last result. |
282 buf->DidConsume(previous_result); | 264 buf->DidConsume(previous_result); |
283 | 265 |
284 DCHECK(!callback.is_null()); | 266 DCHECK(!callback.is_null()); |
285 const int result = ReadInternal(buf, callback); | 267 const int result = ReadInternal(buf, callback); |
286 if (result != ERR_IO_PENDING) | 268 if (result != ERR_IO_PENDING) |
287 callback.Run(result); | 269 callback.Run(result); |
288 } | 270 } |
289 | 271 |
290 } // namespace net | 272 } // namespace net |
OLD | NEW |