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

Unified Diff: net/spdy/spdy_websocket_test_util.cc

Issue 7312005: WebSocket over SPDY: Move common test functions into separated file (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase on lkgr Created 9 years, 5 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 | « net/spdy/spdy_websocket_test_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/spdy_websocket_test_util.cc
diff --git a/net/spdy/spdy_websocket_test_util.cc b/net/spdy/spdy_websocket_test_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ad635fb85a5164f8163285aafa3e9b74b90de67f
--- /dev/null
+++ b/net/spdy/spdy_websocket_test_util.cc
@@ -0,0 +1,93 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/spdy/spdy_websocket_test_util.h"
+
+#include "net/spdy/spdy_framer.h"
+#include "net/spdy/spdy_http_utils.h"
+#include "net/spdy/spdy_test_util.h"
+
+static const int kDefaultAssociatedStreamId = 0;
+static const bool kDefaultCompressed = false;
+static const char* const kDefaultDataPointer = NULL;
+static const uint32 kDefaultDataLength = 0;
+static const char** const kDefaultExtraHeaders = NULL;
+static const int kDefaultExtraHeaderCount = 0;
+
+namespace net {
+
+spdy::SpdyFrame* ConstructSpdyWebSocketHandshakeRequestFrame(
+ const char* const headers[],
+ int header_count,
+ spdy::SpdyStreamId stream_id,
+ RequestPriority request_priority) {
+
+ // SPDY SYN_STREAM control frame header.
+ const SpdyHeaderInfo kSynStreamHeader = {
+ spdy::SYN_STREAM,
+ stream_id,
+ kDefaultAssociatedStreamId,
+ ConvertRequestPriorityToSpdyPriority(request_priority),
+ spdy::CONTROL_FLAG_NONE,
+ kDefaultCompressed,
+ spdy::INVALID,
+ kDefaultDataPointer,
+ kDefaultDataLength,
+ spdy::DATA_FLAG_NONE
+ };
+
+ // Construct SPDY SYN_STREAM control frame.
+ return ConstructSpdyPacket(
+ kSynStreamHeader,
+ kDefaultExtraHeaders,
+ kDefaultExtraHeaderCount,
+ headers,
+ header_count);
+}
+
+spdy::SpdyFrame* ConstructSpdyWebSocketHandshakeResponseFrame(
+ const char* const headers[],
+ int header_count,
+ spdy::SpdyStreamId stream_id,
+ RequestPriority request_priority) {
+
+ // SPDY SYN_REPLY control frame header.
+ const SpdyHeaderInfo kSynReplyHeader = {
+ spdy::SYN_REPLY,
+ stream_id,
+ kDefaultAssociatedStreamId,
+ ConvertRequestPriorityToSpdyPriority(request_priority),
+ spdy::CONTROL_FLAG_NONE,
+ kDefaultCompressed,
+ spdy::INVALID,
+ kDefaultDataPointer,
+ kDefaultDataLength,
+ spdy::DATA_FLAG_NONE
+ };
+
+ // Construct SPDY SYN_REPLY control frame.
+ return ConstructSpdyPacket(
+ kSynReplyHeader,
+ kDefaultExtraHeaders,
+ kDefaultExtraHeaderCount,
+ headers,
+ header_count);
+}
+
+spdy::SpdyFrame* ConstructSpdyWebSocketDataFrame(
+ const char* data,
+ int len,
+ spdy::SpdyStreamId stream_id,
+ bool fin) {
+
+ // Construct SPDY data frame.
+ spdy::SpdyFramer framer;
+ return framer.CreateDataFrame(
+ stream_id,
+ data,
+ len,
+ fin ? spdy::DATA_FLAG_FIN : spdy::DATA_FLAG_NONE);
+}
+
+} // namespace net
« no previous file with comments | « net/spdy/spdy_websocket_test_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698