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 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" | 5 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 } | 121 } |
122 | 122 |
123 | 123 |
124 size_t CannedBrowsingDataCookieHelper::GetCookieCount() const { | 124 size_t CannedBrowsingDataCookieHelper::GetCookieCount() const { |
125 size_t count = 0; | 125 size_t count = 0; |
126 for (const auto& pair : origin_cookie_set_map_) | 126 for (const auto& pair : origin_cookie_set_map_) |
127 count += pair.second->size(); | 127 count += pair.second->size(); |
128 return count; | 128 return count; |
129 } | 129 } |
130 | 130 |
131 | |
132 void CannedBrowsingDataCookieHelper::StartFetching( | 131 void CannedBrowsingDataCookieHelper::StartFetching( |
133 const net::CookieStore::GetCookieListCallback& callback) { | 132 const FetchCallback& callback) { |
134 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 133 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
135 net::CookieList cookie_list; | 134 net::CookieList cookie_list; |
136 for (const auto& pair : origin_cookie_set_map_) { | 135 for (const auto& pair : origin_cookie_set_map_) { |
137 cookie_list.insert(cookie_list.begin(), pair.second->begin(), | 136 cookie_list.insert(cookie_list.begin(), pair.second->begin(), |
138 pair.second->end()); | 137 pair.second->end()); |
139 } | 138 } |
140 callback.Run(cookie_list); | 139 callback.Run(cookie_list); |
141 } | 140 } |
142 | 141 |
143 void CannedBrowsingDataCookieHelper::DeleteCookie( | 142 void CannedBrowsingDataCookieHelper::DeleteCookie( |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 // TODO(markusheintz): A) Change the GetCookiesCount method to prevent | 180 // TODO(markusheintz): A) Change the GetCookiesCount method to prevent |
182 // counting cookies multiple times if they are stored in multiple cookie | 181 // counting cookies multiple times if they are stored in multiple cookie |
183 // sets. B) Replace the GetCookieFor method call below with: | 182 // sets. B) Replace the GetCookieFor method call below with: |
184 // "GetCookiesFor(frame_url.GetOrigin());" | 183 // "GetCookiesFor(frame_url.GetOrigin());" |
185 CR_DEFINE_STATIC_LOCAL(const GURL, origin_cookie_url, (kGlobalCookieSetURL)); | 184 CR_DEFINE_STATIC_LOCAL(const GURL, origin_cookie_url, (kGlobalCookieSetURL)); |
186 canonical_cookie::CookieHashSet* cookie_set = | 185 canonical_cookie::CookieHashSet* cookie_set = |
187 GetCookiesFor(origin_cookie_url); | 186 GetCookiesFor(origin_cookie_url); |
188 DeleteMatchingCookie(cookie, cookie_set); | 187 DeleteMatchingCookie(cookie, cookie_set); |
189 cookie_set->insert(cookie); | 188 cookie_set->insert(cookie); |
190 } | 189 } |
OLD | NEW |