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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 #include "base/metrics/histogram.h" | 58 #include "base/metrics/histogram.h" |
59 #include "base/profiler/scoped_tracker.h" | 59 #include "base/profiler/scoped_tracker.h" |
60 #include "base/single_thread_task_runner.h" | 60 #include "base/single_thread_task_runner.h" |
61 #include "base/strings/string_util.h" | 61 #include "base/strings/string_util.h" |
62 #include "base/strings/stringprintf.h" | 62 #include "base/strings/stringprintf.h" |
63 #include "base/thread_task_runner_handle.h" | 63 #include "base/thread_task_runner_handle.h" |
64 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 64 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
65 #include "net/cookies/canonical_cookie.h" | 65 #include "net/cookies/canonical_cookie.h" |
66 #include "net/cookies/cookie_util.h" | 66 #include "net/cookies/cookie_util.h" |
67 #include "net/cookies/parsed_cookie.h" | 67 #include "net/cookies/parsed_cookie.h" |
| 68 #include "url/origin.h" |
68 | 69 |
69 using base::Time; | 70 using base::Time; |
70 using base::TimeDelta; | 71 using base::TimeDelta; |
71 using base::TimeTicks; | 72 using base::TimeTicks; |
72 | 73 |
73 // In steady state, most cookie requests can be satisfied by the in memory | 74 // In steady state, most cookie requests can be satisfied by the in memory |
74 // cookie monster store. If the cookie request cannot be satisfied by the in | 75 // cookie monster store. If the cookie request cannot be satisfied by the in |
75 // memory store, the relevant cookies must be fetched from the persistent | 76 // memory store, the relevant cookies must be fetched from the persistent |
76 // store. The task is queued in CookieMonster::tasks_pending_ if it requires | 77 // store. The task is queued in CookieMonster::tasks_pending_ if it requires |
77 // all cookies to be loaded from the backend, or tasks_pending_for_key_ if it | 78 // all cookies to be loaded from the backend, or tasks_pending_for_key_ if it |
(...skipping 1133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1211 for (std::vector<CanonicalCookie*>::const_iterator it = cookie_ptrs.begin(); | 1212 for (std::vector<CanonicalCookie*>::const_iterator it = cookie_ptrs.begin(); |
1212 it != cookie_ptrs.end(); it++) | 1213 it != cookie_ptrs.end(); it++) |
1213 cookies.push_back(**it); | 1214 cookies.push_back(**it); |
1214 | 1215 |
1215 return cookies; | 1216 return cookies; |
1216 } | 1217 } |
1217 | 1218 |
1218 CookieList CookieMonster::GetAllCookiesForURL(const GURL& url) { | 1219 CookieList CookieMonster::GetAllCookiesForURL(const GURL& url) { |
1219 CookieOptions options; | 1220 CookieOptions options; |
1220 options.set_include_httponly(); | 1221 options.set_include_httponly(); |
1221 options.set_first_party_url(url); | 1222 options.set_first_party(url::Origin(url)); |
1222 | 1223 |
1223 return GetAllCookiesForURLWithOptions(url, options); | 1224 return GetAllCookiesForURLWithOptions(url, options); |
1224 } | 1225 } |
1225 | 1226 |
1226 int CookieMonster::DeleteAll(bool sync_to_store) { | 1227 int CookieMonster::DeleteAll(bool sync_to_store) { |
1227 base::AutoLock autolock(lock_); | 1228 base::AutoLock autolock(lock_); |
1228 | 1229 |
1229 int num_deleted = 0; | 1230 int num_deleted = 0; |
1230 for (CookieMap::iterator it = cookies_.begin(); it != cookies_.end();) { | 1231 for (CookieMap::iterator it = cookies_.begin(); it != cookies_.end();) { |
1231 CookieMap::iterator curit = it; | 1232 CookieMap::iterator curit = it; |
(...skipping 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2375 it != hook_map_.end(); ++it) { | 2376 it != hook_map_.end(); ++it) { |
2376 std::pair<GURL, std::string> key = it->first; | 2377 std::pair<GURL, std::string> key = it->first; |
2377 if (cookie.IncludeForRequestURL(key.first, opts) && | 2378 if (cookie.IncludeForRequestURL(key.first, opts) && |
2378 cookie.Name() == key.second) { | 2379 cookie.Name() == key.second) { |
2379 it->second->Notify(cookie, removed); | 2380 it->second->Notify(cookie, removed); |
2380 } | 2381 } |
2381 } | 2382 } |
2382 } | 2383 } |
2383 | 2384 |
2384 } // namespace net | 2385 } // namespace net |
OLD | NEW |