| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/native/cookie_manager.h" | 5 #include "android_webview/native/cookie_manager.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 // To execute a CookieTask synchronously you must arrange for Signal to be | 259 // To execute a CookieTask synchronously you must arrange for Signal to be |
| 260 // called on the waitable event at some point. You can call the bool or int | 260 // called on the waitable event at some point. You can call the bool or int |
| 261 // versions of ExecCookieTaskSync, these will supply the caller with a dummy | 261 // versions of ExecCookieTaskSync, these will supply the caller with a dummy |
| 262 // callback which takes an int/bool, throws it away and calls Signal. | 262 // callback which takes an int/bool, throws it away and calls Signal. |
| 263 // Alternatively you can call the version which supplies a Closure in which | 263 // Alternatively you can call the version which supplies a Closure in which |
| 264 // case you must call Run on it when you want the unblock the calling code. | 264 // case you must call Run on it when you want the unblock the calling code. |
| 265 // | 265 // |
| 266 // Ignore a bool callback. | 266 // Ignore a bool callback. |
| 267 void CookieManager::ExecCookieTaskSync( | 267 void CookieManager::ExecCookieTaskSync( |
| 268 const base::Callback<void(BoolCallback)>& task) { | 268 const base::Callback<void(BoolCallback)>& task) { |
| 269 WaitableEvent completion(false, false); | 269 WaitableEvent completion(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 270 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 270 ExecCookieTask( | 271 ExecCookieTask( |
| 271 base::Bind(task, BoolCallbackAdapter(SignalEventClosure(&completion)))); | 272 base::Bind(task, BoolCallbackAdapter(SignalEventClosure(&completion)))); |
| 272 ScopedAllowWaitForLegacyWebViewApi wait; | 273 ScopedAllowWaitForLegacyWebViewApi wait; |
| 273 completion.Wait(); | 274 completion.Wait(); |
| 274 } | 275 } |
| 275 | 276 |
| 276 // Ignore an int callback. | 277 // Ignore an int callback. |
| 277 void CookieManager::ExecCookieTaskSync( | 278 void CookieManager::ExecCookieTaskSync( |
| 278 const base::Callback<void(IntCallback)>& task) { | 279 const base::Callback<void(IntCallback)>& task) { |
| 279 WaitableEvent completion(false, false); | 280 WaitableEvent completion(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 281 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 280 ExecCookieTask( | 282 ExecCookieTask( |
| 281 base::Bind(task, IntCallbackAdapter(SignalEventClosure(&completion)))); | 283 base::Bind(task, IntCallbackAdapter(SignalEventClosure(&completion)))); |
| 282 ScopedAllowWaitForLegacyWebViewApi wait; | 284 ScopedAllowWaitForLegacyWebViewApi wait; |
| 283 completion.Wait(); | 285 completion.Wait(); |
| 284 } | 286 } |
| 285 | 287 |
| 286 // Call the supplied closure when you want to signal that the blocked code can | 288 // Call the supplied closure when you want to signal that the blocked code can |
| 287 // continue. | 289 // continue. |
| 288 void CookieManager::ExecCookieTaskSync( | 290 void CookieManager::ExecCookieTaskSync( |
| 289 const base::Callback<void(base::Closure)>& task) { | 291 const base::Callback<void(base::Closure)>& task) { |
| 290 WaitableEvent completion(false, false); | 292 WaitableEvent completion(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 293 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 291 ExecCookieTask(base::Bind(task, SignalEventClosure(&completion))); | 294 ExecCookieTask(base::Bind(task, SignalEventClosure(&completion))); |
| 292 ScopedAllowWaitForLegacyWebViewApi wait; | 295 ScopedAllowWaitForLegacyWebViewApi wait; |
| 293 completion.Wait(); | 296 completion.Wait(); |
| 294 } | 297 } |
| 295 | 298 |
| 296 // Executes the |task| using |cookie_store_task_runner_|. | 299 // Executes the |task| using |cookie_store_task_runner_|. |
| 297 void CookieManager::ExecCookieTask(const base::Closure& task) { | 300 void CookieManager::ExecCookieTask(const base::Closure& task) { |
| 298 cookie_store_task_runner_->PostTask(FROM_HERE, task); | 301 cookie_store_task_runner_->PostTask(FROM_HERE, task); |
| 299 } | 302 } |
| 300 | 303 |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 | 618 |
| 616 net::CookieStore* GetCookieStore() { | 619 net::CookieStore* GetCookieStore() { |
| 617 return CookieManager::GetInstance()->GetCookieStore(); | 620 return CookieManager::GetInstance()->GetCookieStore(); |
| 618 } | 621 } |
| 619 | 622 |
| 620 bool RegisterCookieManager(JNIEnv* env) { | 623 bool RegisterCookieManager(JNIEnv* env) { |
| 621 return RegisterNativesImpl(env); | 624 return RegisterNativesImpl(env); |
| 622 } | 625 } |
| 623 | 626 |
| 624 } // android_webview namespace | 627 } // android_webview namespace |
| OLD | NEW |