| 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 <memory> | 8 #include <memory> |
| 9 #include <type_traits> | 9 #include <type_traits> |
| 10 | 10 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 59 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
| 60 const tracked_objects::Location from_here_; | 60 const tracked_objects::Location from_here_; |
| 61 std::unique_ptr<base::Callback<T>> callback_; | 61 std::unique_ptr<base::Callback<T>> callback_; |
| 62 | 62 |
| 63 DISALLOW_COPY_AND_ASSIGN(CallbackHolder); | 63 DISALLOW_COPY_AND_ASSIGN(CallbackHolder); |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 template <typename> | 66 template <typename> |
| 67 struct RelayToTaskRunnerHelper; | 67 struct RelayToTaskRunnerHelper; |
| 68 | 68 |
| 69 template <> |
| 70 struct RelayToTaskRunnerHelper<void()> { |
| 71 static void Run(CallbackHolder<void()>* holder) { |
| 72 holder->task_runner()->PostTask(holder->from_here(), holder->callback()); |
| 73 } |
| 74 }; |
| 75 |
| 69 template <typename... Args> | 76 template <typename... Args> |
| 70 struct RelayToTaskRunnerHelper<void(Args...)> { | 77 struct RelayToTaskRunnerHelper<void(Args...)> { |
| 71 static void Run(CallbackHolder<void(Args...)>* holder, Args... args) { | 78 static void Run(CallbackHolder<void(Args...)>* holder, Args... args) { |
| 72 holder->task_runner()->PostTask( | 79 holder->task_runner()->PostTask( |
| 73 holder->from_here(), | 80 holder->from_here(), |
| 74 base::Bind(holder->callback(), RebindForward(args)...)); | 81 base::Bind(holder->callback(), RebindForward(args)...)); |
| 75 } | 82 } |
| 76 }; | 83 }; |
| 77 | 84 |
| 78 } // namespace internal | 85 } // namespace internal |
| (...skipping 19 matching lines...) Expand all Loading... |
| 98 const base::Callback<T>& callback) { | 105 const base::Callback<T>& callback) { |
| 99 return RelayCallbackToTaskRunner( | 106 return RelayCallbackToTaskRunner( |
| 100 base::ThreadTaskRunnerHandle::Get(), | 107 base::ThreadTaskRunnerHandle::Get(), |
| 101 from_here, callback); | 108 from_here, callback); |
| 102 } | 109 } |
| 103 | 110 |
| 104 } // namespace drive_backend | 111 } // namespace drive_backend |
| 105 } // namespace sync_file_system | 112 } // namespace sync_file_system |
| 106 | 113 |
| 107 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_CALLBACK_HELPER_H_ | 114 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_CALLBACK_HELPER_H_ |
| OLD | NEW |