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

Unified Diff: media/base/bind_to_current_loop.h

Issue 978923004: Use variadic template in media::BindToCurrentLoop() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Explain need to forward-declare TrampolineHelper Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | media/base/bind_to_current_loop.h.pump » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/bind_to_current_loop.h
diff --git a/media/base/bind_to_current_loop.h b/media/base/bind_to_current_loop.h
index 6461b1c9af9f5208f355bee96f6f7a48fe319144..cb3e28d4839641f3745684fc7757f87c3aa4cba9 100644
--- a/media/base/bind_to_current_loop.h
+++ b/media/base/bind_to_current_loop.h
@@ -1,9 +1,4 @@
-// This file was GENERATED by command:
-// pump.py bind_to_current_loop.h.pump
-// DO NOT EDIT BY HAND!!!
-
-
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -44,110 +39,22 @@ template <typename T>
base::internal::PassedWrapper<ScopedVector<T> > TrampolineForward(
ScopedVector<T>& p) { return base::Passed(&p); }
-template <typename T> struct TrampolineHelper;
-
-template <>
-struct TrampolineHelper<void()> {
- static void Run(
- const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
- const base::Callback<void()>& cb) {
- task_runner->PostTask(FROM_HERE, base::Bind(cb));
- }
-};
-
+// First, tell the compiler TrampolineHelper is a struct template with one
+// type parameter. Then define specializations where the type is a function
+// returning void and taking zero or more arguments.
+template <typename Sig> struct TrampolineHelper;
-template <typename A1>
-struct TrampolineHelper<void(A1)> {
+template <typename... Args>
+struct TrampolineHelper<void(Args...)> {
static void Run(
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
- const base::Callback<void(A1)>& cb, A1 a1) {
- task_runner->PostTask(FROM_HERE, base::Bind(cb,
- internal::TrampolineForward(a1)));
+ const base::Callback<void(Args...)>& cb,
+ Args... args) {
+ task_runner->PostTask(FROM_HERE,
+ base::Bind(cb, TrampolineForward(args)...));
}
};
-
-template <typename A1, typename A2>
-struct TrampolineHelper<void(A1, A2)> {
- static void Run(
- const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
- const base::Callback<void(A1, A2)>& cb, A1 a1, A2 a2) {
- task_runner->PostTask(FROM_HERE, base::Bind(cb,
- internal::TrampolineForward(a1), internal::TrampolineForward(a2)));
- }
-};
-
-
-template <typename A1, typename A2, typename A3>
-struct TrampolineHelper<void(A1, A2, A3)> {
- static void Run(
- const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
- const base::Callback<void(A1, A2, A3)>& cb, A1 a1, A2 a2, A3 a3) {
- task_runner->PostTask(FROM_HERE, base::Bind(cb,
- internal::TrampolineForward(a1), internal::TrampolineForward(a2),
- internal::TrampolineForward(a3)));
- }
-};
-
-
-template <typename A1, typename A2, typename A3, typename A4>
-struct TrampolineHelper<void(A1, A2, A3, A4)> {
- static void Run(
- const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
- const base::Callback<void(A1, A2, A3, A4)>& cb, A1 a1, A2 a2, A3 a3,
- A4 a4) {
- task_runner->PostTask(FROM_HERE, base::Bind(cb,
- internal::TrampolineForward(a1), internal::TrampolineForward(a2),
- internal::TrampolineForward(a3), internal::TrampolineForward(a4)));
- }
-};
-
-
-template <typename A1, typename A2, typename A3, typename A4, typename A5>
-struct TrampolineHelper<void(A1, A2, A3, A4, A5)> {
- static void Run(
- const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
- const base::Callback<void(A1, A2, A3, A4, A5)>& cb, A1 a1, A2 a2, A3 a3,
- A4 a4, A5 a5) {
- task_runner->PostTask(FROM_HERE, base::Bind(cb,
- internal::TrampolineForward(a1), internal::TrampolineForward(a2),
- internal::TrampolineForward(a3), internal::TrampolineForward(a4),
- internal::TrampolineForward(a5)));
- }
-};
-
-
-template <typename A1, typename A2, typename A3, typename A4, typename A5,
- typename A6>
-struct TrampolineHelper<void(A1, A2, A3, A4, A5, A6)> {
- static void Run(
- const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
- const base::Callback<void(A1, A2, A3, A4, A5, A6)>& cb, A1 a1, A2 a2,
- A3 a3, A4 a4, A5 a5, A6 a6) {
- task_runner->PostTask(FROM_HERE, base::Bind(cb,
- internal::TrampolineForward(a1), internal::TrampolineForward(a2),
- internal::TrampolineForward(a3), internal::TrampolineForward(a4),
- internal::TrampolineForward(a5), internal::TrampolineForward(a6)));
- }
-};
-
-
-template <typename A1, typename A2, typename A3, typename A4, typename A5,
- typename A6, typename A7>
-struct TrampolineHelper<void(A1, A2, A3, A4, A5, A6, A7)> {
- static void Run(
- const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
- const base::Callback<void(A1, A2, A3, A4, A5, A6, A7)>& cb, A1 a1, A2 a2,
- A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) {
- task_runner->PostTask(FROM_HERE, base::Bind(cb,
- internal::TrampolineForward(a1), internal::TrampolineForward(a2),
- internal::TrampolineForward(a3), internal::TrampolineForward(a4),
- internal::TrampolineForward(a5), internal::TrampolineForward(a6),
- internal::TrampolineForward(a7)));
- }
-};
-
-
} // namespace internal
template<typename T>
« no previous file with comments | « no previous file | media/base/bind_to_current_loop.h.pump » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698