Ban raw pointers to ref-counted types on base::Bind

base::Bind is intended to reject raw pointers to ref-counted types as
it's likely a bug. However, it has been regressed and failed to reject
the problematic pointers when it's passed as lvalue reference.

HasRefCountedTypeAsRawPtr requires a non reference type to check the
assertion statement, (e.g. requires `T*` rather than `T*&`).
In MakeBindStateTypeImpl in bind_internals.h, when a pointer type is
passed to base::Bind as an rvalue reference (e.g. `T*&&`), corresponding
BoundArgs item is a non-reference pointer type (e.g. `T*`) that passes the
unittest, however when it passed as an lvalue reference (e.g. `T*&`),
corresponding BoundArgs item is a reference to the pointer (e.g. `T*&`).
That causes the failure, and was not tested.

This CL fixes the compile-time assertion and fixes all banned usage of
base::Bind.

Bug: 737010
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: Ic3293746c22762f7900375b2cbb29ed5363a2d00
Reviewed-on: https://chromium-review.googlesource.com/549537
Commit-Queue: Taiju Tsuiki <tzik@chromium.org>
Reviewed-by: Sami Kyöstilä <skyostil@chromium.org>
Reviewed-by: Yuzhu Shen <yzshen@chromium.org>
Reviewed-by: danakj <danakj@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Luke Halliwell <halliwell@chromium.org>
Reviewed-by: Dale Curtis <dalecurtis@chromium.org>
Reviewed-by: Raymes Khoury <raymes@chromium.org>
Reviewed-by: Bernhard Bauer <bauerb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#483983}

CrOS-Libchrome-Original-Commit: 1d692a2e0d1b58e02760c9c94293a77ecb477440
diff --git a/base/bind_internal.h b/base/bind_internal.h
index c27c34f..5aab7f4 100644
--- a/base/bind_internal.h
+++ b/base/bind_internal.h
@@ -482,7 +482,8 @@
 
 template <typename Functor, typename... BoundArgs>
 struct MakeBindStateTypeImpl<false, Functor, BoundArgs...> {
-  static_assert(!HasRefCountedTypeAsRawPtr<BoundArgs...>::value,
+  static_assert(!HasRefCountedTypeAsRawPtr<
+                    typename std::decay<BoundArgs>::type...>::value,
                 "A parameter is a refcounted type and needs scoped_refptr.");
   using Type = BindState<typename std::decay<Functor>::type,
                          typename std::decay<BoundArgs>::type...>;
@@ -498,7 +499,8 @@
   static_assert(
       !std::is_array<typename std::remove_reference<Receiver>::type>::value,
       "First bound argument to a method cannot be an array.");
-  static_assert(!HasRefCountedTypeAsRawPtr<BoundArgs...>::value,
+  static_assert(!HasRefCountedTypeAsRawPtr<
+                    typename std::decay<BoundArgs>::type...>::value,
                 "A parameter is a refcounted type and needs scoped_refptr.");
 
  private: