OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "webkit/glue/multipart_response_delegate.h" | 5 #include "webkit/glue/multipart_response_delegate.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "net/base/net_util.h" | 10 #include "net/base/net_util.h" |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 content_type.substr(boundary_start_offset, boundary_length); | 318 content_type.substr(boundary_start_offset, boundary_length); |
319 // The byte range response can have quoted boundary strings. This is legal | 319 // The byte range response can have quoted boundary strings. This is legal |
320 // as per MIME specifications. Individual data fragements however don't | 320 // as per MIME specifications. Individual data fragements however don't |
321 // contain quoted boundary strings. | 321 // contain quoted boundary strings. |
322 TrimString(*multipart_boundary, "\"", multipart_boundary); | 322 TrimString(*multipart_boundary, "\"", multipart_boundary); |
323 return true; | 323 return true; |
324 } | 324 } |
325 | 325 |
326 bool MultipartResponseDelegate::ReadContentRanges( | 326 bool MultipartResponseDelegate::ReadContentRanges( |
327 const WebURLResponse& response, | 327 const WebURLResponse& response, |
328 int* content_range_lower_bound, | 328 int64* content_range_lower_bound, |
329 int* content_range_upper_bound, | 329 int64* content_range_upper_bound, |
330 int* content_range_instance_size) { | 330 int64* content_range_instance_size) { |
331 | 331 |
332 std::string content_range = response.httpHeaderField("Content-Range").utf8(); | 332 std::string content_range = response.httpHeaderField("Content-Range").utf8(); |
333 if (content_range.empty()) { | 333 if (content_range.empty()) { |
334 content_range = response.httpHeaderField("Range").utf8(); | 334 content_range = response.httpHeaderField("Range").utf8(); |
335 } | 335 } |
336 | 336 |
337 if (content_range.empty()) { | 337 if (content_range.empty()) { |
338 DLOG(WARNING) << "Failed to read content range from response."; | 338 DLOG(WARNING) << "Failed to read content range from response."; |
339 return false; | 339 return false; |
340 } | 340 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 size_t byte_range_instance_size_end_offset = | 383 size_t byte_range_instance_size_end_offset = |
384 content_range.length(); | 384 content_range.length(); |
385 | 385 |
386 size_t byte_range_instance_size_characters = | 386 size_t byte_range_instance_size_characters = |
387 byte_range_instance_size_end_offset - | 387 byte_range_instance_size_end_offset - |
388 byte_range_instance_size_start_offset; | 388 byte_range_instance_size_start_offset; |
389 std::string byte_range_instance_size = | 389 std::string byte_range_instance_size = |
390 content_range.substr(byte_range_instance_size_start_offset, | 390 content_range.substr(byte_range_instance_size_start_offset, |
391 byte_range_instance_size_characters); | 391 byte_range_instance_size_characters); |
392 | 392 |
393 if (!base::StringToInt(byte_range_lower_bound, content_range_lower_bound)) | 393 if (!base::StringToInt64(byte_range_lower_bound, content_range_lower_bound)) |
394 return false; | 394 return false; |
395 if (!base::StringToInt(byte_range_upper_bound, content_range_upper_bound)) | 395 if (!base::StringToInt64(byte_range_upper_bound, content_range_upper_bound)) |
396 return false; | 396 return false; |
397 if (!base::StringToInt(byte_range_instance_size, content_range_instance_size)) | 397 if (!base::StringToInt64(byte_range_instance_size, |
| 398 content_range_instance_size)) { |
398 return false; | 399 return false; |
| 400 } |
399 return true; | 401 return true; |
400 } | 402 } |
401 | 403 |
402 } // namespace webkit_glue | 404 } // namespace webkit_glue |
OLD | NEW |