| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // Multiply-included message file, hence no include guard. | 5 // Multiply-included message file, hence no include guard. |
| 6 | 6 |
| 7 // This file defines the IPCs for the browser-side implementation of | 7 // This file defines the IPCs for the browser-side implementation of |
| 8 // WebSockets. For the legacy renderer-side implementation, see | 8 // WebSockets. For the legacy renderer-side implementation, see |
| 9 // socket_stream_messages.h. | 9 // socket_stream_messages.h. |
| 10 // TODO(ricea): Fix this comment when the legacy implementation has been | 10 // TODO(ricea): Fix this comment when the legacy implementation has been |
| 11 // removed. | 11 // removed. |
| 12 // | 12 // |
| 13 // This IPC interface is based on the WebSocket multiplexing draft spec, | 13 // This IPC interface is based on the WebSocket multiplexing draft spec, |
| 14 // http://tools.ietf.org/html/draft-ietf-hybi-websocket-multiplexing-09 | 14 // http://tools.ietf.org/html/draft-ietf-hybi-websocket-multiplexing-09 |
| 15 | 15 |
| 16 #include <string> | 16 #include <string> |
| 17 #include <vector> | 17 #include <vector> |
| 18 | 18 |
| 19 #include "base/basictypes.h" | 19 #include "base/basictypes.h" |
| 20 #include "content/common/content_export.h" | 20 #include "content/common/content_export.h" |
| 21 #include "content/common/websocket.h" | 21 #include "content/common/websocket.h" |
| 22 #include "ipc/ipc_message_macros.h" | 22 #include "ipc/ipc_message_macros.h" |
| 23 #include "url/gurl.h" | 23 #include "url/gurl.h" |
| 24 | 24 |
| 25 #undef IPC_MESSAGE_EXPORT | 25 #undef IPC_MESSAGE_EXPORT |
| 26 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT | 26 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT |
| 27 #define IPC_MESSAGE_START WebSocketMsgStart | 27 #define IPC_MESSAGE_START WebSocketMsgStart |
| 28 | 28 |
| 29 IPC_ENUM_TRAITS_MAX_VALUE(content::WebSocketMessageType, |
| 30 content::WEB_SOCKET_MESSAGE_TYPE_LAST) |
| 31 |
| 29 IPC_STRUCT_TRAITS_BEGIN(content::WebSocketHandshakeRequest) | 32 IPC_STRUCT_TRAITS_BEGIN(content::WebSocketHandshakeRequest) |
| 30 IPC_STRUCT_TRAITS_MEMBER(url) | 33 IPC_STRUCT_TRAITS_MEMBER(url) |
| 31 IPC_STRUCT_TRAITS_MEMBER(headers) | 34 IPC_STRUCT_TRAITS_MEMBER(headers) |
| 32 IPC_STRUCT_TRAITS_MEMBER(request_time) | 35 IPC_STRUCT_TRAITS_MEMBER(request_time) |
| 33 IPC_STRUCT_TRAITS_END() | 36 IPC_STRUCT_TRAITS_END() |
| 34 | 37 |
| 35 IPC_STRUCT_TRAITS_BEGIN(content::WebSocketHandshakeResponse) | 38 IPC_STRUCT_TRAITS_BEGIN(content::WebSocketHandshakeResponse) |
| 36 IPC_STRUCT_TRAITS_MEMBER(url) | 39 IPC_STRUCT_TRAITS_MEMBER(url) |
| 37 IPC_STRUCT_TRAITS_MEMBER(status_code) | 40 IPC_STRUCT_TRAITS_MEMBER(status_code) |
| 38 IPC_STRUCT_TRAITS_MEMBER(status_text) | 41 IPC_STRUCT_TRAITS_MEMBER(status_text) |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 // 3. Close the channel immediately uncleanly, as if it received | 97 // 3. Close the channel immediately uncleanly, as if it received |
| 95 // DropChannel(was_clean = false, code = 1006, reason = ""). | 98 // DropChannel(was_clean = false, code = 1006, reason = ""). |
| 96 // |message| will be shown in the inspector and won't be passed to the script. | 99 // |message| will be shown in the inspector and won't be passed to the script. |
| 97 // TODO(yhirano): Find the way to pass |message| directly to the inspector | 100 // TODO(yhirano): Find the way to pass |message| directly to the inspector |
| 98 // process. | 101 // process. |
| 99 IPC_MESSAGE_ROUTED1(WebSocketMsg_NotifyFailure, | 102 IPC_MESSAGE_ROUTED1(WebSocketMsg_NotifyFailure, |
| 100 std::string /* message */) | 103 std::string /* message */) |
| 101 | 104 |
| 102 // WebSocket messages that can be sent in either direction. | 105 // WebSocket messages that can be sent in either direction. |
| 103 | 106 |
| 104 IPC_ENUM_TRAITS(content::WebSocketMessageType) | |
| 105 | |
| 106 // Send a non-control frame on |channel_id|. If the sender is the renderer, it | 107 // Send a non-control frame on |channel_id|. If the sender is the renderer, it |
| 107 // will be sent to the remote server. If the sender is the browser, it comes | 108 // will be sent to the remote server. If the sender is the browser, it comes |
| 108 // from the remote server. |fin| indicates that this frame is the last in the | 109 // from the remote server. |fin| indicates that this frame is the last in the |
| 109 // current message. |type| is the type of the message. On the first frame of a | 110 // current message. |type| is the type of the message. On the first frame of a |
| 110 // message, it must be set to either WEB_SOCKET_MESSAGE_TYPE_TEXT or | 111 // message, it must be set to either WEB_SOCKET_MESSAGE_TYPE_TEXT or |
| 111 // WEB_SOCKET_MESSAGE_TYPE_BINARY. On subsequent frames, it must be set to | 112 // WEB_SOCKET_MESSAGE_TYPE_BINARY. On subsequent frames, it must be set to |
| 112 // WEB_SOCKET_MESSAGE_TYPE_CONTINUATION, and the type is the same as that of the | 113 // WEB_SOCKET_MESSAGE_TYPE_CONTINUATION, and the type is the same as that of the |
| 113 // first message. If |type| is WEB_SOCKET_MESSAGE_TYPE_TEXT, then the | 114 // first message. If |type| is WEB_SOCKET_MESSAGE_TYPE_TEXT, then the |
| 114 // concatenation of the |data| from every frame in the message must be valid | 115 // concatenation of the |data| from every frame in the message must be valid |
| 115 // UTF-8. If |fin| is not set, |data| must be non-empty. | 116 // UTF-8. If |fin| is not set, |data| must be non-empty. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 142 // message. | 143 // message. |
| 143 // If |was_clean| is false on a message from the browser, then the WebSocket | 144 // If |was_clean| is false on a message from the browser, then the WebSocket |
| 144 // connection was not closed cleanly. If |was_clean| is false on a message from | 145 // connection was not closed cleanly. If |was_clean| is false on a message from |
| 145 // the renderer, then the connection should be closed immediately without a | 146 // the renderer, then the connection should be closed immediately without a |
| 146 // closing handshake and the renderer cannot accept any new messages on this | 147 // closing handshake and the renderer cannot accept any new messages on this |
| 147 // connection. | 148 // connection. |
| 148 IPC_MESSAGE_ROUTED3(WebSocketMsg_DropChannel, | 149 IPC_MESSAGE_ROUTED3(WebSocketMsg_DropChannel, |
| 149 bool /* was_clean */, | 150 bool /* was_clean */, |
| 150 unsigned short /* code */, | 151 unsigned short /* code */, |
| 151 std::string /* reason */) | 152 std::string /* reason */) |
| OLD | NEW |