chromeos: bluetooth: add BluetoothInputClient
[chromium-blink-merge.git] / net / spdy / spdy_websocket_test_util.cc
blobad635fb85a5164f8163285aafa3e9b74b90de67f
1 // Copyright (c) 2011 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.h"
7 #include "net/spdy/spdy_framer.h"
8 #include "net/spdy/spdy_http_utils.h"
9 #include "net/spdy/spdy_test_util.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 spdy::SpdyFrame* ConstructSpdyWebSocketHandshakeRequestFrame(
21 const char* const headers[],
22 int header_count,
23 spdy::SpdyStreamId stream_id,
24 RequestPriority request_priority) {
26 // SPDY SYN_STREAM control frame header.
27 const SpdyHeaderInfo kSynStreamHeader = {
28 spdy::SYN_STREAM,
29 stream_id,
30 kDefaultAssociatedStreamId,
31 ConvertRequestPriorityToSpdyPriority(request_priority),
32 spdy::CONTROL_FLAG_NONE,
33 kDefaultCompressed,
34 spdy::INVALID,
35 kDefaultDataPointer,
36 kDefaultDataLength,
37 spdy::DATA_FLAG_NONE
40 // Construct SPDY SYN_STREAM control frame.
41 return ConstructSpdyPacket(
42 kSynStreamHeader,
43 kDefaultExtraHeaders,
44 kDefaultExtraHeaderCount,
45 headers,
46 header_count);
49 spdy::SpdyFrame* ConstructSpdyWebSocketHandshakeResponseFrame(
50 const char* const headers[],
51 int header_count,
52 spdy::SpdyStreamId stream_id,
53 RequestPriority request_priority) {
55 // SPDY SYN_REPLY control frame header.
56 const SpdyHeaderInfo kSynReplyHeader = {
57 spdy::SYN_REPLY,
58 stream_id,
59 kDefaultAssociatedStreamId,
60 ConvertRequestPriorityToSpdyPriority(request_priority),
61 spdy::CONTROL_FLAG_NONE,
62 kDefaultCompressed,
63 spdy::INVALID,
64 kDefaultDataPointer,
65 kDefaultDataLength,
66 spdy::DATA_FLAG_NONE
69 // Construct SPDY SYN_REPLY control frame.
70 return ConstructSpdyPacket(
71 kSynReplyHeader,
72 kDefaultExtraHeaders,
73 kDefaultExtraHeaderCount,
74 headers,
75 header_count);
78 spdy::SpdyFrame* ConstructSpdyWebSocketDataFrame(
79 const char* data,
80 int len,
81 spdy::SpdyStreamId stream_id,
82 bool fin) {
84 // Construct SPDY data frame.
85 spdy::SpdyFramer framer;
86 return framer.CreateDataFrame(
87 stream_id,
88 data,
89 len,
90 fin ? spdy::DATA_FLAG_FIN : spdy::DATA_FLAG_NONE);
93 } // namespace net