| 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 22 matching lines...) Expand all Loading... |
| 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 bool have_result() const { return have_result_; } | 41 bool have_result() const { return have_result_; } |
| 42 | 42 |
| 43 private: | |
| 44 virtual void RunWithParams(const Tuple1<int>& params) { | 43 virtual void RunWithParams(const Tuple1<int>& params) { |
| 45 result_ = params.a; | 44 result_ = params.a; |
| 46 have_result_ = true; | 45 have_result_ = true; |
| 47 if (waiting_for_result_) | 46 if (waiting_for_result_) |
| 48 MessageLoop::current()->Quit(); | 47 MessageLoop::current()->Quit(); |
| 49 } | 48 } |
| 50 | 49 |
| 50 private: |
| 51 int result_; | 51 int result_; |
| 52 bool have_result_; | 52 bool have_result_; |
| 53 bool waiting_for_result_; | 53 bool waiting_for_result_; |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 #endif // NET_BASE_TEST_COMPLETION_CALLBACK_H_ | 56 #endif // NET_BASE_TEST_COMPLETION_CALLBACK_H_ |
| OLD | NEW |