Speech refactoring: Reimplemented SpeechRecognitionManagerImpl as a FSM. (CL1.7)
[chromium-blink-merge.git] / net / spdy / spdy_websocket_test_util_spdy2.cc
blobc2c042feec996602e393009e7a5dda9b9944579a
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "net/spdy/spdy_websocket_test_util_spdy2.h"
7 #include "net/spdy/buffered_spdy_framer.h"
8 #include "net/spdy/spdy_http_utils.h"
9 #include "net/spdy/spdy_test_util_spdy2.h"
11 static const int kDefaultAssociatedStreamId = 0;
12 static const bool kDefaultCompressed = false;
13 static const char* const kDefaultDataPointer = NULL;
14 static const uint32 kDefaultDataLength = 0;
15 static const char** const kDefaultExtraHeaders = NULL;
16 static const int kDefaultExtraHeaderCount = 0;
18 namespace net {
20 namespace test_spdy2 {
22 SpdyFrame* ConstructSpdyWebSocketHandshakeRequestFrame(
23 const char* const headers[],
24 int header_count,
25 SpdyStreamId stream_id,
26 RequestPriority request_priority) {
28 // SPDY SYN_STREAM control frame header.
29 const SpdyHeaderInfo kSynStreamHeader = {
30 SYN_STREAM,
31 stream_id,
32 kDefaultAssociatedStreamId,
33 ConvertRequestPriorityToSpdyPriority(request_priority, 2),
34 CONTROL_FLAG_NONE,
35 kDefaultCompressed,
36 INVALID,
37 kDefaultDataPointer,
38 kDefaultDataLength,
39 DATA_FLAG_NONE
42 // Construct SPDY SYN_STREAM control frame.
43 return ConstructSpdyPacket(
44 kSynStreamHeader,
45 kDefaultExtraHeaders,
46 kDefaultExtraHeaderCount,
47 headers,
48 header_count);
51 SpdyFrame* ConstructSpdyWebSocketHandshakeResponseFrame(
52 const char* const headers[],
53 int header_count,
54 SpdyStreamId stream_id,
55 RequestPriority request_priority) {
57 // SPDY SYN_REPLY control frame header.
58 const SpdyHeaderInfo kSynReplyHeader = {
59 SYN_REPLY,
60 stream_id,
61 kDefaultAssociatedStreamId,
62 ConvertRequestPriorityToSpdyPriority(request_priority, 2),
63 CONTROL_FLAG_NONE,
64 kDefaultCompressed,
65 INVALID,
66 kDefaultDataPointer,
67 kDefaultDataLength,
68 DATA_FLAG_NONE
71 // Construct SPDY SYN_REPLY control frame.
72 return ConstructSpdyPacket(
73 kSynReplyHeader,
74 kDefaultExtraHeaders,
75 kDefaultExtraHeaderCount,
76 headers,
77 header_count);
80 SpdyFrame* ConstructSpdyWebSocketDataFrame(
81 const char* data,
82 int len,
83 SpdyStreamId stream_id,
84 bool fin) {
86 // Construct SPDY data frame.
87 BufferedSpdyFramer framer(2);
88 return framer.CreateDataFrame(
89 stream_id,
90 data,
91 len,
92 fin ? DATA_FLAG_FIN : DATA_FLAG_NONE);
95 } // namespace test_spdy2
97 } // namespace net