OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_CALLBACK_HELPER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_CALLBACK_HELPER_H_ |
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_CALLBACK_HELPER_H_ | 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_CALLBACK_HELPER_H_ |
7 | 7 |
| 8 #include <type_traits> |
| 9 |
8 #include "base/bind.h" | 10 #include "base/bind.h" |
9 #include "base/location.h" | 11 #include "base/location.h" |
10 #include "base/logging.h" | 12 #include "base/logging.h" |
11 #include "base/sequenced_task_runner.h" | 13 #include "base/sequenced_task_runner.h" |
12 #include "base/thread_task_runner_handle.h" | 14 #include "base/thread_task_runner_handle.h" |
13 | 15 |
14 // TODO(tzik): Merge this file to media/base/bind_to_current_loop.h. | 16 // TODO(tzik): Merge this file to media/base/bind_to_current_loop.h. |
15 | 17 |
16 namespace sync_file_system { | 18 namespace sync_file_system { |
17 namespace drive_backend { | 19 namespace drive_backend { |
18 | 20 |
19 namespace internal { | 21 namespace internal { |
20 | 22 |
21 template <typename T> | 23 template <typename T> |
22 typename base::enable_if< | 24 typename std::enable_if<base::internal::IsMoveOnlyType<T>::value, |
23 base::internal::IsMoveOnlyType<T>::value, | 25 base::internal::PassedWrapper<T>>::type |
24 base::internal::PassedWrapper<T> >::type | |
25 RebindForward(T& t) { | 26 RebindForward(T& t) { |
26 return base::Passed(&t); | 27 return base::Passed(&t); |
27 } | 28 } |
28 | 29 |
29 template <typename T> | 30 template <typename T> |
30 typename base::enable_if< | 31 typename std::enable_if<!base::internal::IsMoveOnlyType<T>::value, T&>::type |
31 !base::internal::IsMoveOnlyType<T>::value, | |
32 T&>::type | |
33 RebindForward(T& t) { | 32 RebindForward(T& t) { |
34 return t; | 33 return t; |
35 } | 34 } |
36 | 35 |
37 template <typename T> | 36 template <typename T> |
38 class CallbackHolder { | 37 class CallbackHolder { |
39 public: | 38 public: |
40 CallbackHolder(const scoped_refptr<base::SequencedTaskRunner>& task_runner, | 39 CallbackHolder(const scoped_refptr<base::SequencedTaskRunner>& task_runner, |
41 const tracked_objects::Location& from_here, | 40 const tracked_objects::Location& from_here, |
42 const base::Callback<T>& callback) | 41 const base::Callback<T>& callback) |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 const base::Callback<T>& callback) { | 99 const base::Callback<T>& callback) { |
101 return RelayCallbackToTaskRunner( | 100 return RelayCallbackToTaskRunner( |
102 base::ThreadTaskRunnerHandle::Get(), | 101 base::ThreadTaskRunnerHandle::Get(), |
103 from_here, callback); | 102 from_here, callback); |
104 } | 103 } |
105 | 104 |
106 } // namespace drive_backend | 105 } // namespace drive_backend |
107 } // namespace sync_file_system | 106 } // namespace sync_file_system |
108 | 107 |
109 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_CALLBACK_HELPER_H_ | 108 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_CALLBACK_HELPER_H_ |
OLD | NEW |