OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 COMPONENTS_LOGIN_BASE_SCREEN_HANDLER_UTILS_H_ | 5 #ifndef COMPONENTS_LOGIN_BASE_SCREEN_HANDLER_UTILS_H_ |
6 #define COMPONENTS_LOGIN_BASE_SCREEN_HANDLER_UTILS_H_ | 6 #define COMPONENTS_LOGIN_BASE_SCREEN_HANDLER_UTILS_H_ |
7 | 7 |
8 #include <cstddef> | 8 #include <cstddef> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 template <typename Arg, size_t index> | 63 template <typename Arg, size_t index> |
64 typename UnwrapConstRef<Arg>::Type ParseArg(const base::ListValue* args) { | 64 typename UnwrapConstRef<Arg>::Type ParseArg(const base::ListValue* args) { |
65 typename UnwrapConstRef<Arg>::Type parsed; | 65 typename UnwrapConstRef<Arg>::Type parsed; |
66 CHECK(GetArg(args, index, &parsed)); | 66 CHECK(GetArg(args, index, &parsed)); |
67 return parsed; | 67 return parsed; |
68 } | 68 } |
69 | 69 |
70 template <typename... Args, size_t... Ns> | 70 template <typename... Args, size_t... Ns> |
71 inline void DispatchToCallback(const base::Callback<void(Args...)>& callback, | 71 inline void DispatchToCallback(const base::Callback<void(Args...)>& callback, |
72 const base::ListValue* args, | 72 const base::ListValue* args, |
73 IndexSequence<Ns...> indexes) { | 73 base::IndexSequence<Ns...> indexes) { |
74 DCHECK(args); | 74 DCHECK(args); |
75 DCHECK_EQ(sizeof...(Args), args->GetSize()); | 75 DCHECK_EQ(sizeof...(Args), args->GetSize()); |
76 | 76 |
77 callback.Run(ParseArg<Args, Ns>(args)...); | 77 callback.Run(ParseArg<Args, Ns>(args)...); |
78 } | 78 } |
79 | 79 |
80 template <typename... Args> | 80 template <typename... Args> |
81 void CallbackWrapper(const base::Callback<void(Args...)>& callback, | 81 void CallbackWrapper(const base::Callback<void(Args...)>& callback, |
82 const base::ListValue* args) { | 82 const base::ListValue* args) { |
83 DispatchToCallback(callback, args, MakeIndexSequence<sizeof...(Args)>()); | 83 DispatchToCallback(callback, args, |
| 84 base::MakeIndexSequence<sizeof...(Args)>()); |
84 } | 85 } |
85 | 86 |
86 | 87 |
87 } // namespace login | 88 } // namespace login |
88 | 89 |
89 #endif // COMPONENTS_LOGIN_BASE_SCREEN_HANDLER_UTILS_H_ | 90 #endif // COMPONENTS_LOGIN_BASE_SCREEN_HANDLER_UTILS_H_ |
OLD | NEW |