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

Unified Diff: ipc/ipc_message_templates.h

Issue 2481093003: Introduce ResourceRequesterInfo to abstract the requester of resource request (Closed)
Patch Set: incorporated mmemke's comment Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: ipc/ipc_message_templates.h
diff --git a/ipc/ipc_message_templates.h b/ipc/ipc_message_templates.h
index f5c28cca4a68978b3b5794d12a9d5e7108726eee..c0108596e2718ca847426d4008cb716b1bc650ef 100644
--- a/ipc/ipc_message_templates.h
+++ b/ipc/ipc_message_templates.h
@@ -52,6 +52,58 @@ DispatchToMethod(ObjT* obj,
base::MakeIndexSequence<sizeof...(Ts)>());
}
+// This function is for all the sync IPCs that don't pass an extra parameter
+// using IPC_BEGIN_MESSAGE_MAP_WITH_PARAM.
+template <typename ObjT,
+ typename Method,
+ typename P,
+ typename Tuple,
+ typename ReplyParam>
+void DispatchToSyncMethod(ObjT* obj,
+ Method method,
+ P*,
+ const Tuple& tuple,
+ ReplyParam* reply) {
+ base::DispatchToMethod(obj, method, tuple, reply);
+}
+
+template <typename ObjT,
+ typename Method,
+ typename P,
+ typename InTuple,
+ typename OutTuple,
+ size_t... InNs,
+ size_t... OutNs>
+inline void DispatchToSyncMethodImpl(const ObjT& obj,
+ Method method,
+ P* parameter,
+ InTuple&& in,
+ OutTuple* out,
+ base::IndexSequence<InNs...>,
+ base::IndexSequence<OutNs...>) {
+ (obj->*method)(parameter, base::get<InNs>(std::forward<InTuple>(in))...,
+ &std::get<OutNs>(*out)...);
+}
+
+// The following function is for sync IPCs which have a dispatcher with an
+// extra parameter specified using IPC_BEGIN_MESSAGE_MAP_WITH_PARAM.
+template <typename ObjT,
+ typename P,
+ typename... Args,
+ typename... InParam,
+ typename... OutParam>
+typename std::enable_if<sizeof...(Args) ==
+ sizeof...(InParam) + sizeof...(OutParam)>::type
+DispatchToSyncMethod(ObjT* obj,
+ void (ObjT::*method)(P*, Args...),
+ P* parameter,
+ const std::tuple<InParam...>& in,
+ std::tuple<OutParam...>* out) {
+ DispatchToSyncMethodImpl(obj, method, parameter, in, out,
+ base::MakeIndexSequence<sizeof...(InParam)>(),
+ base::MakeIndexSequence<sizeof...(OutParam)>());
+}
+
enum class MessageKind {
CONTROL,
ROUTED,
@@ -170,7 +222,7 @@ class MessageT<Meta, std::tuple<Ins...>, std::tuple<Outs...>>
Message* reply = SyncMessage::GenerateReply(msg);
if (ok) {
ReplyParam reply_params;
- base::DispatchToMethod(obj, func, send_params, &reply_params);
+ DispatchToSyncMethod(obj, func, parameter, send_params, &reply_params);
WriteParam(reply, reply_params);
LogReplyParamsToMessage(reply_params, msg);
} else {
@@ -193,7 +245,7 @@ class MessageT<Meta, std::tuple<Ins...>, std::tuple<Outs...>>
if (ok) {
std::tuple<Message&> t = std::tie(*reply);
ConnectMessageAndReply(msg, reply);
- base::DispatchToMethod(obj, func, send_params, &t);
+ DispatchToSyncMethod(obj, func, parameter, send_params, &t);
} else {
NOTREACHED() << "Error deserializing message " << msg->type();
reply->set_reply_error();

Powered by Google App Engine
This is Rietveld 408576698