OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/net/evicted_domain_cookie_counter.h" | 5 #include "chrome/browser/net/evicted_domain_cookie_counter.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 ChangeCause cause) { | 100 ChangeCause cause) { |
101 EvictedDomainCookieCounter::EvictedCookieKey key(GetKey(cookie)); | 101 EvictedDomainCookieCounter::EvictedCookieKey key(GetKey(cookie)); |
102 Time current_time(cookie_counter_delegate_->CurrentTime()); | 102 Time current_time(cookie_counter_delegate_->CurrentTime()); |
103 if (removed) { | 103 if (removed) { |
104 if (cause == net::CookieMonster::Delegate::CHANGE_COOKIE_EVICTED) | 104 if (cause == net::CookieMonster::Delegate::CHANGE_COOKIE_EVICTED) |
105 StoreEvictedCookie(key, cookie, current_time); | 105 StoreEvictedCookie(key, cookie, current_time); |
106 } else { // Includes adds or updates. | 106 } else { // Includes adds or updates. |
107 ProcessNewCookie(key, cookie, current_time); | 107 ProcessNewCookie(key, cookie, current_time); |
108 } | 108 } |
109 | 109 |
110 if (next_cookie_monster_delegate_) | 110 if (next_cookie_monster_delegate_.get()) |
111 next_cookie_monster_delegate_->OnCookieChanged(cookie, removed, cause); | 111 next_cookie_monster_delegate_->OnCookieChanged(cookie, removed, cause); |
112 } | 112 } |
113 | 113 |
114 // static | 114 // static |
115 EvictedDomainCookieCounter::EvictedCookieKey | 115 EvictedDomainCookieCounter::EvictedCookieKey |
116 EvictedDomainCookieCounter::GetKey(const net::CanonicalCookie& cookie) { | 116 EvictedDomainCookieCounter::GetKey(const net::CanonicalCookie& cookie) { |
117 return cookie.Domain() + ";" + cookie.Path() + ";" + cookie.Name(); | 117 return cookie.Domain() + ";" + cookie.Path() + ";" + cookie.Name(); |
118 } | 118 } |
119 | 119 |
120 // static | 120 // static |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 EvictedCookieMap::iterator it = evicted_cookies_.find(key); | 193 EvictedCookieMap::iterator it = evicted_cookies_.find(key); |
194 if (it != evicted_cookies_.end()) { | 194 if (it != evicted_cookies_.end()) { |
195 if (!it->second->is_expired(current_time)) // Reinstatement. | 195 if (!it->second->is_expired(current_time)) // Reinstatement. |
196 cookie_counter_delegate_->Report(*it->second, current_time); | 196 cookie_counter_delegate_->Report(*it->second, current_time); |
197 delete it->second; | 197 delete it->second; |
198 evicted_cookies_.erase(it); | 198 evicted_cookies_.erase(it); |
199 } | 199 } |
200 } | 200 } |
201 | 201 |
202 } // namespace chrome_browser_net | 202 } // namespace chrome_browser_net |
OLD | NEW |