Chromium Code Reviews| 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::Clear(base::Time delete_begin, base::Time delete_end) { |
|
asanka
2016/07/12 17:50:32
How feasible would it be to have the API be: void
Tomasz Moniuszko
2016/07/15 11:41:34
Done.
| |
| 256 entries_.clear(); | 256 DCHECK(!delete_end.is_null()); |
| 257 | |
| 258 time_t begin_time = delete_begin.ToTimeT(); | |
| 259 time_t end_time = delete_end.ToTimeT(); | |
| 260 base::TimeTicks unix_epoch = base::TimeTicks::UnixEpoch(); | |
| 261 | |
| 262 entries_.remove_if([begin_time, end_time, unix_epoch](const Entry& entry) { | |
| 263 int64_t creation_time = (entry.creation_time_ - unix_epoch).InSeconds(); | |
| 264 return creation_time >= begin_time && creation_time < end_time; | |
| 265 }); | |
| 257 } | 266 } |
| 258 | 267 |
| 259 bool HttpAuthCache::UpdateStaleChallenge(const GURL& origin, | 268 bool HttpAuthCache::UpdateStaleChallenge(const GURL& origin, |
| 260 const std::string& realm, | 269 const std::string& realm, |
| 261 HttpAuth::Scheme scheme, | 270 HttpAuth::Scheme scheme, |
| 262 const std::string& auth_challenge) { | 271 const std::string& auth_challenge) { |
| 263 HttpAuthCache::Entry* entry = Lookup(origin, realm, scheme); | 272 HttpAuthCache::Entry* entry = Lookup(origin, realm, scheme); |
| 264 if (!entry) | 273 if (!entry) |
| 265 return false; | 274 return false; |
| 266 entry->UpdateStaleChallenge(auth_challenge); | 275 entry->UpdateStaleChallenge(auth_challenge); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 279 // Copy all other paths. | 288 // Copy all other paths. |
| 280 for (Entry::PathList::const_reverse_iterator it2 = ++it->paths_.rbegin(); | 289 for (Entry::PathList::const_reverse_iterator it2 = ++it->paths_.rbegin(); |
| 281 it2 != it->paths_.rend(); ++it2) | 290 it2 != it->paths_.rend(); ++it2) |
| 282 entry->AddPath(*it2); | 291 entry->AddPath(*it2); |
| 283 // Copy nonce count (for digest authentication). | 292 // Copy nonce count (for digest authentication). |
| 284 entry->nonce_count_ = it->nonce_count_; | 293 entry->nonce_count_ = it->nonce_count_; |
| 285 } | 294 } |
| 286 } | 295 } |
| 287 | 296 |
| 288 } // namespace net | 297 } // namespace net |
| OLD | NEW |