| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_backoff_manager.h" | 5 #include "net/url_request/url_request_backoff_manager.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/string_piece.h" | 9 #include "base/strings/string_piece.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 11 #include "net/http/http_response_headers.h" | 11 #include "net/http/http_response_headers.h" |
| 12 | 12 |
| 13 namespace net { | 13 namespace net { |
| 14 | 14 |
| 15 const uint16 URLRequestBackoffManager::kMinimumBackoffInSeconds = 1; | 15 const uint16_t URLRequestBackoffManager::kMinimumBackoffInSeconds = 1; |
| 16 const uint16 URLRequestBackoffManager::kMaximumBackoffInSeconds = 50000; | 16 const uint16_t URLRequestBackoffManager::kMaximumBackoffInSeconds = 50000; |
| 17 const uint16 URLRequestBackoffManager::kNewEntriesBetweenCollecting = 200; | 17 const uint16_t URLRequestBackoffManager::kNewEntriesBetweenCollecting = 200; |
| 18 | 18 |
| 19 URLRequestBackoffManager::URLRequestBackoffManager() | 19 URLRequestBackoffManager::URLRequestBackoffManager() |
| 20 : new_entries_since_last_gc_(0) { | 20 : new_entries_since_last_gc_(0) { |
| 21 url_id_replacements_.ClearPassword(); | 21 url_id_replacements_.ClearPassword(); |
| 22 url_id_replacements_.ClearUsername(); | 22 url_id_replacements_.ClearUsername(); |
| 23 url_id_replacements_.ClearQuery(); | 23 url_id_replacements_.ClearQuery(); |
| 24 url_id_replacements_.ClearRef(); | 24 url_id_replacements_.ClearRef(); |
| 25 | 25 |
| 26 NetworkChangeNotifier::AddIPAddressObserver(this); | 26 NetworkChangeNotifier::AddIPAddressObserver(this); |
| 27 NetworkChangeNotifier::AddConnectionTypeObserver(this); | 27 NetworkChangeNotifier::AddConnectionTypeObserver(this); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 } | 106 } |
| 107 } | 107 } |
| 108 } | 108 } |
| 109 | 109 |
| 110 bool URLRequestBackoffManager::GetBackoffTime(HttpResponseHeaders* headers, | 110 bool URLRequestBackoffManager::GetBackoffTime(HttpResponseHeaders* headers, |
| 111 base::TimeDelta* result) const { | 111 base::TimeDelta* result) const { |
| 112 base::StringPiece name("Backoff"); | 112 base::StringPiece name("Backoff"); |
| 113 std::string value; | 113 std::string value; |
| 114 void* iter = NULL; | 114 void* iter = NULL; |
| 115 while (headers->EnumerateHeader(&iter, name, &value)) { | 115 while (headers->EnumerateHeader(&iter, name, &value)) { |
| 116 int64 seconds; | 116 int64_t seconds; |
| 117 base::StringToInt64(value, &seconds); | 117 base::StringToInt64(value, &seconds); |
| 118 if (seconds >= kMinimumBackoffInSeconds && | 118 if (seconds >= kMinimumBackoffInSeconds && |
| 119 seconds <= kMaximumBackoffInSeconds) { | 119 seconds <= kMaximumBackoffInSeconds) { |
| 120 *result = base::TimeDelta::FromSeconds(seconds); | 120 *result = base::TimeDelta::FromSeconds(seconds); |
| 121 return true; | 121 return true; |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 return false; | 124 return false; |
| 125 } | 125 } |
| 126 | 126 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 138 new_entries_since_last_gc_ = 0; | 138 new_entries_since_last_gc_ = 0; |
| 139 // Remove all entries. | 139 // Remove all entries. |
| 140 for (UrlEntryMap::iterator it = url_entries_.begin(); | 140 for (UrlEntryMap::iterator it = url_entries_.begin(); |
| 141 it != url_entries_.end(); ++it) { | 141 it != url_entries_.end(); ++it) { |
| 142 delete it->second; | 142 delete it->second; |
| 143 } | 143 } |
| 144 url_entries_.clear(); | 144 url_entries_.clear(); |
| 145 } | 145 } |
| 146 | 146 |
| 147 } // namespace net | 147 } // namespace net |
| OLD | NEW |