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(); |
| - private: |
| int result_; |
| bool have_result_; |
| bool waiting_for_result_; |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(TestCompletionCallbackBase); |
| +}; |
|
csilv
2011/12/06 00:56:08
This is a pretty cool approach, although when we r
James Hawkins
2011/12/06 17:25:12
I don't think so; see the use of this base class t
|
| + |
| +class TestOldCompletionCallback : public TestCompletionCallbackBase, |
| + public CallbackRunner< Tuple1<int> > { |
| + public: |
| + TestOldCompletionCallback() {}; |
| + 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(); |
| - 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 |