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

Unified Diff: chrome/browser/sync_file_system/sync_file_system_test_util.cc

Issue 24140003: [SyncFS] Add generic result reciever (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: reupload Created 7 years, 3 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 | « chrome/browser/sync_file_system/sync_file_system_test_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync_file_system/sync_file_system_test_util.cc
diff --git a/chrome/browser/sync_file_system/sync_file_system_test_util.cc b/chrome/browser/sync_file_system/sync_file_system_test_util.cc
index 20f6bd65e7e054dd559b44df9d5cbf1d55868411..4c05f1bf4a59ef0913186fffc3df6f9a7afb981f 100644
--- a/chrome/browser/sync_file_system/sync_file_system_test_util.cc
+++ b/chrome/browser/sync_file_system/sync_file_system_test_util.cc
@@ -9,14 +9,21 @@
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread.h"
+#include "chrome/browser/google_apis/gdata_errorcode.h"
+#include "chrome/browser/sync_file_system/drive_backend/metadata_database.h"
#include "chrome/browser/sync_file_system/sync_status_code.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/test/test_utils.h"
+#include "testing/gtest/include/gtest/gtest.h"
using content::BrowserThread;
namespace sync_file_system {
+namespace drive_backend {
+class MetadataDatabase;
+} // drive_backend
+
template <typename R>
void AssignAndQuit(base::RunLoop* run_loop, R* result_out, R result) {
DCHECK(result_out);
@@ -30,8 +37,53 @@ AssignAndQuitCallback(base::RunLoop* run_loop, R* result) {
return base::Bind(&AssignAndQuit<R>, run_loop, base::Unretained(result));
}
+template <typename Arg>
+void ReceiveResult1(bool* done, Arg* arg_out, Arg arg) {
+ EXPECT_FALSE(*done);
+ *done = true;
+ *arg_out = base::internal::CallbackForward(arg);
+}
+
+template <typename Arg1, typename Arg2>
+void ReceiveResult2(bool* done,
+ Arg1* arg1_out,
+ Arg2* arg2_out,
+ Arg1 arg1,
+ Arg2 arg2) {
+ EXPECT_FALSE(*done);
+ *done = true;
+ *arg1_out = base::internal::CallbackForward(arg1);
+ *arg2_out = base::internal::CallbackForward(arg2);
+}
+
+template <typename Arg>
+base::Callback<void(Arg)> CreateResultReceiver(Arg* arg_out) {
+ return base::Bind(&ReceiveResult1<Arg>,
+ base::Owned(new bool(false)), arg_out);
+}
+
+template <typename Arg1, typename Arg2>
+base::Callback<void(Arg1, Arg2)> CreateResultReceiver(Arg1* arg1_out,
+ Arg2* arg2_out) {
+ return base::Bind(&ReceiveResult2<Arg1, Arg2>,
+ base::Owned(new bool(false)),
+ arg1_out, arg2_out);
+}
+
// Instantiate versions we know callers will need.
template base::Callback<void(SyncStatusCode)>
AssignAndQuitCallback(base::RunLoop*, SyncStatusCode*);
+#define INSTANTIATE_RECEIVER(type) \
+ template base::Callback<void(type)> CreateResultReceiver(type*);
+INSTANTIATE_RECEIVER(SyncStatusCode);
+INSTANTIATE_RECEIVER(google_apis::GDataErrorCode);
+#undef INSTANTIATE_RECEIVER
+
+#define INSTANTIATE_RECEIVER(type1, type2) \
+ template base::Callback<void(type1, scoped_ptr<type2>)> \
+ CreateResultReceiver(type1*, scoped_ptr<type2>*)
+INSTANTIATE_RECEIVER(SyncStatusCode, drive_backend::MetadataDatabase);
+#undef INSTANTIATE_RECEIVER
+
} // namespace sync_file_system
« no previous file with comments | « chrome/browser/sync_file_system/sync_file_system_test_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698