Chromium Code Reviews| 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/serialized_origin.h" | |
| 21 #include "content/common/websocket.h" | 22 #include "content/common/websocket.h" |
| 22 #include "ipc/ipc_message_macros.h" | 23 #include "ipc/ipc_message_macros.h" |
| 23 #include "url/gurl.h" | 24 #include "url/gurl.h" |
| 24 | 25 |
| 25 #undef IPC_MESSAGE_EXPORT | 26 #undef IPC_MESSAGE_EXPORT |
| 26 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT | 27 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT |
| 27 #define IPC_MESSAGE_START WebSocketMsgStart | 28 #define IPC_MESSAGE_START WebSocketMsgStart |
| 28 | 29 |
| 29 IPC_ENUM_TRAITS_MAX_VALUE(content::WebSocketMessageType, | 30 IPC_ENUM_TRAITS_MAX_VALUE(content::WebSocketMessageType, |
| 30 content::WEB_SOCKET_MESSAGE_TYPE_LAST) | 31 content::WEB_SOCKET_MESSAGE_TYPE_LAST) |
| 31 | 32 |
| 32 IPC_STRUCT_TRAITS_BEGIN(content::WebSocketHandshakeRequest) | 33 IPC_STRUCT_TRAITS_BEGIN(content::WebSocketHandshakeRequest) |
| 33 IPC_STRUCT_TRAITS_MEMBER(url) | 34 IPC_STRUCT_TRAITS_MEMBER(url) |
| 34 IPC_STRUCT_TRAITS_MEMBER(headers) | 35 IPC_STRUCT_TRAITS_MEMBER(headers) |
| 35 IPC_STRUCT_TRAITS_MEMBER(request_time) | 36 IPC_STRUCT_TRAITS_MEMBER(request_time) |
| 36 IPC_STRUCT_TRAITS_END() | 37 IPC_STRUCT_TRAITS_END() |
| 37 | 38 |
| 38 IPC_STRUCT_TRAITS_BEGIN(content::WebSocketHandshakeResponse) | 39 IPC_STRUCT_TRAITS_BEGIN(content::WebSocketHandshakeResponse) |
| 39 IPC_STRUCT_TRAITS_MEMBER(url) | 40 IPC_STRUCT_TRAITS_MEMBER(url) |
| 40 IPC_STRUCT_TRAITS_MEMBER(status_code) | 41 IPC_STRUCT_TRAITS_MEMBER(status_code) |
| 41 IPC_STRUCT_TRAITS_MEMBER(status_text) | 42 IPC_STRUCT_TRAITS_MEMBER(status_text) |
| 42 IPC_STRUCT_TRAITS_MEMBER(headers) | 43 IPC_STRUCT_TRAITS_MEMBER(headers) |
| 43 IPC_STRUCT_TRAITS_MEMBER(response_time) | 44 IPC_STRUCT_TRAITS_MEMBER(response_time) |
| 44 IPC_STRUCT_TRAITS_END() | 45 IPC_STRUCT_TRAITS_END() |
| 45 | 46 |
| 47 IPC_STRUCT_TRAITS_BEGIN(content::SerializedOrigin) | |
| 48 IPC_STRUCT_TRAITS_MEMBER(string) | |
|
Adam Rice
2014/02/24 06:48:26
Indentation.
yhirano
2014/03/03 15:41:54
deleted
| |
| 49 IPC_STRUCT_TRAITS_END() | |
| 50 | |
| 46 // WebSocket messages sent from the renderer to the browser. | 51 // WebSocket messages sent from the renderer to the browser. |
| 47 | 52 |
| 48 // Open new virtual WebSocket connection to |socket_url|. |channel_id| is an | 53 // Open new virtual WebSocket connection to |socket_url|. |channel_id| is an |
| 49 // identifier chosen by the renderer for the new channel. It cannot correspond | 54 // identifier chosen by the renderer for the new channel. It cannot correspond |
| 50 // to an existing open channel, and must be between 1 and | 55 // to an existing open channel, and must be between 1 and |
| 51 // 0x7FFFFFFF. |requested_protocols| is a list of tokens identifying | 56 // 0x7FFFFFFF. |requested_protocols| is a list of tokens identifying |
| 52 // sub-protocols the renderer would like to use, as described in RFC6455 | 57 // sub-protocols the renderer would like to use, as described in RFC6455 |
| 53 // "Subprotocols Using the WebSocket Protocol". | 58 // "Subprotocols Using the WebSocket Protocol". |
| 54 // | 59 // |
| 55 // The browser process will not send |channel_id| as-is to the remote server; it | 60 // The browser process will not send |channel_id| as-is to the remote server; it |
| 56 // will try to use a short id on the wire. This saves the renderer from | 61 // will try to use a short id on the wire. This saves the renderer from |
| 57 // having to try to choose the ids cleverly. | 62 // having to try to choose the ids cleverly. |
| 58 IPC_MESSAGE_ROUTED3(WebSocketHostMsg_AddChannelRequest, | 63 IPC_MESSAGE_ROUTED3(WebSocketHostMsg_AddChannelRequest, |
| 59 GURL /* socket_url */, | 64 GURL /* socket_url */, |
| 60 std::vector<std::string> /* requested_protocols */, | 65 std::vector<std::string> /* requested_protocols */, |
| 61 GURL /* origin */) | 66 content::SerializedOrigin /* origin */) |
| 62 | 67 |
| 63 // WebSocket messages sent from the browser to the renderer. | 68 // WebSocket messages sent from the browser to the renderer. |
| 64 | 69 |
| 65 // Respond to an AddChannelRequest for channel |channel_id|. |channel_id| is | 70 // Respond to an AddChannelRequest for channel |channel_id|. |channel_id| is |
| 66 // scoped to the renderer process; while it is unique per-renderer, the browser | 71 // scoped to the renderer process; while it is unique per-renderer, the browser |
| 67 // may have multiple renderers using the same id. If |fail| is true, the channel | 72 // may have multiple renderers using the same id. If |fail| is true, the channel |
| 68 // could not be established (the cause of the failure is not provided to the | 73 // could not be established (the cause of the failure is not provided to the |
| 69 // renderer in order to limit its ability to abuse WebSockets to perform network | 74 // renderer in order to limit its ability to abuse WebSockets to perform network |
| 70 // probing, etc.). If |fail| is set then the |channel_id| is available for | 75 // probing, etc.). If |fail| is set then the |channel_id| is available for |
| 71 // re-use. |selected_protocol| is the sub-protocol the server selected, | 76 // re-use. |selected_protocol| is the sub-protocol the server selected, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 // closing handshake and the renderer cannot accept any new messages on this | 152 // closing handshake and the renderer cannot accept any new messages on this |
| 148 // connection. | 153 // connection. |
| 149 IPC_MESSAGE_ROUTED3(WebSocketMsg_DropChannel, | 154 IPC_MESSAGE_ROUTED3(WebSocketMsg_DropChannel, |
| 150 bool /* was_clean */, | 155 bool /* was_clean */, |
| 151 unsigned short /* code */, | 156 unsigned short /* code */, |
| 152 std::string /* reason */) | 157 std::string /* reason */) |
| 153 | 158 |
| 154 // Notify the renderer that a closing handshake has been initiated by the | 159 // Notify the renderer that a closing handshake has been initiated by the |
| 155 // server, so that it can set the Javascript readyState to CLOSING. | 160 // server, so that it can set the Javascript readyState to CLOSING. |
| 156 IPC_MESSAGE_ROUTED0(WebSocketMsg_NotifyClosing) | 161 IPC_MESSAGE_ROUTED0(WebSocketMsg_NotifyClosing) |
| OLD | NEW |