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

Side by Side Diff: chrome/browser/browsing_data/browsing_data_cookie_helper.cc

Issue 1666513002: Promote CookieMonster::DeleteCanonicalCookieAsync to CookieStore. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cookie_monster13
Patch Set: Rebase Created 4 years, 10 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
« no previous file with comments | « no previous file | chrome/browser/browsing_data/mock_browsing_data_cookie_helper.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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 <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 BrowserThread::PostTask( 61 BrowserThread::PostTask(
62 BrowserThread::IO, FROM_HERE, 62 BrowserThread::IO, FROM_HERE,
63 base::Bind(&BrowsingDataCookieHelper::DeleteCookieOnIOThread, 63 base::Bind(&BrowsingDataCookieHelper::DeleteCookieOnIOThread,
64 this, cookie)); 64 this, 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 scoped_refptr<net::CookieMonster> cookie_monster = 71 request_context_getter_->GetURLRequestContext()->cookie_store()->
72 request_context_getter_->GetURLRequestContext()-> 72 GetAllCookiesAsync(base::Bind(&OnFetchComplete, callback));
73 cookie_store()->GetCookieMonster();
74 if (cookie_monster.get()) {
75 cookie_monster->GetAllCookiesAsync(base::Bind(&OnFetchComplete, callback));
76 } else {
77 OnFetchComplete(callback, net::CookieList());
78 }
79 } 73 }
80 74
81 void BrowsingDataCookieHelper::DeleteCookieOnIOThread( 75 void BrowsingDataCookieHelper::DeleteCookieOnIOThread(
82 const net::CanonicalCookie& cookie) { 76 const net::CanonicalCookie& cookie) {
83 DCHECK_CURRENTLY_ON(BrowserThread::IO); 77 DCHECK_CURRENTLY_ON(BrowserThread::IO);
84 scoped_refptr<net::CookieMonster> cookie_monster = 78 request_context_getter_->GetURLRequestContext()->cookie_store()->
85 request_context_getter_->GetURLRequestContext()-> 79 DeleteCanonicalCookieAsync(
86 cookie_store()->GetCookieMonster(); 80 cookie, net::CookieStore::DeleteCallback());
87 if (cookie_monster.get()) {
88 cookie_monster->DeleteCanonicalCookieAsync(
89 cookie, net::CookieMonster::DeleteCookieCallback());
90 }
91 } 81 }
92 82
93 CannedBrowsingDataCookieHelper::CannedBrowsingDataCookieHelper( 83 CannedBrowsingDataCookieHelper::CannedBrowsingDataCookieHelper(
94 net::URLRequestContextGetter* request_context_getter) 84 net::URLRequestContextGetter* request_context_getter)
95 : BrowsingDataCookieHelper(request_context_getter) { 85 : BrowsingDataCookieHelper(request_context_getter) {
96 } 86 }
97 87
98 CannedBrowsingDataCookieHelper::~CannedBrowsingDataCookieHelper() { 88 CannedBrowsingDataCookieHelper::~CannedBrowsingDataCookieHelper() {
99 Reset(); 89 Reset();
100 } 90 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 125
136 size_t CannedBrowsingDataCookieHelper::GetCookieCount() const { 126 size_t CannedBrowsingDataCookieHelper::GetCookieCount() const {
137 size_t count = 0; 127 size_t count = 0;
138 for (const auto& pair : origin_cookie_set_map_) 128 for (const auto& pair : origin_cookie_set_map_)
139 count += pair.second->size(); 129 count += pair.second->size();
140 return count; 130 return count;
141 } 131 }
142 132
143 133
144 void CannedBrowsingDataCookieHelper::StartFetching( 134 void CannedBrowsingDataCookieHelper::StartFetching(
145 const net::CookieMonster::GetCookieListCallback& callback) { 135 const net::CookieStore::GetCookieListCallback& callback) {
146 DCHECK_CURRENTLY_ON(BrowserThread::UI); 136 DCHECK_CURRENTLY_ON(BrowserThread::UI);
147 net::CookieList cookie_list; 137 net::CookieList cookie_list;
148 for (const auto& pair : origin_cookie_set_map_) { 138 for (const auto& pair : origin_cookie_set_map_) {
149 cookie_list.insert(cookie_list.begin(), pair.second->begin(), 139 cookie_list.insert(cookie_list.begin(), pair.second->begin(),
150 pair.second->end()); 140 pair.second->end());
151 } 141 }
152 callback.Run(cookie_list); 142 callback.Run(cookie_list);
153 } 143 }
154 144
155 void CannedBrowsingDataCookieHelper::DeleteCookie( 145 void CannedBrowsingDataCookieHelper::DeleteCookie(
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 // TODO(markusheintz): A) Change the GetCookiesCount method to prevent 187 // TODO(markusheintz): A) Change the GetCookiesCount method to prevent
198 // counting cookies multiple times if they are stored in multiple cookie 188 // counting cookies multiple times if they are stored in multiple cookie
199 // sets. B) Replace the GetCookieFor method call below with: 189 // sets. B) Replace the GetCookieFor method call below with:
200 // "GetCookiesFor(frame_url.GetOrigin());" 190 // "GetCookiesFor(frame_url.GetOrigin());"
201 CR_DEFINE_STATIC_LOCAL(const GURL, origin_cookie_url, (kGlobalCookieSetURL)); 191 CR_DEFINE_STATIC_LOCAL(const GURL, origin_cookie_url, (kGlobalCookieSetURL));
202 canonical_cookie::CookieHashSet* cookie_set = 192 canonical_cookie::CookieHashSet* cookie_set =
203 GetCookiesFor(origin_cookie_url); 193 GetCookiesFor(origin_cookie_url);
204 DeleteMatchingCookie(cookie, cookie_set); 194 DeleteMatchingCookie(cookie, cookie_set);
205 cookie_set->insert(cookie); 195 cookie_set->insert(cookie);
206 } 196 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/browsing_data/mock_browsing_data_cookie_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698