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

Side by Side Diff: net/cookies/cookie_store_test_helpers.cc

Issue 2937963003: Shift cookie system callbacks to OnceCallback to impedance match mojo. (Closed)
Patch Set: Finish Merge Created 3 years, 6 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
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 "net/cookies/cookie_store_test_helpers.h" 5 #include "net/cookies/cookie_store_test_helpers.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 void DelayedCookieMonster::GetCookieListWithOptionsInternalCallback( 55 void DelayedCookieMonster::GetCookieListWithOptionsInternalCallback(
56 const CookieList& cookie_list) { 56 const CookieList& cookie_list) {
57 cookie_list_ = cookie_list; 57 cookie_list_ = cookie_list;
58 did_run_ = true; 58 did_run_ = true;
59 } 59 }
60 60
61 void DelayedCookieMonster::SetCookieWithOptionsAsync( 61 void DelayedCookieMonster::SetCookieWithOptionsAsync(
62 const GURL& url, 62 const GURL& url,
63 const std::string& cookie_line, 63 const std::string& cookie_line,
64 const CookieOptions& options, 64 const CookieOptions& options,
65 const CookieMonster::SetCookiesCallback& callback) { 65 CookieMonster::SetCookiesCallback callback) {
66 did_run_ = false; 66 did_run_ = false;
67 cookie_monster_->SetCookieWithOptionsAsync( 67 cookie_monster_->SetCookieWithOptionsAsync(
68 url, cookie_line, options, 68 url, cookie_line, options,
69 base::Bind(&DelayedCookieMonster::SetCookiesInternalCallback, 69 base::Bind(&DelayedCookieMonster::SetCookiesInternalCallback,
70 base::Unretained(this))); 70 base::Unretained(this)));
71 DCHECK_EQ(did_run_, true); 71 DCHECK_EQ(did_run_, true);
72 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 72 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
73 FROM_HERE, base::Bind(&DelayedCookieMonster::InvokeSetCookiesCallback, 73 FROM_HERE,
74 base::Unretained(this), callback), 74 base::BindOnce(&DelayedCookieMonster::InvokeSetCookiesCallback,
75 base::Unretained(this), std::move(callback)),
75 base::TimeDelta::FromMilliseconds(kDelayedTime)); 76 base::TimeDelta::FromMilliseconds(kDelayedTime));
76 } 77 }
77 78
78 void DelayedCookieMonster::SetCookieWithDetailsAsync( 79 void DelayedCookieMonster::SetCookieWithDetailsAsync(
79 const GURL& url, 80 const GURL& url,
80 const std::string& name, 81 const std::string& name,
81 const std::string& value, 82 const std::string& value,
82 const std::string& domain, 83 const std::string& domain,
83 const std::string& path, 84 const std::string& path,
84 base::Time creation_time, 85 base::Time creation_time,
85 base::Time expiration_time, 86 base::Time expiration_time,
86 base::Time last_access_time, 87 base::Time last_access_time,
87 bool secure, 88 bool secure,
88 bool http_only, 89 bool http_only,
89 CookieSameSite same_site, 90 CookieSameSite same_site,
90 CookiePriority priority, 91 CookiePriority priority,
91 const SetCookiesCallback& callback) { 92 SetCookiesCallback callback) {
92 NOTREACHED(); 93 NOTREACHED();
93 } 94 }
94 95
95 void DelayedCookieMonster::SetCanonicalCookieAsync( 96 void DelayedCookieMonster::SetCanonicalCookieAsync(
96 std::unique_ptr<CanonicalCookie> cookie, 97 std::unique_ptr<CanonicalCookie> cookie,
97 bool secure_source, 98 bool secure_source,
98 bool modify_http_only, 99 bool modify_http_only,
99 const SetCookiesCallback& callback) { 100 SetCookiesCallback callback) {
100 NOTREACHED(); 101 NOTREACHED();
101 } 102 }
102 103
103 void DelayedCookieMonster::GetCookiesWithOptionsAsync( 104 void DelayedCookieMonster::GetCookiesWithOptionsAsync(
104 const GURL& url, 105 const GURL& url,
105 const CookieOptions& options, 106 const CookieOptions& options,
106 const CookieMonster::GetCookiesCallback& callback) { 107 CookieMonster::GetCookiesCallback callback) {
107 did_run_ = false; 108 did_run_ = false;
108 cookie_monster_->GetCookiesWithOptionsAsync( 109 cookie_monster_->GetCookiesWithOptionsAsync(
109 url, options, 110 url, options,
110 base::Bind(&DelayedCookieMonster::GetCookiesWithOptionsInternalCallback, 111 base::Bind(&DelayedCookieMonster::GetCookiesWithOptionsInternalCallback,
111 base::Unretained(this))); 112 base::Unretained(this)));
112 DCHECK_EQ(did_run_, true); 113 DCHECK_EQ(did_run_, true);
113 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 114 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
114 FROM_HERE, 115 FROM_HERE,
115 base::Bind(&DelayedCookieMonster::InvokeGetCookieStringCallback, 116 base::BindOnce(&DelayedCookieMonster::InvokeGetCookieStringCallback,
116 base::Unretained(this), callback), 117 base::Unretained(this), std::move(callback)),
117 base::TimeDelta::FromMilliseconds(kDelayedTime)); 118 base::TimeDelta::FromMilliseconds(kDelayedTime));
118 } 119 }
119 120
120 void DelayedCookieMonster::GetCookieListWithOptionsAsync( 121 void DelayedCookieMonster::GetCookieListWithOptionsAsync(
121 const GURL& url, 122 const GURL& url,
122 const CookieOptions& options, 123 const CookieOptions& options,
123 const CookieMonster::GetCookieListCallback& callback) { 124 CookieMonster::GetCookieListCallback callback) {
124 did_run_ = false; 125 did_run_ = false;
125 cookie_monster_->GetCookieListWithOptionsAsync( 126 cookie_monster_->GetCookieListWithOptionsAsync(
126 url, options, 127 url, options,
127 base::Bind( 128 base::Bind(
128 &DelayedCookieMonster::GetCookieListWithOptionsInternalCallback, 129 &DelayedCookieMonster::GetCookieListWithOptionsInternalCallback,
129 base::Unretained(this))); 130 base::Unretained(this)));
130 DCHECK_EQ(did_run_, true); 131 DCHECK_EQ(did_run_, true);
131 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 132 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
132 FROM_HERE, base::Bind(&DelayedCookieMonster::InvokeGetCookieListCallback, 133 FROM_HERE,
133 base::Unretained(this), callback), 134 base::BindOnce(&DelayedCookieMonster::InvokeGetCookieListCallback,
135 base::Unretained(this), std::move(callback)),
134 base::TimeDelta::FromMilliseconds(kDelayedTime)); 136 base::TimeDelta::FromMilliseconds(kDelayedTime));
135 } 137 }
136 138
137 void DelayedCookieMonster::GetAllCookiesAsync( 139 void DelayedCookieMonster::GetAllCookiesAsync(GetCookieListCallback callback) {
138 const GetCookieListCallback& callback) { 140 cookie_monster_->GetAllCookiesAsync(std::move(callback));
139 cookie_monster_->GetAllCookiesAsync(callback);
140 } 141 }
141 142
142 void DelayedCookieMonster::InvokeSetCookiesCallback( 143 void DelayedCookieMonster::InvokeSetCookiesCallback(
143 const CookieMonster::SetCookiesCallback& callback) { 144 CookieMonster::SetCookiesCallback callback) {
144 if (!callback.is_null()) 145 if (!callback.is_null())
145 callback.Run(result_); 146 std::move(callback).Run(result_);
146 } 147 }
147 148
148 void DelayedCookieMonster::InvokeGetCookieStringCallback( 149 void DelayedCookieMonster::InvokeGetCookieStringCallback(
149 const CookieMonster::GetCookiesCallback& callback) { 150 CookieMonster::GetCookiesCallback callback) {
150 if (!callback.is_null()) 151 if (!callback.is_null())
151 callback.Run(cookie_); 152 std::move(callback).Run(cookie_);
152 } 153 }
153 154
154 void DelayedCookieMonster::InvokeGetCookieListCallback( 155 void DelayedCookieMonster::InvokeGetCookieListCallback(
155 const CookieMonster::GetCookieListCallback& callback) { 156 CookieMonster::GetCookieListCallback callback) {
156 if (!callback.is_null()) 157 if (!callback.is_null())
157 callback.Run(cookie_list_); 158 std::move(callback).Run(cookie_list_);
158 } 159 }
159 160
160 bool DelayedCookieMonster::SetCookieWithOptions( 161 bool DelayedCookieMonster::SetCookieWithOptions(
161 const GURL& url, 162 const GURL& url,
162 const std::string& cookie_line, 163 const std::string& cookie_line,
163 const CookieOptions& options) { 164 const CookieOptions& options) {
164 ADD_FAILURE(); 165 ADD_FAILURE();
165 return false; 166 return false;
166 } 167 }
167 168
168 std::string DelayedCookieMonster::GetCookiesWithOptions( 169 std::string DelayedCookieMonster::GetCookiesWithOptions(
169 const GURL& url, 170 const GURL& url,
170 const CookieOptions& options) { 171 const CookieOptions& options) {
171 ADD_FAILURE(); 172 ADD_FAILURE();
172 return std::string(); 173 return std::string();
173 } 174 }
174 175
175 void DelayedCookieMonster::DeleteCookie(const GURL& url, 176 void DelayedCookieMonster::DeleteCookie(const GURL& url,
176 const std::string& cookie_name) { 177 const std::string& cookie_name) {
177 ADD_FAILURE(); 178 ADD_FAILURE();
178 } 179 }
179 180
180 void DelayedCookieMonster::DeleteCookieAsync(const GURL& url, 181 void DelayedCookieMonster::DeleteCookieAsync(const GURL& url,
181 const std::string& cookie_name, 182 const std::string& cookie_name,
182 const base::Closure& callback) { 183 base::OnceClosure callback) {
183 ADD_FAILURE(); 184 ADD_FAILURE();
184 } 185 }
185 186
186 void DelayedCookieMonster::DeleteCanonicalCookieAsync( 187 void DelayedCookieMonster::DeleteCanonicalCookieAsync(
187 const CanonicalCookie& cookie, 188 const CanonicalCookie& cookie,
188 const DeleteCallback& callback) { 189 DeleteCallback callback) {
189 ADD_FAILURE(); 190 ADD_FAILURE();
190 } 191 }
191 192
192 void DelayedCookieMonster::DeleteAllCreatedBetweenAsync( 193 void DelayedCookieMonster::DeleteAllCreatedBetweenAsync(
193 const base::Time& delete_begin, 194 const base::Time& delete_begin,
194 const base::Time& delete_end, 195 const base::Time& delete_end,
195 const DeleteCallback& callback) { 196 DeleteCallback callback) {
196 ADD_FAILURE(); 197 ADD_FAILURE();
197 } 198 }
198 199
199 void DelayedCookieMonster::DeleteAllCreatedBetweenWithPredicateAsync( 200 void DelayedCookieMonster::DeleteAllCreatedBetweenWithPredicateAsync(
200 const base::Time& delete_begin, 201 const base::Time& delete_begin,
201 const base::Time& delete_end, 202 const base::Time& delete_end,
202 const base::Callback<bool(const CanonicalCookie&)>& predicate, 203 const base::Callback<bool(const CanonicalCookie&)>& predicate,
203 const DeleteCallback& callback) { 204 DeleteCallback callback) {
204 ADD_FAILURE(); 205 ADD_FAILURE();
205 } 206 }
206 207
207 void DelayedCookieMonster::DeleteSessionCookiesAsync(const DeleteCallback&) { 208 void DelayedCookieMonster::DeleteSessionCookiesAsync(DeleteCallback) {
208 ADD_FAILURE(); 209 ADD_FAILURE();
209 } 210 }
210 211
211 void DelayedCookieMonster::FlushStore(const base::Closure& callback) { 212 void DelayedCookieMonster::FlushStore(base::OnceClosure callback) {
212 ADD_FAILURE(); 213 ADD_FAILURE();
213 } 214 }
214 215
215 std::unique_ptr<CookieStore::CookieChangedSubscription> 216 std::unique_ptr<CookieStore::CookieChangedSubscription>
216 DelayedCookieMonster::AddCallbackForCookie( 217 DelayedCookieMonster::AddCallbackForCookie(
217 const GURL& url, 218 const GURL& url,
218 const std::string& name, 219 const std::string& name,
219 const CookieChangedCallback& callback) { 220 const CookieChangedCallback& callback) {
220 ADD_FAILURE(); 221 ADD_FAILURE();
221 return std::unique_ptr<CookieStore::CookieChangedSubscription>(); 222 return std::unique_ptr<CookieStore::CookieChangedSubscription>();
(...skipping 18 matching lines...) Expand all
240 241
241 std::string CookieURLHelper::Format(const std::string& format_string) const { 242 std::string CookieURLHelper::Format(const std::string& format_string) const {
242 std::string new_string = format_string; 243 std::string new_string = format_string;
243 base::ReplaceSubstringsAfterOffset(&new_string, 0, "%D", 244 base::ReplaceSubstringsAfterOffset(&new_string, 0, "%D",
244 domain_and_registry_); 245 domain_and_registry_);
245 base::ReplaceSubstringsAfterOffset(&new_string, 0, "%R", registry_); 246 base::ReplaceSubstringsAfterOffset(&new_string, 0, "%R", registry_);
246 return new_string; 247 return new_string;
247 } 248 }
248 249
249 } // namespace net 250 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698