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 "content/public/test/browser_test_utils.h" | 5 #include "content/public/test/browser_test_utils.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
807 do { | 807 do { |
808 if (!message_queue.WaitForMessage(&message)) | 808 if (!message_queue.WaitForMessage(&message)) |
809 return false; | 809 return false; |
810 } while (message.compare("\"PENDING\"") == 0); | 810 } while (message.compare("\"PENDING\"") == 0); |
811 | 811 |
812 return message.compare("\"SUCCESS\"") == 0; | 812 return message.compare("\"SUCCESS\"") == 0; |
813 } | 813 } |
814 | 814 |
815 std::string GetCookies(BrowserContext* browser_context, const GURL& url) { | 815 std::string GetCookies(BrowserContext* browser_context, const GURL& url) { |
816 std::string cookies; | 816 std::string cookies; |
817 base::WaitableEvent event(true, false); | 817 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::MANUAL, |
| 818 base::WaitableEvent::InitialState::NOT_SIGNALED); |
818 net::URLRequestContextGetter* context_getter = | 819 net::URLRequestContextGetter* context_getter = |
819 BrowserContext::GetDefaultStoragePartition(browser_context)-> | 820 BrowserContext::GetDefaultStoragePartition(browser_context)-> |
820 GetURLRequestContext(); | 821 GetURLRequestContext(); |
821 | 822 |
822 BrowserThread::PostTask( | 823 BrowserThread::PostTask( |
823 BrowserThread::IO, FROM_HERE, | 824 BrowserThread::IO, FROM_HERE, |
824 base::Bind(&GetCookiesOnIOThread, url, base::RetainedRef(context_getter), | 825 base::Bind(&GetCookiesOnIOThread, url, base::RetainedRef(context_getter), |
825 &event, &cookies)); | 826 &event, &cookies)); |
826 event.Wait(); | 827 event.Wait(); |
827 return cookies; | 828 return cookies; |
828 } | 829 } |
829 | 830 |
830 bool SetCookie(BrowserContext* browser_context, | 831 bool SetCookie(BrowserContext* browser_context, |
831 const GURL& url, | 832 const GURL& url, |
832 const std::string& value) { | 833 const std::string& value) { |
833 bool result = false; | 834 bool result = false; |
834 base::WaitableEvent event(true, false); | 835 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::MANUAL, |
| 836 base::WaitableEvent::InitialState::NOT_SIGNALED); |
835 net::URLRequestContextGetter* context_getter = | 837 net::URLRequestContextGetter* context_getter = |
836 BrowserContext::GetDefaultStoragePartition(browser_context)-> | 838 BrowserContext::GetDefaultStoragePartition(browser_context)-> |
837 GetURLRequestContext(); | 839 GetURLRequestContext(); |
838 | 840 |
839 BrowserThread::PostTask( | 841 BrowserThread::PostTask( |
840 BrowserThread::IO, FROM_HERE, | 842 BrowserThread::IO, FROM_HERE, |
841 base::Bind(&SetCookieOnIOThread, url, value, | 843 base::Bind(&SetCookieOnIOThread, url, value, |
842 base::RetainedRef(context_getter), &event, &result)); | 844 base::RetainedRef(context_getter), &event, &result)); |
843 event.Wait(); | 845 event.Wait(); |
844 return result; | 846 return result; |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1255 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1257 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1256 if (ack_result_ != INPUT_EVENT_ACK_STATE_UNKNOWN) | 1258 if (ack_result_ != INPUT_EVENT_ACK_STATE_UNKNOWN) |
1257 return ack_result_; | 1259 return ack_result_; |
1258 base::RunLoop run_loop; | 1260 base::RunLoop run_loop; |
1259 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure()); | 1261 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure()); |
1260 run_loop.Run(); | 1262 run_loop.Run(); |
1261 return ack_result_; | 1263 return ack_result_; |
1262 } | 1264 } |
1263 | 1265 |
1264 } // namespace content | 1266 } // namespace content |
OLD | NEW |