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 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/callback.h" | |
8 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
9 #include "base/tuple.h" | 10 #include "base/tuple.h" |
10 #include "net/base/completion_callback.h" | 11 #include "net/base/completion_callback.h" |
11 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
12 | 13 |
13 //----------------------------------------------------------------------------- | 14 //----------------------------------------------------------------------------- |
14 // completion callback helper | 15 // completion callback helper |
15 | 16 |
16 // A helper class for completion callbacks, designed to make it easy to run | 17 // A helper class for completion callbacks, designed to make it easy to run |
17 // tests involving asynchronous operations. Just call WaitForResult to wait | 18 // tests involving asynchronous operations. Just call WaitForResult to wait |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 | 71 |
71 TestCompletionCallbackTemplate() : result_(R()) {} | 72 TestCompletionCallbackTemplate() : result_(R()) {} |
72 R result_; | 73 R result_; |
73 | 74 |
74 private: | 75 private: |
75 DISALLOW_COPY_AND_ASSIGN(TestCompletionCallbackTemplate); | 76 DISALLOW_COPY_AND_ASSIGN(TestCompletionCallbackTemplate); |
76 }; | 77 }; |
77 | 78 |
78 } // namespace internal | 79 } // namespace internal |
79 | 80 |
81 class TestClosureCallback | |
82 : public internal::TestCompletionCallbackBaseInternal { | |
83 public: | |
84 TestClosureCallback(); | |
85 ~TestClosureCallback(); | |
jkarlin
2014/11/03 19:17:59
virtual override
gavinp
2014/11/03 22:54:48
Sure. I have to update a bunch of base classes; bu
| |
86 | |
87 using internal::TestCompletionCallbackBaseInternal::WaitForResult; | |
jkarlin
2014/11/03 19:17:59
Why is this necessary?
gavinp
2014/11/03 22:54:48
Because TestCompletionCallbackBaseInternal::WaitFo
| |
88 | |
89 const base::Closure& callback() const { return callback_; } | |
90 | |
91 private: | |
92 const base::Closure callback_; | |
93 | |
94 DISALLOW_COPY_AND_ASSIGN(TestClosureCallback); | |
95 }; | |
96 | |
80 // Base class overridden by custom implementations of TestCompletionCallback. | 97 // Base class overridden by custom implementations of TestCompletionCallback. |
81 typedef internal::TestCompletionCallbackTemplate<int> | 98 typedef internal::TestCompletionCallbackTemplate<int> |
82 TestCompletionCallbackBase; | 99 TestCompletionCallbackBase; |
83 | 100 |
84 typedef internal::TestCompletionCallbackTemplate<int64> | 101 typedef internal::TestCompletionCallbackTemplate<int64> |
85 TestInt64CompletionCallbackBase; | 102 TestInt64CompletionCallbackBase; |
86 | 103 |
87 class TestCompletionCallback : public TestCompletionCallbackBase { | 104 class TestCompletionCallback : public TestCompletionCallbackBase { |
88 public: | 105 public: |
89 TestCompletionCallback(); | 106 TestCompletionCallback(); |
(...skipping 29 matching lines...) Expand all Loading... | |
119 private: | 136 private: |
120 void SetResult(int result) override; | 137 void SetResult(int result) override; |
121 | 138 |
122 IOBuffer* buffer_; | 139 IOBuffer* buffer_; |
123 DISALLOW_COPY_AND_ASSIGN(ReleaseBufferCompletionCallback); | 140 DISALLOW_COPY_AND_ASSIGN(ReleaseBufferCompletionCallback); |
124 }; | 141 }; |
125 | 142 |
126 } // namespace net | 143 } // namespace net |
127 | 144 |
128 #endif // NET_BASE_TEST_COMPLETION_CALLBACK_H_ | 145 #endif // NET_BASE_TEST_COMPLETION_CALLBACK_H_ |
OLD | NEW |