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

Side by Side Diff: base/bind_internal.h

Issue 2048023004: Introduce base::IsWeakReceiver for base::Bind to support external weak pointers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: +comment Created 4 years, 6 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
« base/bind_helpers.h ('K') | « base/bind_helpers.h ('k') | 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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 std::forward<Runnable>(runnable).Run(std::forward<RunArgs>(args)...); 312 std::forward<Runnable>(runnable).Run(std::forward<RunArgs>(args)...);
313 } 313 }
314 }; 314 };
315 315
316 template <> 316 template <>
317 struct InvokeHelper<true, void> { 317 struct InvokeHelper<true, void> {
318 template <typename Runnable, typename BoundWeakPtr, typename... RunArgs> 318 template <typename Runnable, typename BoundWeakPtr, typename... RunArgs>
319 static void MakeItSo(Runnable&& runnable, 319 static void MakeItSo(Runnable&& runnable,
320 BoundWeakPtr weak_ptr, 320 BoundWeakPtr weak_ptr,
321 RunArgs&&... args) { 321 RunArgs&&... args) {
322 if (!weak_ptr.get()) { 322 if (!weak_ptr) {
323 return; 323 return;
324 } 324 }
325 std::forward<Runnable>(runnable).Run( 325 std::forward<Runnable>(runnable).Run(
326 weak_ptr.get(), std::forward<RunArgs>(args)...); 326 weak_ptr, std::forward<RunArgs>(args)...);
danakj 2016/06/10 23:36:18 I had to look at a bunch of places to understand w
tzik 2016/06/14 12:06:10 Done.
327 } 327 }
328 }; 328 };
329 329
330 #if !defined(_MSC_VER) 330 #if !defined(_MSC_VER)
331 331
332 template <typename ReturnType> 332 template <typename ReturnType>
333 struct InvokeHelper<true, ReturnType> { 333 struct InvokeHelper<true, ReturnType> {
334 // WeakCalls are only supported for functions with a void return type. 334 // WeakCalls are only supported for functions with a void return type.
335 // Otherwise, the function result would be undefined if the the WeakPtr<> 335 // Otherwise, the function result would be undefined if the the WeakPtr<>
336 // is invalidated. 336 // is invalidated.
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 437
438 static void Destroy(BindStateBase* self) { 438 static void Destroy(BindStateBase* self) {
439 delete static_cast<BindState*>(self); 439 delete static_cast<BindState*>(self);
440 } 440 }
441 }; 441 };
442 442
443 } // namespace internal 443 } // namespace internal
444 } // namespace base 444 } // namespace base
445 445
446 #endif // BASE_BIND_INTERNAL_H_ 446 #endif // BASE_BIND_INTERNAL_H_
OLDNEW
« base/bind_helpers.h ('K') | « base/bind_helpers.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698