OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/blob/blob_url_request_job.h" | 5 #include "webkit/browser/blob/blob_url_request_job.h" |
6 | 6 |
7 #include <algorithm> | |
7 #include <limits> | 8 #include <limits> |
9 #include <string> | |
10 #include <vector> | |
hashimoto
2014/09/05 03:17:27
nit: Are these include needed?
mtomasz
2014/09/05 05:31:42
algorithm for std::min.
string for std::string.
ve
| |
8 | 11 |
9 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
10 #include "base/bind.h" | 13 #include "base/bind.h" |
11 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
12 #include "base/files/file_util_proxy.h" | 15 #include "base/files/file_util_proxy.h" |
13 #include "base/format_macros.h" | 16 #include "base/format_macros.h" |
14 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
15 #include "base/message_loop/message_loop_proxy.h" | 18 #include "base/message_loop/message_loop_proxy.h" |
19 #include "base/numerics/safe_conversions.h" | |
16 #include "base/stl_util.h" | 20 #include "base/stl_util.h" |
17 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
18 #include "base/strings/stringprintf.h" | 22 #include "base/strings/stringprintf.h" |
19 #include "net/base/io_buffer.h" | 23 #include "net/base/io_buffer.h" |
20 #include "net/base/net_errors.h" | 24 #include "net/base/net_errors.h" |
21 #include "net/http/http_request_headers.h" | 25 #include "net/http/http_request_headers.h" |
22 #include "net/http/http_response_headers.h" | 26 #include "net/http/http_response_headers.h" |
23 #include "net/http/http_response_info.h" | 27 #include "net/http/http_response_info.h" |
24 #include "net/http/http_util.h" | 28 #include "net/http/http_util.h" |
25 #include "net/url_request/url_request.h" | 29 #include "net/url_request/url_request.h" |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
216 NotifyFailure(error); | 220 NotifyFailure(error); |
217 return; | 221 return; |
218 } | 222 } |
219 | 223 |
220 // Apply the range requirement. | 224 // Apply the range requirement. |
221 if (!byte_range_.ComputeBounds(total_size_)) { | 225 if (!byte_range_.ComputeBounds(total_size_)) { |
222 NotifyFailure(net::ERR_REQUEST_RANGE_NOT_SATISFIABLE); | 226 NotifyFailure(net::ERR_REQUEST_RANGE_NOT_SATISFIABLE); |
223 return; | 227 return; |
224 } | 228 } |
225 | 229 |
226 remaining_bytes_ = byte_range_.last_byte_position() - | 230 remaining_bytes_ = base::checked_cast<int64>( |
227 byte_range_.first_byte_position() + 1; | 231 byte_range_.last_byte_position() - byte_range_.first_byte_position() + 1); |
228 DCHECK_GE(remaining_bytes_, 0); | 232 DCHECK_GE(remaining_bytes_, 0); |
229 | 233 |
230 // Do the seek at the beginning of the request. | 234 // Do the seek at the beginning of the request. |
231 if (byte_range_.first_byte_position()) | 235 if (byte_range_.first_byte_position()) |
232 Seek(byte_range_.first_byte_position()); | 236 Seek(byte_range_.first_byte_position()); |
233 | 237 |
234 NotifySuccess(); | 238 NotifySuccess(); |
235 } | 239 } |
236 | 240 |
237 void BlobURLRequestJob::DidGetFileItemLength(size_t index, int64 result) { | 241 void BlobURLRequestJob::DidGetFileItemLength(size_t index, int64 result) { |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
570 item.path(), | 574 item.path(), |
571 item.offset() + additional_offset, | 575 item.offset() + additional_offset, |
572 item.expected_modification_time()); | 576 item.expected_modification_time()); |
573 break; | 577 break; |
574 case BlobData::Item::TYPE_FILE_FILESYSTEM: | 578 case BlobData::Item::TYPE_FILE_FILESYSTEM: |
575 reader = file_system_context_->CreateFileStreamReader( | 579 reader = file_system_context_->CreateFileStreamReader( |
576 storage::FileSystemURL( | 580 storage::FileSystemURL( |
577 file_system_context_->CrackURL( | 581 file_system_context_->CrackURL( |
578 item.filesystem_url())), | 582 item.filesystem_url())), |
579 item.offset() + additional_offset, | 583 item.offset() + additional_offset, |
584 item.length() - additional_offset, | |
hashimoto
2014/09/05 03:17:27
Shouldn't item_length_list_ be used here?
mtomasz
2014/09/05 05:31:42
While filling out item_length_list_, file stream r
| |
580 item.expected_modification_time()) | 585 item.expected_modification_time()) |
581 .release(); | 586 .release(); |
582 break; | 587 break; |
583 default: | 588 default: |
584 NOTREACHED(); | 589 NOTREACHED(); |
585 } | 590 } |
586 DCHECK(reader); | 591 DCHECK(reader); |
587 index_to_reader_[index] = reader; | 592 index_to_reader_[index] = reader; |
588 } | 593 } |
589 | 594 |
590 } // namespace storage | 595 } // namespace storage |
OLD | NEW |