OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 NET_BASE_TEST_COMPLETION_CALLBACK_H_ | 5 #ifndef NET_BASE_TEST_COMPLETION_CALLBACK_H_ |
6 #define NET_BASE_TEST_COMPLETION_CALLBACK_H_ | 6 #define NET_BASE_TEST_COMPLETION_CALLBACK_H_ |
7 | 7 |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "net/base/completion_callback.h" | 9 #include "net/base/completion_callback.h" |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... |
31 DCHECK(!waiting_for_result_); | 31 DCHECK(!waiting_for_result_); |
32 while (!have_result_) { | 32 while (!have_result_) { |
33 waiting_for_result_ = true; | 33 waiting_for_result_ = true; |
34 MessageLoop::current()->Run(); | 34 MessageLoop::current()->Run(); |
35 waiting_for_result_ = false; | 35 waiting_for_result_ = false; |
36 } | 36 } |
37 have_result_ = false; // auto-reset for next callback | 37 have_result_ = false; // auto-reset for next callback |
38 return result_; | 38 return result_; |
39 } | 39 } |
40 | 40 |
| 41 private: |
41 virtual void RunWithParams(const Tuple1<int>& params) { | 42 virtual void RunWithParams(const Tuple1<int>& params) { |
42 result_ = params.a; | 43 result_ = params.a; |
43 have_result_ = true; | 44 have_result_ = true; |
44 if (waiting_for_result_) | 45 if (waiting_for_result_) |
45 MessageLoop::current()->Quit(); | 46 MessageLoop::current()->Quit(); |
46 } | 47 } |
47 | 48 |
48 private: | |
49 int result_; | 49 int result_; |
50 bool have_result_; | 50 bool have_result_; |
51 bool waiting_for_result_; | 51 bool waiting_for_result_; |
52 }; | 52 }; |
53 | 53 |
54 #endif // NET_BASE_TEST_COMPLETION_CALLBACK_H_ | 54 #endif // NET_BASE_TEST_COMPLETION_CALLBACK_H_ |
OLD | NEW |