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) { |
256 entries_.clear(); | 256 int64_t begin_millis = |
257 delete_begin.is_null() | |
258 ? 0 | |
259 : (delete_begin - base::Time::UnixEpoch()).InMilliseconds(); | |
msramek
2016/06/30 11:36:20
Can you use base::Time::ToTimeT() to do these conv
Tomasz Moniuszko
2016/07/01 12:44:02
There's a TODO saying base::Time::ToTimeT() should
msramek
2016/07/01 13:19:40
I would say yes. The TODO says that the function s
Tomasz Moniuszko
2016/07/01 14:54:39
Done.
| |
260 int64_t end_millis = | |
261 delete_end.is_null() | |
262 ? std::numeric_limits<int64_t>::max() | |
263 : (delete_end - base::Time::UnixEpoch()).InMilliseconds(); | |
264 | |
265 base::TimeTicks unix_epoch = base::TimeTicks::UnixEpoch(); | |
266 | |
267 entries_.remove_if( | |
268 [begin_millis, end_millis, unix_epoch](const Entry& entry) { | |
269 int64_t creation_millis = | |
270 (entry.creation_time_ - unix_epoch).InMilliseconds(); | |
271 return creation_millis >= begin_millis && creation_millis <= end_millis; | |
msramek
2016/06/30 11:36:20
BrowsingDataRemover always uses half-closed interv
Tomasz Moniuszko
2016/07/01 12:44:02
Done.
| |
272 }); | |
257 } | 273 } |
258 | 274 |
259 bool HttpAuthCache::UpdateStaleChallenge(const GURL& origin, | 275 bool HttpAuthCache::UpdateStaleChallenge(const GURL& origin, |
260 const std::string& realm, | 276 const std::string& realm, |
261 HttpAuth::Scheme scheme, | 277 HttpAuth::Scheme scheme, |
262 const std::string& auth_challenge) { | 278 const std::string& auth_challenge) { |
263 HttpAuthCache::Entry* entry = Lookup(origin, realm, scheme); | 279 HttpAuthCache::Entry* entry = Lookup(origin, realm, scheme); |
264 if (!entry) | 280 if (!entry) |
265 return false; | 281 return false; |
266 entry->UpdateStaleChallenge(auth_challenge); | 282 entry->UpdateStaleChallenge(auth_challenge); |
(...skipping 12 matching lines...) Expand all Loading... | |
279 // Copy all other paths. | 295 // Copy all other paths. |
280 for (Entry::PathList::const_reverse_iterator it2 = ++it->paths_.rbegin(); | 296 for (Entry::PathList::const_reverse_iterator it2 = ++it->paths_.rbegin(); |
281 it2 != it->paths_.rend(); ++it2) | 297 it2 != it->paths_.rend(); ++it2) |
282 entry->AddPath(*it2); | 298 entry->AddPath(*it2); |
283 // Copy nonce count (for digest authentication). | 299 // Copy nonce count (for digest authentication). |
284 entry->nonce_count_ = it->nonce_count_; | 300 entry->nonce_count_ = it->nonce_count_; |
285 } | 301 } |
286 } | 302 } |
287 | 303 |
288 } // namespace net | 304 } // namespace net |
OLD | NEW |