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

Side by Side Diff: google_apis/drive/task_util.h

Issue 214363002: drive: Return cancel closure from FileSystem::GetFileContent (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 GOOGLE_APIS_DRIVE_TASK_UTIL_H_ 5 #ifndef GOOGLE_APIS_DRIVE_TASK_UTIL_H_
6 #define GOOGLE_APIS_DRIVE_TASK_UTIL_H_ 6 #define GOOGLE_APIS_DRIVE_TASK_UTIL_H_
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 10
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 template<typename T1, typename T2, typename T3, typename T4> 88 template<typename T1, typename T2, typename T3, typename T4>
89 struct ComposedCallback<void(T1, T2, T3, T4)> { 89 struct ComposedCallback<void(T1, T2, T3, T4)> {
90 static void Run( 90 static void Run(
91 const base::Callback<void(const base::Closure&)>& runner, 91 const base::Callback<void(const base::Closure&)>& runner,
92 const base::Callback<void(T1, T2, T3, T4)>& callback, 92 const base::Callback<void(T1, T2, T3, T4)>& callback,
93 T1 arg1, T2 arg2, T3 arg3, T4 arg4) { 93 T1 arg1, T2 arg2, T3 arg3, T4 arg4) {
94 runner.Run(base::Bind(callback, arg1, arg2, arg3, arg4)); 94 runner.Run(base::Bind(callback, arg1, arg2, arg3, arg4));
95 } 95 }
96 }; 96 };
97 97
98 // ComposedCallback with four arguments, and the second one is scoped_ptr.
99 template<typename T1, typename T2, typename D2, typename T3, typename T4>
100 struct ComposedCallback<void(T1, scoped_ptr<T2, D2>, T3, T4)> {
101 static void Run(
102 const base::Callback<void(const base::Closure&)>& runner,
103 const base::Callback<void(T1, scoped_ptr<T2, D2>, T3, T4)>& callback,
104 T1 arg1, scoped_ptr<T2, D2> arg2, T3 arg3, T4 arg4) {
105 runner.Run(base::Bind(callback, arg1, base::Passed(&arg2), arg3, arg4));
106 }
107 };
108
109 } // namespace internal 98 } // namespace internal
110 99
111 // Returns callback that takes arguments (arg1, arg2, ...), create a closure 100 // Returns callback that takes arguments (arg1, arg2, ...), create a closure
112 // by binding them to |callback|, and runs |runner| with the closure. 101 // by binding them to |callback|, and runs |runner| with the closure.
113 // I.e. the returned callback works as follows: 102 // I.e. the returned callback works as follows:
114 // runner.Run(Bind(callback, arg1, arg2, ...)) 103 // runner.Run(Bind(callback, arg1, arg2, ...))
115 template<typename CallbackType> 104 template<typename CallbackType>
116 CallbackType CreateComposedCallback( 105 CallbackType CreateComposedCallback(
117 const base::Callback<void(const base::Closure&)>& runner, 106 const base::Callback<void(const base::Closure&)>& runner,
118 const CallbackType& callback) { 107 const CallbackType& callback) {
119 DCHECK(!runner.is_null()); 108 DCHECK(!runner.is_null());
120 DCHECK(!callback.is_null()); 109 DCHECK(!callback.is_null());
121 return base::Bind( 110 return base::Bind(
122 &internal::ComposedCallback<typename CallbackType::RunType>::Run, 111 &internal::ComposedCallback<typename CallbackType::RunType>::Run,
123 runner, callback); 112 runner, callback);
124 } 113 }
125 114
126 // Returns callback which runs the given |callback| on the current thread. 115 // Returns callback which runs the given |callback| on the current thread.
127 template<typename CallbackType> 116 template<typename CallbackType>
128 CallbackType CreateRelayCallback(const CallbackType& callback) { 117 CallbackType CreateRelayCallback(const CallbackType& callback) {
129 return CreateComposedCallback( 118 return CreateComposedCallback(
130 base::Bind(&RunTaskOnThread, base::MessageLoopProxy::current()), 119 base::Bind(&RunTaskOnThread, base::MessageLoopProxy::current()),
131 callback); 120 callback);
132 } 121 }
133 122
134 } // namespace google_apis 123 } // namespace google_apis
135 124
136 #endif // GOOGLE_APIS_DRIVE_TASK_UTIL_H_ 125 #endif // GOOGLE_APIS_DRIVE_TASK_UTIL_H_
OLDNEW
« chrome/browser/chromeos/drive/file_system_interface.h ('K') | « chrome/chrome_tests_unit.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698