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

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

Issue 408153003: Simplify RunTaskOnThread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix FileCacheTest Created 6 years, 5 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
11 namespace google_apis { 11 namespace google_apis {
12 12
13 // Runs task on a thread on which |task_runner| may run tasks. 13 // Runs the task with the task runner.
14 void RunTaskOnThread(scoped_refptr<base::SequencedTaskRunner> task_runner, 14 void RunTaskWithTaskRunner(scoped_refptr<base::TaskRunner> task_runner,
15 const base::Closure& task); 15 const base::Closure& task);
16 16
17 namespace internal { 17 namespace internal {
18 18
19 // Implementation of the composed callback, whose signature is |Sig|. 19 // Implementation of the composed callback, whose signature is |Sig|.
20 template<typename Sig> struct ComposedCallback; 20 template<typename Sig> struct ComposedCallback;
21 21
22 // ComposedCallback with no argument. 22 // ComposedCallback with no argument.
23 template<> 23 template<>
24 struct ComposedCallback<void()> { 24 struct ComposedCallback<void()> {
25 static void Run( 25 static void Run(
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 DCHECK(!callback.is_null()); 109 DCHECK(!callback.is_null());
110 return base::Bind( 110 return base::Bind(
111 &internal::ComposedCallback<typename CallbackType::RunType>::Run, 111 &internal::ComposedCallback<typename CallbackType::RunType>::Run,
112 runner, callback); 112 runner, callback);
113 } 113 }
114 114
115 // Returns callback which runs the given |callback| on the current thread. 115 // Returns callback which runs the given |callback| on the current thread.
116 template<typename CallbackType> 116 template<typename CallbackType>
117 CallbackType CreateRelayCallback(const CallbackType& callback) { 117 CallbackType CreateRelayCallback(const CallbackType& callback) {
118 return CreateComposedCallback( 118 return CreateComposedCallback(
119 base::Bind(&RunTaskOnThread, base::MessageLoopProxy::current()), 119 base::Bind(&RunTaskWithTaskRunner, base::MessageLoopProxy::current()),
120 callback); 120 callback);
121 } 121 }
122 122
123 } // namespace google_apis 123 } // namespace google_apis
124 124
125 #endif // GOOGLE_APIS_DRIVE_TASK_UTIL_H_ 125 #endif // GOOGLE_APIS_DRIVE_TASK_UTIL_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/fileapi/async_file_util.cc ('k') | google_apis/drive/task_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698