| 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 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 const char kGlobalCookieSetURL[] = "chrome://cookieset"; | 28 const char kGlobalCookieSetURL[] = "chrome://cookieset"; |
| 29 | 29 |
| 30 void OnFetchComplete(const BrowsingDataCookieHelper::FetchCallback& callback, | 30 void OnFetchComplete(const BrowsingDataCookieHelper::FetchCallback& callback, |
| 31 const net::CookieList& cookies) { | 31 const net::CookieList& cookies) { |
| 32 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 32 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 33 DCHECK(!callback.is_null()); | 33 DCHECK(!callback.is_null()); |
| 34 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 34 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 35 base::Bind(callback, cookies)); | 35 base::BindOnce(callback, cookies)); |
| 36 } | 36 } |
| 37 | 37 |
| 38 } // namespace | 38 } // namespace |
| 39 | 39 |
| 40 BrowsingDataCookieHelper::BrowsingDataCookieHelper( | 40 BrowsingDataCookieHelper::BrowsingDataCookieHelper( |
| 41 net::URLRequestContextGetter* request_context_getter) | 41 net::URLRequestContextGetter* request_context_getter) |
| 42 : request_context_getter_(request_context_getter) { | 42 : request_context_getter_(request_context_getter) { |
| 43 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 43 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 44 } | 44 } |
| 45 | 45 |
| 46 BrowsingDataCookieHelper::~BrowsingDataCookieHelper() { | 46 BrowsingDataCookieHelper::~BrowsingDataCookieHelper() { |
| 47 } | 47 } |
| 48 | 48 |
| 49 void BrowsingDataCookieHelper::StartFetching(const FetchCallback& callback) { | 49 void BrowsingDataCookieHelper::StartFetching(const FetchCallback& callback) { |
| 50 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 50 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 51 DCHECK(!callback.is_null()); | 51 DCHECK(!callback.is_null()); |
| 52 BrowserThread::PostTask( | 52 BrowserThread::PostTask( |
| 53 BrowserThread::IO, FROM_HERE, | 53 BrowserThread::IO, FROM_HERE, |
| 54 base::Bind(&BrowsingDataCookieHelper::FetchCookiesOnIOThread, this, | 54 base::BindOnce(&BrowsingDataCookieHelper::FetchCookiesOnIOThread, this, |
| 55 callback)); | 55 callback)); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void BrowsingDataCookieHelper::DeleteCookie( | 58 void BrowsingDataCookieHelper::DeleteCookie( |
| 59 const net::CanonicalCookie& cookie) { | 59 const net::CanonicalCookie& cookie) { |
| 60 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 60 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 61 BrowserThread::PostTask( | 61 BrowserThread::PostTask( |
| 62 BrowserThread::IO, FROM_HERE, | 62 BrowserThread::IO, FROM_HERE, |
| 63 base::Bind(&BrowsingDataCookieHelper::DeleteCookieOnIOThread, | 63 base::BindOnce(&BrowsingDataCookieHelper::DeleteCookieOnIOThread, this, |
| 64 this, cookie)); | 64 cookie)); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void BrowsingDataCookieHelper::FetchCookiesOnIOThread( | 67 void BrowsingDataCookieHelper::FetchCookiesOnIOThread( |
| 68 const FetchCallback& callback) { | 68 const FetchCallback& callback) { |
| 69 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 69 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 70 DCHECK(!callback.is_null()); | 70 DCHECK(!callback.is_null()); |
| 71 request_context_getter_->GetURLRequestContext()->cookie_store()-> | 71 request_context_getter_->GetURLRequestContext()->cookie_store()-> |
| 72 GetAllCookiesAsync(base::Bind(&OnFetchComplete, callback)); | 72 GetAllCookiesAsync(base::Bind(&OnFetchComplete, callback)); |
| 73 } | 73 } |
| 74 | 74 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 // TODO(markusheintz): A) Change the GetCookiesCount method to prevent | 181 // TODO(markusheintz): A) Change the GetCookiesCount method to prevent |
| 182 // counting cookies multiple times if they are stored in multiple cookie | 182 // counting cookies multiple times if they are stored in multiple cookie |
| 183 // sets. B) Replace the GetCookieFor method call below with: | 183 // sets. B) Replace the GetCookieFor method call below with: |
| 184 // "GetCookiesFor(frame_url.GetOrigin());" | 184 // "GetCookiesFor(frame_url.GetOrigin());" |
| 185 CR_DEFINE_STATIC_LOCAL(const GURL, origin_cookie_url, (kGlobalCookieSetURL)); | 185 CR_DEFINE_STATIC_LOCAL(const GURL, origin_cookie_url, (kGlobalCookieSetURL)); |
| 186 canonical_cookie::CookieHashSet* cookie_set = | 186 canonical_cookie::CookieHashSet* cookie_set = |
| 187 GetCookiesFor(origin_cookie_url); | 187 GetCookiesFor(origin_cookie_url); |
| 188 DeleteMatchingCookie(cookie, cookie_set); | 188 DeleteMatchingCookie(cookie, cookie_set); |
| 189 cookie_set->insert(cookie); | 189 cookie_set->insert(cookie); |
| 190 } | 190 } |
| OLD | NEW |