| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef NET_SPDY_SPDY_TEST_UTIL_SPDY3_H_ | 5 #ifndef NET_SPDY_SPDY_TEST_UTIL_SPDY3_H_ |
| 6 #define NET_SPDY_SPDY_TEST_UTIL_SPDY3_H_ | 6 #define NET_SPDY_SPDY_TEST_UTIL_SPDY3_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/string_piece.h" |
| 10 #include "crypto/ec_private_key.h" | 11 #include "crypto/ec_private_key.h" |
| 11 #include "crypto/ec_signature_creator.h" | 12 #include "crypto/ec_signature_creator.h" |
| 12 #include "net/base/cert_verifier.h" | 13 #include "net/base/cert_verifier.h" |
| 13 #include "net/base/host_port_pair.h" | 14 #include "net/base/host_port_pair.h" |
| 14 #include "net/base/mock_host_resolver.h" | 15 #include "net/base/mock_host_resolver.h" |
| 15 #include "net/base/request_priority.h" | 16 #include "net/base/request_priority.h" |
| 16 #include "net/base/ssl_config_service_defaults.h" | 17 #include "net/base/ssl_config_service_defaults.h" |
| 17 #include "net/http/http_auth_handler_factory.h" | 18 #include "net/http/http_auth_handler_factory.h" |
| 18 #include "net/http/http_cache.h" | 19 #include "net/http/http_cache.h" |
| 19 #include "net/http/http_network_session.h" | 20 #include "net/http/http_network_session.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 // Chop a SpdyFrame into an array of MockReads. | 109 // Chop a SpdyFrame into an array of MockReads. |
| 109 // |frame| is the frame to chop. | 110 // |frame| is the frame to chop. |
| 110 // |num_chunks| is the number of chunks to create. | 111 // |num_chunks| is the number of chunks to create. |
| 111 MockRead* ChopReadFrame(const SpdyFrame& frame, int num_chunks); | 112 MockRead* ChopReadFrame(const SpdyFrame& frame, int num_chunks); |
| 112 | 113 |
| 113 // Adds headers and values to a map. | 114 // Adds headers and values to a map. |
| 114 // |extra_headers| is an array of { name, value } pairs, arranged as strings | 115 // |extra_headers| is an array of { name, value } pairs, arranged as strings |
| 115 // where the even entries are the header names, and the odd entries are the | 116 // where the even entries are the header names, and the odd entries are the |
| 116 // header values. | 117 // header values. |
| 117 // |headers| gets filled in from |extra_headers|. | 118 // |headers| gets filled in from |extra_headers|. |
| 118 void AppendHeadersToSpdyFrame(const char* const extra_headers[], | 119 void AppendHeadersToBlock(const char* const extra_headers[], |
| 119 int extra_header_count, | 120 int extra_header_count, |
| 120 SpdyHeaderBlock* headers); | 121 SpdyHeaderBlock* headers); |
| 122 |
| 123 // Constructs a HeaderBlock for the given URL. |
| 124 scoped_ptr<SpdyHeaderBlock> ConstructHeaderBlock(base::StringPiece url); |
| 121 | 125 |
| 122 // Writes |str| of the given |len| to the buffer pointed to by |buffer_handle|. | 126 // Writes |str| of the given |len| to the buffer pointed to by |buffer_handle|. |
| 123 // Uses a template so buffer_handle can be a char* or an unsigned char*. | 127 // Uses a template so buffer_handle can be a char* or an unsigned char*. |
| 124 // Updates the |*buffer_handle| pointer by |len| | 128 // Updates the |*buffer_handle| pointer by |len| |
| 125 // Returns the number of bytes written into *|buffer_handle| | 129 // Returns the number of bytes written into *|buffer_handle| |
| 126 template<class T> | 130 template<class T> |
| 127 int AppendToBuffer(const char* str, | 131 int AppendToBuffer(const char* str, |
| 128 int len, | 132 int len, |
| 129 T** buffer_handle, | 133 T** buffer_handle, |
| 130 int* buffer_len_remaining) { | 134 int* buffer_len_remaining) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 143 // Writes |val| to a location of size |len|, in big-endian format. | 147 // Writes |val| to a location of size |len|, in big-endian format. |
| 144 // in the buffer pointed to by |buffer_handle|. | 148 // in the buffer pointed to by |buffer_handle|. |
| 145 // Updates the |*buffer_handle| pointer by |len| | 149 // Updates the |*buffer_handle| pointer by |len| |
| 146 // Returns the number of bytes written | 150 // Returns the number of bytes written |
| 147 int AppendToBuffer(int val, | 151 int AppendToBuffer(int val, |
| 148 int len, | 152 int len, |
| 149 unsigned char** buffer_handle, | 153 unsigned char** buffer_handle, |
| 150 int* buffer_len_remaining); | 154 int* buffer_len_remaining); |
| 151 | 155 |
| 152 // Construct a SPDY packet. | 156 // Construct a SPDY packet. |
| 153 // |head| is the start of the packet, up to but not including | 157 SpdyFrame* ConstructSpdyPacket(const SpdyHeaderInfo& header_info, |
| 154 // the header value pairs. | 158 scoped_ptr<SpdyHeaderBlock> headers); |
| 159 |
| 160 // Construct a SPDY packet. |
| 155 // |extra_headers| are the extra header-value pairs, which typically | 161 // |extra_headers| are the extra header-value pairs, which typically |
| 156 // will vary the most between calls. | 162 // will vary the most between calls. |
| 157 // |tail| is any (relatively constant) header-value pairs to add. | 163 // |tail| is any (relatively constant) header-value pairs to add. |
| 158 // |buffer| is the buffer we're filling in. | |
| 159 // Returns a SpdyFrame. | 164 // Returns a SpdyFrame. |
| 160 SpdyFrame* ConstructSpdyPacket(const SpdyHeaderInfo& header_info, | 165 SpdyFrame* ConstructSpdyPacket(const SpdyHeaderInfo& header_info, |
| 161 const char* const extra_headers[], | 166 const char* const extra_headers[], |
| 162 int extra_header_count, | 167 int extra_header_count, |
| 163 const char* const tail[], | 168 const char* const tail[], |
| 164 int tail_header_count); | 169 int tail_header_count); |
| 165 | 170 |
| 166 // Construct a generic SpdyControlFrame. | 171 // Construct a generic SpdyControlFrame. |
| 167 SpdyFrame* ConstructSpdyControlFrame(const char* const extra_headers[], | 172 SpdyFrame* ConstructSpdyControlFrame(const char* const extra_headers[], |
| 168 int extra_header_count, | 173 int extra_header_count, |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 SpdySessionPool* const pool_; | 464 SpdySessionPool* const pool_; |
| 460 | 465 |
| 461 DISALLOW_COPY_AND_ASSIGN(SpdySessionPoolPeer); | 466 DISALLOW_COPY_AND_ASSIGN(SpdySessionPoolPeer); |
| 462 }; | 467 }; |
| 463 | 468 |
| 464 } // namespace test_spdy3 | 469 } // namespace test_spdy3 |
| 465 | 470 |
| 466 } // namespace net | 471 } // namespace net |
| 467 | 472 |
| 468 #endif // NET_SPDY_SPDY_TEST_UTIL_SPDY3_H_ | 473 #endif // NET_SPDY_SPDY_TEST_UTIL_SPDY3_H_ |
| OLD | NEW |