Chromium Code Reviews| Index: net/base/test_completion_callback.h |
| diff --git a/net/base/test_completion_callback.h b/net/base/test_completion_callback.h |
| index a192194955d83921f49ec974d3a75a4cd34bea28..888c61026519dc6f7666bd1d30c7d5be35d7981e 100644 |
| --- a/net/base/test_completion_callback.h |
| +++ b/net/base/test_completion_callback.h |
| @@ -22,45 +22,51 @@ |
| // there could be other side-effects resulting from WaitForResult. For this |
| // reason, this class is probably not ideal for a general application. |
| // |
| -class TestOldCompletionCallback : public CallbackRunner< Tuple1<int> > { |
| - public: |
| - TestOldCompletionCallback(); |
| - virtual ~TestOldCompletionCallback(); |
| +// Base class overridden by custom implementations of TestCompletionCallback. |
| +class TestCompletionCallbackBase { |
| + public: |
| + void SetResult(int result); |
| int WaitForResult(); |
| - |
| int GetResult(int result); |
| - |
| bool have_result() const { return have_result_; } |
| - virtual void RunWithParams(const Tuple1<int>& params) OVERRIDE; |
| + protected: |
| + TestCompletionCallbackBase(); |
|
awong
2011/12/08 22:35:11
Declare an out-of-line destructor.
|
| - private: |
| int result_; |
| bool have_result_; |
| bool waiting_for_result_; |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(TestCompletionCallbackBase); |
| +}; |
| + |
| +class TestOldCompletionCallback : public TestCompletionCallbackBase, |
| + public CallbackRunner< Tuple1<int> > { |
| + public: |
| + TestOldCompletionCallback() {}; |
|
awong
2011/12/08 22:35:11
Should out-of-line these constructors/destructors.
|
| + virtual ~TestOldCompletionCallback() {} |
| + |
| + virtual void RunWithParams(const Tuple1<int>& params) OVERRIDE; |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(TestOldCompletionCallback); |
| }; |
| namespace net { |
| -class TestCompletionCallback { |
| +class TestCompletionCallback : public TestCompletionCallbackBase { |
| public: |
| TestCompletionCallback(); |
| ~TestCompletionCallback(); |
|
awong
2011/12/08 22:35:11
virtual.
|
| - int WaitForResult() { return old_callback_impl_.WaitForResult(); } |
| - |
| - int GetResult(int result) { return old_callback_impl_.GetResult(result); } |
| - |
| - bool have_result() const { return old_callback_impl_.have_result(); } |
| - |
| const CompletionCallback& callback() const { return callback_; } |
| private: |
| - void OnComplete(int result); |
| - |
| const CompletionCallback callback_; |
| - TestOldCompletionCallback old_callback_impl_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(TestCompletionCallback); |
| }; |
| } // namespace net |