Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / sync_file_system / sync_file_system_test_util.cc
blob1c285e83f32224343f1572d74ce05adc53bfd37e
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
3 // found in the LICENSE file.
5 #include "chrome/browser/sync_file_system/sync_file_system_test_util.h"
7 #include "base/run_loop.h"
8 #include "chrome/browser/sync_file_system/sync_status_code.h"
9 #include "content/public/test/test_utils.h"
10 #include "google_apis/drive/gdata_errorcode.h"
12 using content::BrowserThread;
14 namespace sync_file_system {
16 namespace drive_backend {
17 class MetadataDatabase;
18 } // drive_backend
20 template <typename R>
21 void AssignAndQuit(base::RunLoop* run_loop, R* result_out, R result) {
22 DCHECK(result_out);
23 DCHECK(run_loop);
24 *result_out = result;
25 run_loop->Quit();
28 template <typename R> base::Callback<void(R)>
29 AssignAndQuitCallback(base::RunLoop* run_loop, R* result) {
30 return base::Bind(&AssignAndQuit<R>, run_loop, base::Unretained(result));
33 template <typename Arg, typename Param>
34 void ReceiveResult1(bool* done, Arg* arg_out, Param arg) {
35 EXPECT_FALSE(*done);
36 *done = true;
37 *arg_out = base::internal::CallbackForward(arg);
40 template <typename Arg>
41 base::Callback<void(typename TypeTraits<Arg>::ParamType)>
42 CreateResultReceiver(Arg* arg_out) {
43 typedef typename TypeTraits<Arg>::ParamType Param;
44 return base::Bind(&ReceiveResult1<Arg, Param>,
45 base::Owned(new bool(false)), arg_out);
48 // Instantiate versions we know callers will need.
49 template base::Callback<void(SyncStatusCode)>
50 AssignAndQuitCallback(base::RunLoop*, SyncStatusCode*);
52 #define INSTANTIATE_RECEIVER(type) \
53 template base::Callback<void(type)> CreateResultReceiver(type*);
54 INSTANTIATE_RECEIVER(SyncStatusCode);
55 INSTANTIATE_RECEIVER(google_apis::GDataErrorCode);
56 #undef INSTANTIATE_RECEIVER
58 } // namespace sync_file_system