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 #ifndef CHROME_BROWSER_ANDROID_PROVIDER_BLOCKING_UI_THREAD_ASYNC_REQUEST_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_PROVIDER_BLOCKING_UI_THREAD_ASYNC_REQUEST_H_ |
6 #define CHROME_BROWSER_ANDROID_PROVIDER_BLOCKING_UI_THREAD_ASYNC_REQUEST_H_ | 6 #define CHROME_BROWSER_ANDROID_PROVIDER_BLOCKING_UI_THREAD_ASYNC_REQUEST_H_ |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/macros.h" |
10 #include "base/synchronization/waitable_event.h" | 11 #include "base/synchronization/waitable_event.h" |
11 #include "chrome/browser/android/provider/run_on_ui_thread_blocking.h" | 12 #include "chrome/browser/android/provider/run_on_ui_thread_blocking.h" |
12 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
13 | 14 |
14 // Allows making async requests and blocking the current thread until the | 15 // Allows making async requests and blocking the current thread until the |
15 // response arrives. The request is performed in the UI thread. | 16 // response arrives. The request is performed in the UI thread. |
16 // Users of this class MUST call RequestCompleted when receiving the response. | 17 // Users of this class MUST call RequestCompleted when receiving the response. |
17 // Cannot be called directly from the UI thread. | 18 // Cannot be called directly from the UI thread. |
18 class BlockingUIThreadAsyncRequest { | 19 class BlockingUIThreadAsyncRequest { |
19 public: | 20 public: |
(...skipping 26 matching lines...) Expand all Loading... |
46 static void RunRequestOnUIThread(base::Callback<Signature> request) { | 47 static void RunRequestOnUIThread(base::Callback<Signature> request) { |
47 request.Run(); | 48 request.Run(); |
48 } | 49 } |
49 | 50 |
50 base::WaitableEvent request_completed_; | 51 base::WaitableEvent request_completed_; |
51 | 52 |
52 DISALLOW_COPY_AND_ASSIGN(BlockingUIThreadAsyncRequest); | 53 DISALLOW_COPY_AND_ASSIGN(BlockingUIThreadAsyncRequest); |
53 }; | 54 }; |
54 | 55 |
55 #endif // CHROME_BROWSER_ANDROID_PROVIDER_BLOCKING_UI_THREAD_ASYNC_REQUEST_H_ | 56 #endif // CHROME_BROWSER_ANDROID_PROVIDER_BLOCKING_UI_THREAD_ASYNC_REQUEST_H_ |
OLD | NEW |