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

Unified Diff: net/websockets/websocket_frame.h

Issue 10384180: Add functions used for building WebSocket frame data. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove class, add free functions. Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: net/websockets/websocket_frame.h
diff --git a/net/websockets/websocket_frame.h b/net/websockets/websocket_frame.h
index 593d439481282b023397b241e08d9fa2975d9942..9d1f8bb732a6490fda222a63f0341ad6652d9388 100644
--- a/net/websockets/websocket_frame.h
+++ b/net/websockets/websocket_frame.h
@@ -75,6 +75,42 @@ struct NET_EXPORT_PRIVATE WebSocketFrameChunk {
std::vector<char> data;
};
+// Writes wire format of a WebSocket frame header into |output|.
+//
+// WebSocket frame format is defined at:
+// <http://tools.ietf.org/html/rfc6455#section-5.2>. This function writes
+// everything but payload data in a WebSocket frame to |output|.
+//
+// If |header->masked| is true, |masking_key| must point to four-byte data
+// representing a masking key for that frame (possibly generated by
+// GenerateWebSocketMaskingKey() function below). Otherwise, |masking_key|
+// must be NULL.
+NET_EXPORT_PRIVATE void WriteWebSocketFrameHeader(
+ const WebSocketFrameHeader* header,
mmenke 2012/05/21 15:08:37 Suggest you make this const WebSocketFrameHeader&
Yuta Kitamura 2012/05/22 10:29:35 Done.
+ const char* masking_key,
+ std::vector<char>* output);
+
+// Generates a masking key suitable for use in a new WebSocket frame.
+//
+// |masking_key| should be non-NULL value pointing four-byte
+// (== kMaskingKeyLength bytes) data. The generated masking key will be written
+// to that buffer.
+NET_EXPORT_PRIVATE void GenearteWebSocketMaskingKey(char* masking_key);
mmenke 2012/05/21 15:08:37 nit: GenearteWebSocketMaskingKey -> GenerateWebSoc
mmenke 2012/05/21 15:08:37 I suggest you make a struct for masking keys, so t
Yuta Kitamura 2012/05/22 10:29:35 Introduced a new struct WebSocketMaskingKey. Chang
Yuta Kitamura 2012/05/22 10:29:35 Doh! Fixed.
+
+// Masks WebSocket frame payload.
+//
+// A browser must mask every WebSocket frame by XOR'ing the frame payload
mmenke 2012/05/21 15:08:37 nit: Suggest "client" instead of "browser", as pe
Yuta Kitamura 2012/05/22 10:29:35 Done.
+// with four-byte random data (masking key). This function applies the masking
+// to the given payload data.
+//
+// This function masks |frame_data| with |masking_key|, assuming |frame_data|
+// is partial data starting from |frame_offset| bytes from the beginning of
+// the payload data.
mmenke 2012/05/21 15:08:37 Should make clear that this must not be called whe
Yuta Kitamura 2012/05/22 10:29:35 Resolved by changing the type of |masking_key| to
+NET_EXPORT_PRIVATE void MaskWebSocketFramePayload(
+ const char* masking_key,
+ uint64 frame_offset,
+ std::vector<char>* frame_data);
+
} // namespace net
#endif // NET_WEBSOCKETS_WEBSOCKET_FRAME_H_

Powered by Google App Engine
This is Rietveld 408576698