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

Side by Side Diff: ipc/ipc_message_templates.h

Issue 1833573002: Move TRACE_EVENT in IPC message dispatch to add message name (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@only_thread_name
Patch Set: Remove patch deppendency. Created 4 years, 8 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 | « ipc/ipc_channel_proxy.cc ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 IPC_IPC_MESSAGE_TEMPLATES_H_ 5 #ifndef IPC_IPC_MESSAGE_TEMPLATES_H_
6 #define IPC_IPC_MESSAGE_TEMPLATES_H_ 6 #define IPC_IPC_MESSAGE_TEMPLATES_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <tuple> 10 #include <tuple>
11 #include <type_traits> 11 #include <type_traits>
12 12
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/trace_event/trace_event.h"
14 #include "base/tuple.h" 15 #include "base/tuple.h"
15 #include "build/build_config.h" 16 #include "build/build_config.h"
16 #include "ipc/ipc_message.h" 17 #include "ipc/ipc_message.h"
17 #include "ipc/ipc_message_utils.h" 18 #include "ipc/ipc_message_utils.h"
18 19
19 namespace IPC { 20 namespace IPC {
20 21
21 // This function is for all the async IPCs that don't pass an extra parameter 22 // This function is for all the async IPCs that don't pass an extra parameter
22 // using IPC_BEGIN_MESSAGE_MAP_WITH_PARAM. 23 // using IPC_BEGIN_MESSAGE_MAP_WITH_PARAM.
23 template <typename ObjT, typename Method, typename P, typename Tuple> 24 template <typename ObjT, typename Method, typename P, typename Tuple>
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 108
108 static bool Read(const Message* msg, Param* p); 109 static bool Read(const Message* msg, Param* p);
109 static void Log(std::string* name, const Message* msg, std::string* l); 110 static void Log(std::string* name, const Message* msg, std::string* l);
110 111
111 template <class T, class S, class P, class Method> 112 template <class T, class S, class P, class Method>
112 static bool Dispatch(const Message* msg, 113 static bool Dispatch(const Message* msg,
113 T* obj, 114 T* obj,
114 S* sender, 115 S* sender,
115 P* parameter, 116 P* parameter,
116 Method func) { 117 Method func) {
118 TRACE_EVENT0("ipc", Meta::kName);
117 Param p; 119 Param p;
118 if (Read(msg, &p)) { 120 if (Read(msg, &p)) {
119 DispatchToMethod(obj, func, parameter, p); 121 DispatchToMethod(obj, func, parameter, p);
120 return true; 122 return true;
121 } 123 }
122 return false; 124 return false;
123 } 125 }
124 126
125 private: 127 private:
126 MessageT(Routing routing, const Ins&... ins); 128 MessageT(Routing routing, const Ins&... ins);
(...skipping 28 matching lines...) Expand all
155 static bool ReadReplyParam(const Message* msg, ReplyParam* p); 157 static bool ReadReplyParam(const Message* msg, ReplyParam* p);
156 static void WriteReplyParams(Message* reply, const Outs&... outs); 158 static void WriteReplyParams(Message* reply, const Outs&... outs);
157 static void Log(std::string* name, const Message* msg, std::string* l); 159 static void Log(std::string* name, const Message* msg, std::string* l);
158 160
159 template <class T, class S, class P, class Method> 161 template <class T, class S, class P, class Method>
160 static bool Dispatch(const Message* msg, 162 static bool Dispatch(const Message* msg,
161 T* obj, 163 T* obj,
162 S* sender, 164 S* sender,
163 P* parameter, 165 P* parameter,
164 Method func) { 166 Method func) {
167 TRACE_EVENT0("ipc", Meta::kName);
165 SendParam send_params; 168 SendParam send_params;
166 bool ok = ReadSendParam(msg, &send_params); 169 bool ok = ReadSendParam(msg, &send_params);
167 Message* reply = SyncMessage::GenerateReply(msg); 170 Message* reply = SyncMessage::GenerateReply(msg);
168 if (ok) { 171 if (ok) {
169 ReplyParam reply_params; 172 ReplyParam reply_params;
170 base::DispatchToMethod(obj, func, send_params, &reply_params); 173 base::DispatchToMethod(obj, func, send_params, &reply_params);
171 WriteParam(reply, reply_params); 174 WriteParam(reply, reply_params);
172 LogReplyParamsToMessage(reply_params, msg); 175 LogReplyParamsToMessage(reply_params, msg);
173 } else { 176 } else {
174 NOTREACHED() << "Error deserializing message " << msg->type(); 177 NOTREACHED() << "Error deserializing message " << msg->type();
175 reply->set_reply_error(); 178 reply->set_reply_error();
176 } 179 }
177 sender->Send(reply); 180 sender->Send(reply);
178 return ok; 181 return ok;
179 } 182 }
180 183
181 template <class T, class P, class Method> 184 template <class T, class P, class Method>
182 static bool DispatchDelayReply(const Message* msg, 185 static bool DispatchDelayReply(const Message* msg,
183 T* obj, 186 T* obj,
184 P* parameter, 187 P* parameter,
185 Method func) { 188 Method func) {
189 TRACE_EVENT0("ipc", Meta::kName);
186 SendParam send_params; 190 SendParam send_params;
187 bool ok = ReadSendParam(msg, &send_params); 191 bool ok = ReadSendParam(msg, &send_params);
188 Message* reply = SyncMessage::GenerateReply(msg); 192 Message* reply = SyncMessage::GenerateReply(msg);
189 if (ok) { 193 if (ok) {
190 std::tuple<Message&> t = std::tie(*reply); 194 std::tuple<Message&> t = std::tie(*reply);
191 ConnectMessageAndReply(msg, reply); 195 ConnectMessageAndReply(msg, reply);
192 base::DispatchToMethod(obj, func, send_params, &t); 196 base::DispatchToMethod(obj, func, send_params, &t);
193 } else { 197 } else {
194 NOTREACHED() << "Error deserializing message " << msg->type(); 198 NOTREACHED() << "Error deserializing message " << msg->type();
195 reply->set_reply_error(); 199 reply->set_reply_error();
196 obj->Send(reply); 200 obj->Send(reply);
197 } 201 }
198 return ok; 202 return ok;
199 } 203 }
200 204
201 private: 205 private:
202 MessageT(Routing routing, const Ins&... ins, Outs*... outs); 206 MessageT(Routing routing, const Ins&... ins, Outs*... outs);
203 }; 207 };
204 208
205 } // namespace IPC 209 } // namespace IPC
206 210
207 #if defined(IPC_MESSAGE_IMPL) 211 #if defined(IPC_MESSAGE_IMPL)
208 #include "ipc/ipc_message_templates_impl.h" 212 #include "ipc/ipc_message_templates_impl.h"
209 #endif 213 #endif
210 214
211 #endif // IPC_IPC_MESSAGE_TEMPLATES_H_ 215 #endif // IPC_IPC_MESSAGE_TEMPLATES_H_
OLDNEW
« no previous file with comments | « ipc/ipc_channel_proxy.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698