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_); |
| 180 DCHECK(upload_->is_chunked()); |
| 181 upload_->AppendChunk(NULL, 0); |
| 182 } |
| 183 |
163 void URLRequest::set_upload(net::UploadData* upload) { | 184 void URLRequest::set_upload(net::UploadData* upload) { |
164 upload_ = upload; | 185 upload_ = upload; |
165 } | 186 } |
166 | 187 |
167 // Get the upload data directly. | 188 // Get the upload data directly. |
168 net::UploadData* URLRequest::get_upload() { | 189 net::UploadData* URLRequest::get_upload() { |
169 return upload_.get(); | 190 return upload_.get(); |
170 } | 191 } |
171 | 192 |
172 bool URLRequest::has_upload() const { | 193 bool URLRequest::has_upload() const { |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 if (found != user_data_.end()) | 616 if (found != user_data_.end()) |
596 return found->second.get(); | 617 return found->second.get(); |
597 return NULL; | 618 return NULL; |
598 } | 619 } |
599 | 620 |
600 void URLRequest::SetUserData(const void* key, UserData* data) { | 621 void URLRequest::SetUserData(const void* key, UserData* data) { |
601 user_data_[key] = linked_ptr<UserData>(data); | 622 user_data_[key] = linked_ptr<UserData>(data); |
602 } | 623 } |
603 | 624 |
604 } // namespace net | 625 } // namespace net |
OLD | NEW |