Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: net/cookies/cookie_monster.cc

Issue 13979002: Add support for split PSL list distinctions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added const modifiers Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1941 matching lines...) Expand 10 before | Expand all | Expand 10 after
1952 CookieMonster::CookieItVector::iterator it_begin, 1952 CookieMonster::CookieItVector::iterator it_begin,
1953 CookieMonster::CookieItVector::iterator it_end) { 1953 CookieMonster::CookieItVector::iterator it_end) {
1954 for (CookieItVector::iterator it = it_begin; it != it_end; it++) { 1954 for (CookieItVector::iterator it = it_begin; it != it_end; it++) {
1955 histogram_evicted_last_access_minutes_->Add( 1955 histogram_evicted_last_access_minutes_->Add(
1956 (current - (*it)->second->LastAccessDate()).InMinutes()); 1956 (current - (*it)->second->LastAccessDate()).InMinutes());
1957 InternalDeleteCookie((*it), true, cause); 1957 InternalDeleteCookie((*it), true, cause);
1958 } 1958 }
1959 return it_end - it_begin; 1959 return it_end - it_begin;
1960 } 1960 }
1961 1961
1962 // A wrapper around RegistryControlledDomainService::GetDomainAndRegistry 1962 // A wrapper around registry_controlled_domains::GetDomainAndRegistry
1963 // to make clear we're creating a key for our local map. Here and 1963 // to make clear we're creating a key for our local map. Here and
1964 // in FindCookiesForHostAndDomain() are the only two places where 1964 // in FindCookiesForHostAndDomain() are the only two places where
1965 // we need to conditionalize based on key type. 1965 // we need to conditionalize based on key type.
1966 // 1966 //
1967 // Note that this key algorithm explicitly ignores the scheme. This is 1967 // Note that this key algorithm explicitly ignores the scheme. This is
1968 // because when we're entering cookies into the map from the backing store, 1968 // because when we're entering cookies into the map from the backing store,
1969 // we in general won't have the scheme at that point. 1969 // we in general won't have the scheme at that point.
1970 // In practical terms, this means that file cookies will be stored 1970 // In practical terms, this means that file cookies will be stored
1971 // in the map either by an empty string or by UNC name (and will be 1971 // in the map either by an empty string or by UNC name (and will be
1972 // limited by kMaxCookiesPerHost), and extension cookies will be stored 1972 // limited by kMaxCookiesPerHost), and extension cookies will be stored
1973 // based on the single extension id, as the extension id won't have the 1973 // based on the single extension id, as the extension id won't have the
1974 // form of a DNS host and hence GetKey() will return it unchanged. 1974 // form of a DNS host and hence GetKey() will return it unchanged.
1975 // 1975 //
1976 // Arguably the right thing to do here is to make the key 1976 // Arguably the right thing to do here is to make the key
1977 // algorithm dependent on the scheme, and make sure that the scheme is 1977 // algorithm dependent on the scheme, and make sure that the scheme is
1978 // available everywhere the key must be obtained (specfically at backing 1978 // available everywhere the key must be obtained (specfically at backing
1979 // store load time). This would require either changing the backing store 1979 // store load time). This would require either changing the backing store
1980 // database schema to include the scheme (far more trouble than it's worth), or 1980 // database schema to include the scheme (far more trouble than it's worth), or
1981 // separating out file cookies into their own CookieMonster instance and 1981 // separating out file cookies into their own CookieMonster instance and
1982 // thus restricting each scheme to a single cookie monster (which might 1982 // thus restricting each scheme to a single cookie monster (which might
1983 // be worth it, but is still too much trouble to solve what is currently a 1983 // be worth it, but is still too much trouble to solve what is currently a
1984 // non-problem). 1984 // non-problem).
1985 std::string CookieMonster::GetKey(const std::string& domain) const { 1985 std::string CookieMonster::GetKey(const std::string& domain) const {
1986 std::string effective_domain( 1986 std::string effective_domain(
1987 RegistryControlledDomainService::GetDomainAndRegistry(domain)); 1987 registry_controlled_domains::GetDomainAndRegistry(
1988 domain, registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES));
1988 if (effective_domain.empty()) 1989 if (effective_domain.empty())
1989 effective_domain = domain; 1990 effective_domain = domain;
1990 1991
1991 if (!effective_domain.empty() && effective_domain[0] == '.') 1992 if (!effective_domain.empty() && effective_domain[0] == '.')
1992 return effective_domain.substr(1); 1993 return effective_domain.substr(1);
1993 return effective_domain; 1994 return effective_domain;
1994 } 1995 }
1995 1996
1996 bool CookieMonster::IsCookieableScheme(const std::string& scheme) { 1997 bool CookieMonster::IsCookieableScheme(const std::string& scheme) {
1997 base::AutoLock autolock(lock_); 1998 base::AutoLock autolock(lock_);
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
2147 2148
2148 // The system resolution is not high enough, so we can have multiple 2149 // The system resolution is not high enough, so we can have multiple
2149 // set cookies that result in the same system time. When this happens, we 2150 // set cookies that result in the same system time. When this happens, we
2150 // increment by one Time unit. Let's hope computers don't get too fast. 2151 // increment by one Time unit. Let's hope computers don't get too fast.
2151 Time CookieMonster::CurrentTime() { 2152 Time CookieMonster::CurrentTime() {
2152 return std::max(Time::Now(), 2153 return std::max(Time::Now(),
2153 Time::FromInternalValue(last_time_seen_.ToInternalValue() + 1)); 2154 Time::FromInternalValue(last_time_seen_.ToInternalValue() + 1));
2154 } 2155 }
2155 2156
2156 } // namespace net 2157 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698