Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Unified Diff: net/base/test_completion_callback.h

Issue 9949011: Make FileStream::Seek async and add FileStream::SeekSync for sync operation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/mock_file_stream.cc ('k') | net/base/test_completion_callback.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/test_completion_callback.h
diff --git a/net/base/test_completion_callback.h b/net/base/test_completion_callback.h
index 1519e10e573cfc67e381da4396fd3e44556f6672..25c96766b1775d2a3feb9e0b2820ad3365495809 100644
--- a/net/base/test_completion_callback.h
+++ b/net/base/test_completion_callback.h
@@ -9,6 +9,7 @@
#include "base/compiler_specific.h"
#include "base/tuple.h"
#include "net/base/completion_callback.h"
+#include "net/base/net_errors.h"
//-----------------------------------------------------------------------------
// completion callback helper
@@ -22,26 +23,62 @@
// reason, this class is probably not ideal for a general application.
//
-// Base class overridden by custom implementations of TestCompletionCallback.
-class TestCompletionCallbackBase {
+namespace net {
+
+namespace internal {
+
+class TestCompletionCallbackBaseInternal {
public:
- void SetResult(int result);
- int WaitForResult();
- int GetResult(int result);
bool have_result() const { return have_result_; }
protected:
- TestCompletionCallbackBase();
+ TestCompletionCallbackBaseInternal();
+ void DidSetResult();
+ void WaitForResult();
- int result_;
bool have_result_;
bool waiting_for_result_;
private:
- DISALLOW_COPY_AND_ASSIGN(TestCompletionCallbackBase);
+ DISALLOW_COPY_AND_ASSIGN(TestCompletionCallbackBaseInternal);
};
-namespace net {
+template <typename R>
+class TestCompletionCallbackTemplate
+ : public TestCompletionCallbackBaseInternal {
+ public:
+ void SetResult(R result) {
+ result_ = result;
+ DidSetResult();
+ }
+
+ R WaitForResult() {
+ TestCompletionCallbackBaseInternal::WaitForResult();
+ return result_;
+ }
+
+ R GetResult(R result) {
+ if (net::ERR_IO_PENDING != result)
+ return result;
+ return WaitForResult();
+ }
+
+ protected:
+ TestCompletionCallbackTemplate() : result_(R()) {}
+ R result_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(TestCompletionCallbackTemplate);
+};
+
+} // namespace internal
+
+// Base class overridden by custom implementations of TestCompletionCallback.
+typedef internal::TestCompletionCallbackTemplate<int>
+ TestCompletionCallbackBase;
+
+typedef internal::TestCompletionCallbackTemplate<int64>
+ TestInt64CompletionCallbackBase;
class TestCompletionCallback : public TestCompletionCallbackBase {
public:
@@ -56,6 +93,19 @@ class TestCompletionCallback : public TestCompletionCallbackBase {
DISALLOW_COPY_AND_ASSIGN(TestCompletionCallback);
};
+class TestInt64CompletionCallback : public TestInt64CompletionCallbackBase {
+ public:
+ TestInt64CompletionCallback();
+ ~TestInt64CompletionCallback();
+
+ const Int64CompletionCallback& callback() const { return callback_; }
+
+ private:
+ const Int64CompletionCallback callback_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestInt64CompletionCallback);
+};
+
} // namespace net
#endif // NET_BASE_TEST_COMPLETION_CALLBACK_H_
« no previous file with comments | « net/base/mock_file_stream.cc ('k') | net/base/test_completion_callback.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698