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

Side by Side Diff: net/base/upload_data.cc

Issue 6292013: Add chunked uploads support to SPDY (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | net/base/upload_data_stream.h » ('j') | net/base/upload_data_stream.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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.h" 5 #include "net/base/upload_data.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "net/base/file_stream.h" 10 #include "net/base/file_stream.h"
(...skipping 11 matching lines...) Expand all
22 content_length_(-1), 22 content_length_(-1),
23 file_stream_(NULL) { 23 file_stream_(NULL) {
24 } 24 }
25 25
26 UploadData::Element::~Element() { 26 UploadData::Element::~Element() {
27 // In the common case |file__stream_| will be null. 27 // In the common case |file__stream_| will be null.
28 delete file_stream_; 28 delete file_stream_;
29 } 29 }
30 30
31 void UploadData::Element::SetToChunk(const char* bytes, int bytes_len) { 31 void UploadData::Element::SetToChunk(const char* bytes, int bytes_len) {
32 std::string chunk_length = StringPrintf("%X\r\n", bytes_len);
33 bytes_.clear(); 32 bytes_.clear();
34 bytes_.insert(bytes_.end(), chunk_length.data(),
35 chunk_length.data() + chunk_length.length());
36 bytes_.insert(bytes_.end(), bytes, bytes + bytes_len); 33 bytes_.insert(bytes_.end(), bytes, bytes + bytes_len);
37 const char* crlf = "\r\n";
38 bytes_.insert(bytes_.end(), crlf, crlf + 2);
39 type_ = TYPE_CHUNK; 34 type_ = TYPE_CHUNK;
40 is_last_chunk_ = (bytes_len == 0); 35 is_last_chunk_ = (bytes_len == 0);
41 } 36 }
42 37
43 uint64 UploadData::Element::GetContentLength() { 38 uint64 UploadData::Element::GetContentLength() {
44 if (override_content_length_ || content_length_computed_) 39 if (override_content_length_ || content_length_computed_)
45 return content_length_; 40 return content_length_;
46 41
47 if (type_ == TYPE_BYTES || type_ == TYPE_CHUNK) 42 if (type_ == TYPE_BYTES || type_ == TYPE_CHUNK)
48 return static_cast<uint64>(bytes_.size()); 43 return static_cast<uint64>(bytes_.size());
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 } 162 }
168 163
169 void UploadData::SetElements(const std::vector<Element>& elements) { 164 void UploadData::SetElements(const std::vector<Element>& elements) {
170 elements_ = elements; 165 elements_ = elements;
171 } 166 }
172 167
173 UploadData::~UploadData() { 168 UploadData::~UploadData() {
174 } 169 }
175 170
176 } // namespace net 171 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/base/upload_data_stream.h » ('j') | net/base/upload_data_stream.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698