OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // IPC messages for the P2P Transport API. | 5 // IPC messages for the P2P Transport API. |
6 | 6 // Multiply-included message file, hence no include guard. |
7 #ifndef CONTENT_COMMON_P2P_MESSAGES_H_ | |
8 #define CONTENT_COMMON_P2P_MESSAGES_H_ | |
9 | 7 |
10 #include "content/common/p2p_sockets.h" | 8 #include "content/common/p2p_sockets.h" |
11 #include "ipc/ipc_message_macros.h" | 9 #include "ipc/ipc_message_macros.h" |
12 | 10 |
13 #define IPC_MESSAGE_START P2PMsgStart | 11 #define IPC_MESSAGE_START P2PMsgStart |
14 | 12 |
| 13 IPC_STRUCT_TRAITS_BEGIN(P2PSocketAddress) |
| 14 IPC_STRUCT_TRAITS_MEMBER(address) |
| 15 IPC_STRUCT_TRAITS_MEMBER(port) |
| 16 IPC_STRUCT_TRAITS_END() |
| 17 |
| 18 IPC_ENUM_TRAITS(P2PSocketType) |
| 19 |
15 // P2P Socket messages sent from the browser to the renderer. | 20 // P2P Socket messages sent from the browser to the renderer. |
16 | 21 |
17 IPC_MESSAGE_ROUTED2(P2PMsg_OnSocketCreated, | 22 IPC_MESSAGE_ROUTED2(P2PMsg_OnSocketCreated, |
18 int /* socket_id */, | 23 int /* socket_id */, |
19 P2PSocketAddress /* socket_address */) | 24 P2PSocketAddress /* socket_address */) |
20 | 25 |
21 IPC_MESSAGE_ROUTED1(P2PMsg_OnError, | 26 IPC_MESSAGE_ROUTED1(P2PMsg_OnError, |
22 int /* socket_id */) | 27 int /* socket_id */) |
23 | 28 |
24 IPC_MESSAGE_ROUTED3(P2PMsg_OnDataReceived, | 29 IPC_MESSAGE_ROUTED3(P2PMsg_OnDataReceived, |
25 int /* socket_id */, | 30 int /* socket_id */, |
26 P2PSocketAddress /* socket_address */, | 31 P2PSocketAddress /* socket_address */, |
27 std::vector<char> /* data */) | 32 std::vector<char> /* data */) |
28 | 33 |
29 // P2P Socket messages sent from the renderer to the browser. | 34 // P2P Socket messages sent from the renderer to the browser. |
30 | 35 |
31 IPC_MESSAGE_ROUTED3(P2PHostMsg_CreateSocket, | 36 IPC_MESSAGE_ROUTED3(P2PHostMsg_CreateSocket, |
32 P2PSocketType /* type */, | 37 P2PSocketType /* type */, |
33 int /* socket_id */, | 38 int /* socket_id */, |
34 P2PSocketAddress /* remote_address */) | 39 P2PSocketAddress /* remote_address */) |
35 | 40 |
36 // TODO(sergeyu): Use shared memory to pass the data. | 41 // TODO(sergeyu): Use shared memory to pass the data. |
37 IPC_MESSAGE_ROUTED3(P2PHostMsg_Send, | 42 IPC_MESSAGE_ROUTED3(P2PHostMsg_Send, |
38 int /* socket_id */, | 43 int /* socket_id */, |
39 P2PSocketAddress /* socket_address */, | 44 P2PSocketAddress /* socket_address */, |
40 std::vector<char> /* data */) | 45 std::vector<char> /* data */) |
41 | 46 |
42 IPC_MESSAGE_ROUTED1(P2PHostMsg_DestroySocket, | 47 IPC_MESSAGE_ROUTED1(P2PHostMsg_DestroySocket, |
43 int /* socket_id */) | 48 int /* socket_id */) |
44 | |
45 namespace IPC { | |
46 | |
47 template <> | |
48 struct ParamTraits<P2PSocketAddress> { | |
49 typedef P2PSocketAddress param_type; | |
50 static void Write(Message* m, const param_type& p); | |
51 static bool Read(const Message* m, void** iter, param_type* p); | |
52 static void Log(const param_type& p, std::string* l); | |
53 }; | |
54 | |
55 template <> | |
56 struct SimilarTypeTraits<P2PSocketType> { | |
57 typedef int Type; | |
58 }; | |
59 | |
60 } // namespace IPC | |
61 | |
62 #endif // CONTENT_COMMON_P2P_MESSAGES_H_ | |
OLD | NEW |