| 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 "net/http/partial_data.h" | 5 #include "net/http/partial_data.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/trace_event/trace_event.h" |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 11 #include "base/format_macros.h" | 12 #include "base/format_macros.h" |
| 12 #include "base/logging.h" | 13 #include "base/logging.h" |
| 13 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 15 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 16 #include "net/base/net_errors.h" | 17 #include "net/base/net_errors.h" |
| 17 #include "net/disk_cache/disk_cache.h" | 18 #include "net/disk_cache/disk_cache.h" |
| 18 #include "net/http/http_response_headers.h" | 19 #include "net/http/http_response_headers.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 37 cached_min_len_(0), | 38 cached_min_len_(0), |
| 38 range_present_(false), | 39 range_present_(false), |
| 39 final_range_(false), | 40 final_range_(false), |
| 40 sparse_entry_(true), | 41 sparse_entry_(true), |
| 41 truncated_(false), | 42 truncated_(false), |
| 42 initial_validation_(false), | 43 initial_validation_(false), |
| 43 weak_factory_(this) { | 44 weak_factory_(this) { |
| 44 } | 45 } |
| 45 | 46 |
| 46 PartialData::~PartialData() { | 47 PartialData::~PartialData() { |
| 48 TRACE_EVENT0("toplevel", "PartialData::~PartialData"); |
| 47 } | 49 } |
| 48 | 50 |
| 49 bool PartialData::Init(const HttpRequestHeaders& headers) { | 51 bool PartialData::Init(const HttpRequestHeaders& headers) { |
| 50 std::string range_header; | 52 std::string range_header; |
| 51 if (!headers.GetHeader(HttpRequestHeaders::kRange, &range_header)) | 53 if (!headers.GetHeader(HttpRequestHeaders::kRange, &range_header)) |
| 52 return false; | 54 return false; |
| 53 | 55 |
| 54 std::vector<HttpByteRange> ranges; | 56 std::vector<HttpByteRange> ranges; |
| 55 if (!HttpUtil::ParseRangeHeader(range_header, &ranges) || ranges.size() != 1) | 57 if (!HttpUtil::ParseRangeHeader(range_header, &ranges) || ranges.size() != 1) |
| 56 return false; | 58 return false; |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 cached_min_len_ = result; | 437 cached_min_len_ = result; |
| 436 if (result >= 0) | 438 if (result >= 0) |
| 437 result = 1; // Return success, go ahead and validate the entry. | 439 result = 1; // Return success, go ahead and validate the entry. |
| 438 | 440 |
| 439 CompletionCallback cb = callback_; | 441 CompletionCallback cb = callback_; |
| 440 callback_.Reset(); | 442 callback_.Reset(); |
| 441 cb.Run(result); | 443 cb.Run(result); |
| 442 } | 444 } |
| 443 | 445 |
| 444 } // namespace net | 446 } // namespace net |
| OLD | NEW |