| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/http_auth_cache.h" | 5 #include "net/http/http_auth_cache.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 | 10 |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 if (credentials.Equals(it->credentials())) { | 245 if (credentials.Equals(it->credentials())) { |
| 246 entries_.erase(it); | 246 entries_.erase(it); |
| 247 return true; | 247 return true; |
| 248 } | 248 } |
| 249 return false; | 249 return false; |
| 250 } | 250 } |
| 251 } | 251 } |
| 252 return false; | 252 return false; |
| 253 } | 253 } |
| 254 | 254 |
| 255 void HttpAuthCache::Clear() { | 255 void HttpAuthCache::ClearEntriesAddedWithin(base::TimeDelta duration) { |
| 256 entries_.clear(); | 256 base::TimeTicks begin_time = base::TimeTicks::Now() - duration; |
| 257 entries_.remove_if([begin_time](const Entry& entry) { |
| 258 return entry.creation_time_ >= begin_time; |
| 259 }); |
| 257 } | 260 } |
| 258 | 261 |
| 259 bool HttpAuthCache::UpdateStaleChallenge(const GURL& origin, | 262 bool HttpAuthCache::UpdateStaleChallenge(const GURL& origin, |
| 260 const std::string& realm, | 263 const std::string& realm, |
| 261 HttpAuth::Scheme scheme, | 264 HttpAuth::Scheme scheme, |
| 262 const std::string& auth_challenge) { | 265 const std::string& auth_challenge) { |
| 263 HttpAuthCache::Entry* entry = Lookup(origin, realm, scheme); | 266 HttpAuthCache::Entry* entry = Lookup(origin, realm, scheme); |
| 264 if (!entry) | 267 if (!entry) |
| 265 return false; | 268 return false; |
| 266 entry->UpdateStaleChallenge(auth_challenge); | 269 entry->UpdateStaleChallenge(auth_challenge); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 279 // Copy all other paths. | 282 // Copy all other paths. |
| 280 for (Entry::PathList::const_reverse_iterator it2 = ++it->paths_.rbegin(); | 283 for (Entry::PathList::const_reverse_iterator it2 = ++it->paths_.rbegin(); |
| 281 it2 != it->paths_.rend(); ++it2) | 284 it2 != it->paths_.rend(); ++it2) |
| 282 entry->AddPath(*it2); | 285 entry->AddPath(*it2); |
| 283 // Copy nonce count (for digest authentication). | 286 // Copy nonce count (for digest authentication). |
| 284 entry->nonce_count_ = it->nonce_count_; | 287 entry->nonce_count_ = it->nonce_count_; |
| 285 } | 288 } |
| 286 } | 289 } |
| 287 | 290 |
| 288 } // namespace net | 291 } // namespace net |
| OLD | NEW |