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

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.cc » ('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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 if (file_range_offset_ >= static_cast<uint64>(length)) 62 if (file_range_offset_ >= static_cast<uint64>(length))
63 return 0; // range is beyond eof 63 return 0; // range is beyond eof
64 64
65 // compensate for the offset and clip file_range_length_ to eof 65 // compensate for the offset and clip file_range_length_ to eof
66 content_length_ = std::min(length - file_range_offset_, file_range_length_); 66 content_length_ = std::min(length - file_range_offset_, file_range_length_);
67 return content_length_; 67 return content_length_;
68 } 68 }
69 69
70 void UploadData::Element::SetToChunk(const char* bytes, int bytes_len) { 70 void UploadData::Element::SetToChunk(const char* bytes, int bytes_len) {
71 std::string chunk_length = StringPrintf("%X\r\n", bytes_len);
72 bytes_.clear(); 71 bytes_.clear();
73 bytes_.insert(bytes_.end(), chunk_length.data(),
74 chunk_length.data() + chunk_length.length());
75 bytes_.insert(bytes_.end(), bytes, bytes + bytes_len); 72 bytes_.insert(bytes_.end(), bytes, bytes + bytes_len);
76 const char* crlf = "\r\n";
77 bytes_.insert(bytes_.end(), crlf, crlf + 2);
78 type_ = TYPE_CHUNK; 73 type_ = TYPE_CHUNK;
79 is_last_chunk_ = (bytes_len == 0); 74 is_last_chunk_ = (bytes_len == 0);
80 } 75 }
81 76
82 FileStream* UploadData::Element::NewFileStreamForReading() { 77 FileStream* UploadData::Element::NewFileStreamForReading() {
83 // In common usage GetContentLength() will call this first and store the 78 // In common usage GetContentLength() will call this first and store the
84 // result into |file_| and a subsequent call (from UploadDataStream) will 79 // result into |file_| and a subsequent call (from UploadDataStream) will
85 // get the cached open FileStream. 80 // get the cached open FileStream.
86 if (file_stream_) { 81 if (file_stream_) {
87 FileStream* file = file_stream_; 82 FileStream* file = file_stream_;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 } 163 }
169 164
170 void UploadData::SetElements(const std::vector<Element>& elements) { 165 void UploadData::SetElements(const std::vector<Element>& elements) {
171 elements_ = elements; 166 elements_ = elements;
172 } 167 }
173 168
174 UploadData::~UploadData() { 169 UploadData::~UploadData() {
175 } 170 }
176 171
177 } // namespace net 172 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/base/upload_data_stream.h » ('j') | net/base/upload_data_stream.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698