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

Side by Side Diff: android_webview/browser/net/aw_cookie_store_wrapper.cc

Issue 2882063002: Add a SetCanonicalCookie method for CookieMonster. (Closed)
Patch Set: Fix AW cookie store wrapper. 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "android_webview/browser/net/aw_cookie_store_wrapper.h" 5 #include "android_webview/browser/net/aw_cookie_store_wrapper.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "android_webview/browser/net/init_native_callback.h" 9 #include "android_webview/browser/net/init_native_callback.h"
10 #include "base/memory/ref_counted_delete_on_sequence.h" 10 #include "base/memory/ref_counted_delete_on_sequence.h"
11 #include "base/threading/thread_task_runner_handle.h" 11 #include "base/threading/thread_task_runner_handle.h"
12 #include "url/gurl.h" 12 #include "url/gurl.h"
13 13
14 namespace android_webview { 14 namespace android_webview {
15 15
16 namespace { 16 namespace {
17 17
18 // Posts |task| to the thread that the global CookieStore lives on. 18 // Posts |task| to the thread that the global CookieStore lives on.
19 void PostTaskToCookieStoreTaskRunner(const base::Closure& task) { 19 void PostTaskToCookieStoreTaskRunner(base::OnceClosure task) {
20 GetCookieStoreTaskRunner()->PostTask(FROM_HERE, task); 20 GetCookieStoreTaskRunner()->PostTask(FROM_HERE, std::move(task));
21 } 21 }
22 22
23 // Wraps a subscription to cookie change notifications for the global 23 // Wraps a subscription to cookie change notifications for the global
24 // CookieStore for a consumer that lives on another thread. Handles passing 24 // CookieStore for a consumer that lives on another thread. Handles passing
25 // messages between thread, and destroys itself when the consumer unsubscribes. 25 // messages between thread, and destroys itself when the consumer unsubscribes.
26 // Must be created on the consumer's thread. Each instance only supports a 26 // Must be created on the consumer's thread. Each instance only supports a
27 // single subscription. 27 // single subscription.
28 class SubscriptionWrapper { 28 class SubscriptionWrapper {
29 public: 29 public:
30 SubscriptionWrapper() : weak_factory_(this) {} 30 SubscriptionWrapper() : weak_factory_(this) {}
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 bool secure, 121 bool secure,
122 bool http_only, 122 bool http_only,
123 net::CookieSameSite same_site, 123 net::CookieSameSite same_site,
124 net::CookiePriority priority, 124 net::CookiePriority priority,
125 const net::CookieStore::SetCookiesCallback& callback) { 125 const net::CookieStore::SetCookiesCallback& callback) {
126 GetCookieStore()->SetCookieWithDetailsAsync( 126 GetCookieStore()->SetCookieWithDetailsAsync(
127 url, name, value, domain, path, creation_time, expiration_time, 127 url, name, value, domain, path, creation_time, expiration_time,
128 last_access_time, secure, http_only, same_site, priority, callback); 128 last_access_time, secure, http_only, same_site, priority, callback);
129 } 129 }
130 130
131 void SetCanonicalCookieAsyncOnCookieThread(
132 std::unique_ptr<net::CanonicalCookie> cookie,
133 bool secure_source,
134 bool modify_http_only,
135 const net::CookieStore::SetCookiesCallback& callback) {
136 GetCookieStore()->SetCanonicalCookieAsync(std::move(cookie), secure_source,
137 modify_http_only, callback);
138 }
139
131 void GetCookiesWithOptionsAsyncOnCookieThread( 140 void GetCookiesWithOptionsAsyncOnCookieThread(
132 const GURL& url, 141 const GURL& url,
133 const net::CookieOptions& options, 142 const net::CookieOptions& options,
134 const net::CookieStore::GetCookiesCallback& callback) { 143 const net::CookieStore::GetCookiesCallback& callback) {
135 GetCookieStore()->GetCookiesWithOptionsAsync(url, options, callback); 144 GetCookieStore()->GetCookiesWithOptionsAsync(url, options, callback);
136 } 145 }
137 146
138 void GetCookieListWithOptionsAsyncOnCookieThread( 147 void GetCookieListWithOptionsAsyncOnCookieThread(
139 const GURL& url, 148 const GURL& url,
140 const net::CookieOptions& options, 149 const net::CookieOptions& options,
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 net::CookiePriority priority, 232 net::CookiePriority priority,
224 const SetCookiesCallback& callback) { 233 const SetCookiesCallback& callback) {
225 DCHECK(client_task_runner_->RunsTasksInCurrentSequence()); 234 DCHECK(client_task_runner_->RunsTasksInCurrentSequence());
226 PostTaskToCookieStoreTaskRunner( 235 PostTaskToCookieStoreTaskRunner(
227 base::Bind(&SetCookieWithDetailsAsyncOnCookieThread, url, name, value, 236 base::Bind(&SetCookieWithDetailsAsyncOnCookieThread, url, name, value,
228 domain, path, creation_time, expiration_time, last_access_time, 237 domain, path, creation_time, expiration_time, last_access_time,
229 secure, http_only, same_site, priority, 238 secure, http_only, same_site, priority,
230 CreateWrappedCallback<bool>(callback))); 239 CreateWrappedCallback<bool>(callback)));
231 } 240 }
232 241
242 void AwCookieStoreWrapper::SetCanonicalCookieAsync(
243 std::unique_ptr<net::CanonicalCookie> cookie,
244 bool secure_source,
245 bool modify_http_only,
246 const SetCookiesCallback& callback) {
247 DCHECK(client_task_runner_->RunsTasksOnCurrentThread());
248 PostTaskToCookieStoreTaskRunner(base::BindOnce(
249 &SetCanonicalCookieAsyncOnCookieThread, std::move(cookie), secure_source,
250 modify_http_only, CreateWrappedCallback<bool>(callback)));
251 }
252
233 void AwCookieStoreWrapper::GetCookiesWithOptionsAsync( 253 void AwCookieStoreWrapper::GetCookiesWithOptionsAsync(
234 const GURL& url, 254 const GURL& url,
235 const net::CookieOptions& options, 255 const net::CookieOptions& options,
236 const GetCookiesCallback& callback) { 256 const GetCookiesCallback& callback) {
237 DCHECK(client_task_runner_->RunsTasksInCurrentSequence()); 257 DCHECK(client_task_runner_->RunsTasksInCurrentSequence());
238 PostTaskToCookieStoreTaskRunner( 258 PostTaskToCookieStoreTaskRunner(
239 base::Bind(&GetCookiesWithOptionsAsyncOnCookieThread, url, options, 259 base::Bind(&GetCookiesWithOptionsAsyncOnCookieThread, url, options,
240 CreateWrappedCallback<const std::string&>(callback))); 260 CreateWrappedCallback<const std::string&>(callback)));
241 } 261 }
242 262
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 base::Bind(&AwCookieStoreWrapper::RunClosureCallback, 367 base::Bind(&AwCookieStoreWrapper::RunClosureCallback,
348 weak_factory_.GetWeakPtr(), callback)); 368 weak_factory_.GetWeakPtr(), callback));
349 } 369 }
350 370
351 void AwCookieStoreWrapper::RunClosureCallback(const base::Closure& callback) { 371 void AwCookieStoreWrapper::RunClosureCallback(const base::Closure& callback) {
352 DCHECK(client_task_runner_->RunsTasksInCurrentSequence()); 372 DCHECK(client_task_runner_->RunsTasksInCurrentSequence());
353 callback.Run(); 373 callback.Run();
354 } 374 }
355 375
356 } // namespace android_webview 376 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/browser/net/aw_cookie_store_wrapper.h ('k') | chrome/browser/extensions/api/cookies/cookies_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698