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

Unified Diff: net/websockets/websocket_frame.h

Issue 10825444: Add a function that calculates the size of WebSocket frame header. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Matt's comment. Created 8 years, 4 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
« no previous file with comments | « no previous file | net/websockets/websocket_frame.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/websockets/websocket_frame.h
diff --git a/net/websockets/websocket_frame.h b/net/websockets/websocket_frame.h
index 9f7c7fd6fc26b471fd38cc8db84a7f2f95ea9068..94f4ede680254dde32a0ba2f163531acf401b915 100644
--- a/net/websockets/websocket_frame.h
+++ b/net/websockets/websocket_frame.h
@@ -86,6 +86,12 @@ struct WebSocketMaskingKey {
char key[WebSocketFrameHeader::kMaskingKeyLength];
};
+// Returns the size of WebSocket frame header. The size of WebSocket frame
+// header varies from 2 bytes to 14 bytes depending on the payload length
+// and maskedness.
+NET_EXPORT_PRIVATE int GetWebSocketFrameHeaderSize(
+ const WebSocketFrameHeader& header);
+
// Writes wire format of a WebSocket frame header into |output|, and returns
// the number of bytes written.
//
@@ -98,10 +104,10 @@ struct WebSocketMaskingKey {
// (possibly generated by GenerateWebSocketMaskingKey() function below).
// Otherwise, |masking_key| must be NULL.
//
-// |buffer| should have enough size to contain the frame header. Size of a
-// frame header varies from 2 bytes to 14 bytes depending on the payload length
-// and maskedness. If the size of |buffer| is insufficient, this function
-// returns ERR_INVALID_ARGUMENT and does not write any data to |buffer|.
+// |buffer| should have enough size to contain the frame header.
+// GetWebSocketFrameHeaderSize() can be used to know the size of header
+// beforehand. If the size of |buffer| is insufficient, this function returns
+// ERR_INVALID_ARGUMENT and does not write any data to |buffer|.
NET_EXPORT_PRIVATE int WriteWebSocketFrameHeader(
const WebSocketFrameHeader& header,
const WebSocketMaskingKey* masking_key,
« no previous file with comments | « no previous file | net/websockets/websocket_frame.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698