Skip to content

Commit

Permalink
Support smart pointers in base::DispatchToMethod
Browse files Browse the repository at this point in the history
* Make base::DispatchToMethod to accept smart pointers as the this pointer
* Remove base::internal::UnwrapTraits from //storage code

BUG=554299

Review URL: https://codereview.chromium.org/1696093002

Cr-Commit-Position: refs/heads/master@{#375516}
  • Loading branch information
tzik authored and Commit bot committed Feb 16, 2016
1 parent 26d7fdb commit 1ea87e3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
8 changes: 4 additions & 4 deletions base/tuple.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,15 @@ inline Tuple<Ts&...> MakeRefTuple(Ts&... arg) {
// Non-Static Dispatchers with no out params.

template <typename ObjT, typename Method, typename... Ts, size_t... Ns>
inline void DispatchToMethodImpl(ObjT* obj,
inline void DispatchToMethodImpl(const ObjT& obj,
Method method,
const Tuple<Ts...>& arg,
IndexSequence<Ns...>) {
(obj->*method)(base::internal::UnwrapTraits<Ts>::Unwrap(get<Ns>(arg))...);
}

template <typename ObjT, typename Method, typename... Ts>
inline void DispatchToMethod(ObjT* obj,
inline void DispatchToMethod(const ObjT& obj,
Method method,
const Tuple<Ts...>& arg) {
DispatchToMethodImpl(obj, method, arg, MakeIndexSequence<sizeof...(Ts)>());
Expand Down Expand Up @@ -232,7 +232,7 @@ template <typename ObjT,
typename... OutTs,
size_t... InNs,
size_t... OutNs>
inline void DispatchToMethodImpl(ObjT* obj,
inline void DispatchToMethodImpl(const ObjT& obj,
Method method,
const Tuple<InTs...>& in,
Tuple<OutTs...>* out,
Expand All @@ -243,7 +243,7 @@ inline void DispatchToMethodImpl(ObjT* obj,
}

template <typename ObjT, typename Method, typename... InTs, typename... OutTs>
inline void DispatchToMethod(ObjT* obj,
inline void DispatchToMethod(const ObjT& obj,
Method method,
const Tuple<InTs...>& in,
Tuple<OutTs...>* out) {
Expand Down
6 changes: 2 additions & 4 deletions storage/browser/fileapi/task_runner_bound_observer_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace storage {
// A wrapper for dispatching method.
template <class T, class Method, class Params>
void NotifyWrapper(T obj, Method m, const Params& p) {
base::DispatchToMethod(base::internal::UnwrapTraits<T>::Unwrap(obj), m, p);
base::DispatchToMethod(obj, m, p);
}

// An observer list helper to notify on a given task runner.
Expand Down Expand Up @@ -69,7 +69,7 @@ class TaskRunnerBoundObserverList {
for (typename ObserversListMap::const_iterator it = observers_.begin();
it != observers_.end(); ++it) {
if (!it->second.get() || it->second->RunsTasksOnCurrentThread()) {
base::DispatchToMethod(UnwrapTraits::Unwrap(it->first), method, params);
base::DispatchToMethod(it->first, method, params);
continue;
}
it->second->PostTask(
Expand All @@ -80,8 +80,6 @@ class TaskRunnerBoundObserverList {
}

private:
typedef base::internal::UnwrapTraits<ObserverStoreType> UnwrapTraits;

ObserversListMap observers_;
};

Expand Down

0 comments on commit 1ea87e3

Please sign in to comment.