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

Side by Side Diff: base/bind_internal.h

Issue 2145383002: Pass weak pointer by ref in Bind implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 BASE_BIND_INTERNAL_H_ 5 #ifndef BASE_BIND_INTERNAL_H_
6 #define BASE_BIND_INTERNAL_H_ 6 #define BASE_BIND_INTERNAL_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <tuple> 10 #include <tuple>
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 template <typename ReturnType> 288 template <typename ReturnType>
289 struct InvokeHelper<true, ReturnType> { 289 struct InvokeHelper<true, ReturnType> {
290 // WeakCalls are only supported for functions with a void return type. 290 // WeakCalls are only supported for functions with a void return type.
291 // Otherwise, the function result would be undefined if the the WeakPtr<> 291 // Otherwise, the function result would be undefined if the the WeakPtr<>
292 // is invalidated. 292 // is invalidated.
293 static_assert(std::is_void<ReturnType>::value, 293 static_assert(std::is_void<ReturnType>::value,
294 "weak_ptrs can only bind to methods without return values"); 294 "weak_ptrs can only bind to methods without return values");
295 295
296 template <typename Functor, typename BoundWeakPtr, typename... RunArgs> 296 template <typename Functor, typename BoundWeakPtr, typename... RunArgs>
297 static inline void MakeItSo(Functor&& functor, 297 static inline void MakeItSo(Functor&& functor,
298 BoundWeakPtr weak_ptr, 298 BoundWeakPtr&& weak_ptr,
299 RunArgs&&... args) { 299 RunArgs&&... args) {
300 if (!weak_ptr) 300 if (!weak_ptr)
301 return; 301 return;
302 using Traits = FunctorTraits<typename std::decay<Functor>::type>; 302 using Traits = FunctorTraits<typename std::decay<Functor>::type>;
303 Traits::Invoke(std::forward<Functor>(functor), 303 Traits::Invoke(std::forward<Functor>(functor),
304 std::forward<BoundWeakPtr>(weak_ptr), 304 std::forward<BoundWeakPtr>(weak_ptr),
305 std::forward<RunArgs>(args)...); 305 std::forward<RunArgs>(args)...);
306 } 306 }
307 }; 307 };
308 308
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 444
445 // Returns a RunType of bound functor. 445 // Returns a RunType of bound functor.
446 // E.g. MakeUnboundRunType<R(A, B, C), A, B> is evaluated to R(C). 446 // E.g. MakeUnboundRunType<R(A, B, C), A, B> is evaluated to R(C).
447 template <typename Functor, typename... BoundArgs> 447 template <typename Functor, typename... BoundArgs>
448 using MakeUnboundRunType = 448 using MakeUnboundRunType =
449 typename internal::MakeUnboundRunTypeImpl<Functor, BoundArgs...>::Type; 449 typename internal::MakeUnboundRunTypeImpl<Functor, BoundArgs...>::Type;
450 450
451 } // namespace base 451 } // namespace base
452 452
453 #endif // BASE_BIND_INTERNAL_H_ 453 #endif // BASE_BIND_INTERNAL_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698