OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Portions of this code based on Mozilla: | 5 // Portions of this code based on Mozilla: |
6 // (netwerk/cookie/src/nsCookieService.cpp) | 6 // (netwerk/cookie/src/nsCookieService.cpp) |
7 /* ***** BEGIN LICENSE BLOCK ***** | 7 /* ***** BEGIN LICENSE BLOCK ***** |
8 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 8 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
9 * | 9 * |
10 * The contents of this file are subject to the Mozilla Public License Version | 10 * The contents of this file are subject to the Mozilla Public License Version |
(...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1312 return SetCookieWithCreationTimeAndOptions(url, cookie_line, Time(), options); | 1312 return SetCookieWithCreationTimeAndOptions(url, cookie_line, Time(), options); |
1313 } | 1313 } |
1314 | 1314 |
1315 std::string CookieMonster::GetCookiesWithOptions(const GURL& url, | 1315 std::string CookieMonster::GetCookiesWithOptions(const GURL& url, |
1316 const CookieOptions& options) { | 1316 const CookieOptions& options) { |
1317 base::AutoLock autolock(lock_); | 1317 base::AutoLock autolock(lock_); |
1318 | 1318 |
1319 if (!HasCookieableScheme(url)) | 1319 if (!HasCookieableScheme(url)) |
1320 return std::string(); | 1320 return std::string(); |
1321 | 1321 |
1322 TimeTicks start_time(TimeTicks::Now()); | |
1323 | |
1324 std::vector<CanonicalCookie*> cookies; | 1322 std::vector<CanonicalCookie*> cookies; |
1325 FindCookiesForHostAndDomain(url, options, true, &cookies); | 1323 FindCookiesForHostAndDomain(url, options, true, &cookies); |
1326 std::sort(cookies.begin(), cookies.end(), CookieSorter); | 1324 std::sort(cookies.begin(), cookies.end(), CookieSorter); |
1327 | 1325 |
1328 std::string cookie_line = BuildCookieLine(cookies); | 1326 std::string cookie_line = BuildCookieLine(cookies); |
1329 | 1327 |
1330 histogram_time_get_->AddTime(TimeTicks::Now() - start_time); | |
1331 | |
1332 VLOG(kVlogGetCookies) << "GetCookies() result: " << cookie_line; | 1328 VLOG(kVlogGetCookies) << "GetCookies() result: " << cookie_line; |
1333 | 1329 |
1334 return cookie_line; | 1330 return cookie_line; |
1335 } | 1331 } |
1336 | 1332 |
1337 void CookieMonster::DeleteCookie(const GURL& url, | 1333 void CookieMonster::DeleteCookie(const GURL& url, |
1338 const std::string& cookie_name) { | 1334 const std::string& cookie_name) { |
1339 base::AutoLock autolock(lock_); | 1335 base::AutoLock autolock(lock_); |
1340 | 1336 |
1341 if (!HasCookieableScheme(url)) | 1337 if (!HasCookieableScheme(url)) |
(...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2238 "Net.NumDuplicateCookiesInDb", 1, 10000, 50, | 2234 "Net.NumDuplicateCookiesInDb", 1, 10000, 50, |
2239 base::Histogram::kUmaTargetedHistogramFlag); | 2235 base::Histogram::kUmaTargetedHistogramFlag); |
2240 | 2236 |
2241 // From UMA_HISTOGRAM_ENUMERATION | 2237 // From UMA_HISTOGRAM_ENUMERATION |
2242 histogram_cookie_deletion_cause_ = base::LinearHistogram::FactoryGet( | 2238 histogram_cookie_deletion_cause_ = base::LinearHistogram::FactoryGet( |
2243 "Cookie.DeletionCause", 1, | 2239 "Cookie.DeletionCause", 1, |
2244 DELETE_COOKIE_LAST_ENTRY - 1, DELETE_COOKIE_LAST_ENTRY, | 2240 DELETE_COOKIE_LAST_ENTRY - 1, DELETE_COOKIE_LAST_ENTRY, |
2245 base::Histogram::kUmaTargetedHistogramFlag); | 2241 base::Histogram::kUmaTargetedHistogramFlag); |
2246 | 2242 |
2247 // From UMA_HISTOGRAM_{CUSTOM_,}TIMES | 2243 // From UMA_HISTOGRAM_{CUSTOM_,}TIMES |
2248 histogram_time_get_ = base::Histogram::FactoryTimeGet("Cookie.TimeGet", | |
2249 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMinutes(1), | |
2250 50, base::Histogram::kUmaTargetedHistogramFlag); | |
2251 histogram_time_blocked_on_load_ = base::Histogram::FactoryTimeGet( | 2244 histogram_time_blocked_on_load_ = base::Histogram::FactoryTimeGet( |
2252 "Cookie.TimeBlockedOnLoad", | 2245 "Cookie.TimeBlockedOnLoad", |
2253 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMinutes(1), | 2246 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMinutes(1), |
2254 50, base::Histogram::kUmaTargetedHistogramFlag); | 2247 50, base::Histogram::kUmaTargetedHistogramFlag); |
2255 } | 2248 } |
2256 | 2249 |
2257 | 2250 |
2258 // The system resolution is not high enough, so we can have multiple | 2251 // The system resolution is not high enough, so we can have multiple |
2259 // set cookies that result in the same system time. When this happens, we | 2252 // set cookies that result in the same system time. When this happens, we |
2260 // increment by one Time unit. Let's hope computers don't get too fast. | 2253 // increment by one Time unit. Let's hope computers don't get too fast. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2340 it != hook_map_.end(); ++it) { | 2333 it != hook_map_.end(); ++it) { |
2341 std::pair<GURL, std::string> key = it->first; | 2334 std::pair<GURL, std::string> key = it->first; |
2342 if (cookie.IncludeForRequestURL(key.first, opts) && | 2335 if (cookie.IncludeForRequestURL(key.first, opts) && |
2343 cookie.Name() == key.second) { | 2336 cookie.Name() == key.second) { |
2344 it->second->Notify(cookie, removed); | 2337 it->second->Notify(cookie, removed); |
2345 } | 2338 } |
2346 } | 2339 } |
2347 } | 2340 } |
2348 | 2341 |
2349 } // namespace net | 2342 } // namespace net |
OLD | NEW |