OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_UTILS_H_ | 5 #ifndef IPC_IPC_MESSAGE_UTILS_H_ |
6 #define IPC_IPC_MESSAGE_UTILS_H_ | 6 #define IPC_IPC_MESSAGE_UTILS_H_ |
7 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/containers/small_map.h" | 14 #include "base/containers/small_map.h" |
15 #include "base/files/file.h" | 15 #include "base/files/file.h" |
16 #include "base/format_macros.h" | 16 #include "base/format_macros.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/memory/scoped_vector.h" | 18 #include "base/memory/scoped_vector.h" |
19 #include "base/strings/string16.h" | 19 #include "base/strings/string16.h" |
20 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
21 #include "base/strings/stringprintf.h" | 21 #include "base/strings/stringprintf.h" |
22 #include "base/tuple.h" | 22 #include "base/tuple.h" |
| 23 #include "ipc/brokerable_attachment.h" |
23 #include "ipc/ipc_message_start.h" | 24 #include "ipc/ipc_message_start.h" |
24 #include "ipc/ipc_param_traits.h" | 25 #include "ipc/ipc_param_traits.h" |
25 #include "ipc/ipc_sync_message.h" | 26 #include "ipc/ipc_sync_message.h" |
26 | 27 |
27 #if defined(COMPILER_GCC) | 28 #if defined(COMPILER_GCC) |
28 // GCC "helpfully" tries to inline template methods in release mode. Except we | 29 // GCC "helpfully" tries to inline template methods in release mode. Except we |
29 // want the majority of the template junk being expanded once in the | 30 // want the majority of the template junk being expanded once in the |
30 // implementation file (and only provide the definitions in | 31 // implementation file (and only provide the definitions in |
31 // ipc_message_utils_impl.h in those files) and exported, instead of expanded | 32 // ipc_message_utils_impl.h in those files) and exported, instead of expanded |
32 // at every call site. Special note: GCC happily accepts the attribute before | 33 // at every call site. Special note: GCC happily accepts the attribute before |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 } | 422 } |
422 static void Log(const param_type& p, std::string* l) { | 423 static void Log(const param_type& p, std::string* l) { |
423 l->append("("); | 424 l->append("("); |
424 LogParam(p.first, l); | 425 LogParam(p.first, l); |
425 l->append(", "); | 426 l->append(", "); |
426 LogParam(p.second, l); | 427 LogParam(p.second, l); |
427 l->append(")"); | 428 l->append(")"); |
428 } | 429 } |
429 }; | 430 }; |
430 | 431 |
| 432 // IPC ParamTraits ------------------------------------------------------------- |
| 433 template <> |
| 434 struct IPC_EXPORT ParamTraits<IPC::BrokerableAttachment::AttachmentId> { |
| 435 typedef IPC::BrokerableAttachment::AttachmentId param_type; |
| 436 static void Write(Message* m, const param_type& p); |
| 437 static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); |
| 438 static void Log(const param_type& p, std::string* l); |
| 439 }; |
| 440 |
431 // Base ParamTraits ------------------------------------------------------------ | 441 // Base ParamTraits ------------------------------------------------------------ |
432 | 442 |
433 template <> | 443 template <> |
434 struct IPC_EXPORT ParamTraits<base::DictionaryValue> { | 444 struct IPC_EXPORT ParamTraits<base::DictionaryValue> { |
435 typedef base::DictionaryValue param_type; | 445 typedef base::DictionaryValue param_type; |
436 static void Write(Message* m, const param_type& p); | 446 static void Write(Message* m, const param_type& p); |
437 static bool Read(const Message* m, | 447 static bool Read(const Message* m, |
438 base::PickleIterator* iter, | 448 base::PickleIterator* iter, |
439 param_type* r); | 449 param_type* r); |
440 static void Log(const param_type& p, std::string* l); | 450 static void Log(const param_type& p, std::string* l); |
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
996 template <typename... Ts> | 1006 template <typename... Ts> |
997 static void WriteReplyParams(Message* reply, Ts... args) { | 1007 static void WriteReplyParams(Message* reply, Ts... args) { |
998 ReplyParam p(args...); | 1008 ReplyParam p(args...); |
999 WriteParam(reply, p); | 1009 WriteParam(reply, p); |
1000 } | 1010 } |
1001 }; | 1011 }; |
1002 | 1012 |
1003 } // namespace IPC | 1013 } // namespace IPC |
1004 | 1014 |
1005 #endif // IPC_IPC_MESSAGE_UTILS_H_ | 1015 #endif // IPC_IPC_MESSAGE_UTILS_H_ |
OLD | NEW |