OLD | NEW |
---|---|
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/url_request/url_request.h" | 5 #include "net/url_request/url_request.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/metrics/stats_counters.h" | 9 #include "base/metrics/stats_counters.h" |
10 #include "base/singleton.h" | 10 #include "base/singleton.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 uint64 offset, | 153 uint64 offset, |
154 uint64 length, | 154 uint64 length, |
155 const base::Time& expected_modification_time) { | 155 const base::Time& expected_modification_time) { |
156 DCHECK(file_path.value().length() > 0 && length > 0); | 156 DCHECK(file_path.value().length() > 0 && length > 0); |
157 if (!upload_) | 157 if (!upload_) |
158 upload_ = new UploadData(); | 158 upload_ = new UploadData(); |
159 upload_->AppendFileRange(file_path, offset, length, | 159 upload_->AppendFileRange(file_path, offset, length, |
160 expected_modification_time); | 160 expected_modification_time); |
161 } | 161 } |
162 | 162 |
163 void URLRequest::EnableChunkedUpload() { | |
164 DCHECK(!upload_ || upload_->is_chunked()); | |
165 if (!upload_) { | |
166 upload_ = new UploadData(); | |
167 upload_->set_is_chunked(true); | |
168 } | |
169 } | |
170 | |
171 void URLRequest::AppendChunkToUpload(const char* bytes, int bytes_len) { | |
172 DCHECK(upload_); | |
173 DCHECK(upload_->is_chunked()); | |
174 DCHECK_GT(bytes_len, 0); | |
175 upload_->AppendChunk(bytes, bytes_len); | |
176 } | |
177 | |
178 void URLRequest::MarkEndOfChunks() { | |
179 DCHECK(upload_); | |
wtc
2011/01/20 00:29:47
Nit: also DCHECK upload_->is_chunked(), as you do
| |
180 upload_->AppendChunk(NULL, 0); | |
181 } | |
182 | |
163 void URLRequest::set_upload(net::UploadData* upload) { | 183 void URLRequest::set_upload(net::UploadData* upload) { |
164 upload_ = upload; | 184 upload_ = upload; |
165 } | 185 } |
166 | 186 |
167 // Get the upload data directly. | 187 // Get the upload data directly. |
168 net::UploadData* URLRequest::get_upload() { | 188 net::UploadData* URLRequest::get_upload() { |
169 return upload_.get(); | 189 return upload_.get(); |
170 } | 190 } |
171 | 191 |
172 bool URLRequest::has_upload() const { | 192 bool URLRequest::has_upload() const { |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
596 if (found != user_data_.end()) | 616 if (found != user_data_.end()) |
597 return found->second.get(); | 617 return found->second.get(); |
598 return NULL; | 618 return NULL; |
599 } | 619 } |
600 | 620 |
601 void URLRequest::SetUserData(const void* key, UserData* data) { | 621 void URLRequest::SetUserData(const void* key, UserData* data) { |
602 user_data_[key] = linked_ptr<UserData>(data); | 622 user_data_[key] = linked_ptr<UserData>(data); |
603 } | 623 } |
604 | 624 |
605 } // namespace net | 625 } // namespace net |
OLD | NEW |