OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 } | 894 } |
895 | 895 |
896 return num_deleted; | 896 return num_deleted; |
897 } | 897 } |
898 | 898 |
899 int CookieMonster::DeleteAllCreatedAfter(const Time& delete_begin, | 899 int CookieMonster::DeleteAllCreatedAfter(const Time& delete_begin, |
900 bool sync_to_store) { | 900 bool sync_to_store) { |
901 return DeleteAllCreatedBetween(delete_begin, Time(), sync_to_store); | 901 return DeleteAllCreatedBetween(delete_begin, Time(), sync_to_store); |
902 } | 902 } |
903 | 903 |
904 int CookieMonster::DeleteAllForURL(const GURL& url, | 904 int CookieMonster::DeleteAllForHost(const GURL& url) { |
905 bool sync_to_store) { | |
906 AutoLock autolock(lock_); | 905 AutoLock autolock(lock_); |
907 InitIfNecessary(); | 906 InitIfNecessary(); |
908 | 907 |
909 CookieList cookies = InternalGetAllCookiesForURL(url); | 908 if (!HasCookieableScheme(url)) |
| 909 return 0; |
| 910 |
| 911 // We store host cookies in the store by their canonical host name; |
| 912 // domain cookies are stored with a leading ".". So this is a pretty |
| 913 // simple lookup and per-cookie delete. |
910 int num_deleted = 0; | 914 int num_deleted = 0; |
911 for (CookieMap::iterator it = cookies_.begin(); it != cookies_.end();) { | 915 for (CookieMapItPair its = cookies_.equal_range(url.host()); |
912 CookieMap::iterator curit = it; | 916 its.first != its.second;) { |
913 ++it; | 917 CookieMap::iterator curit = its.first; |
914 InternalDeleteCookie(curit, sync_to_store, kDeleteCookieExplicit); | 918 ++its.first; |
| 919 num_deleted++; |
| 920 |
| 921 InternalDeleteCookie(curit, true, kDeleteCookieExplicit); |
915 } | 922 } |
916 return num_deleted; | 923 return num_deleted; |
917 } | 924 } |
918 | 925 |
919 bool CookieMonster::DeleteCookie(const std::string& domain, | 926 bool CookieMonster::DeleteCookie(const std::string& domain, |
920 const CanonicalCookie& cookie, | 927 const CanonicalCookie& cookie, |
921 bool sync_to_store) { | 928 bool sync_to_store) { |
922 AutoLock autolock(lock_); | 929 AutoLock autolock(lock_); |
923 InitIfNecessary(); | 930 InitIfNecessary(); |
924 | 931 |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1565 return true; | 1572 return true; |
1566 } | 1573 } |
1567 | 1574 |
1568 std::string CookieMonster::CanonicalCookie::DebugString() const { | 1575 std::string CookieMonster::CanonicalCookie::DebugString() const { |
1569 return StringPrintf("name: %s value: %s path: %s creation: %" PRId64, | 1576 return StringPrintf("name: %s value: %s path: %s creation: %" PRId64, |
1570 name_.c_str(), value_.c_str(), path_.c_str(), | 1577 name_.c_str(), value_.c_str(), path_.c_str(), |
1571 static_cast<int64>(creation_date_.ToTimeT())); | 1578 static_cast<int64>(creation_date_.ToTimeT())); |
1572 } | 1579 } |
1573 | 1580 |
1574 } // namespace | 1581 } // namespace |
OLD | NEW |