Chromium Code Reviews| 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_SPDY2_H_ | 5 #ifndef NET_SPDY_SPDY_TEST_UTIL_SPDY2_H_ |
| 6 #define NET_SPDY_SPDY_TEST_UTIL_SPDY2_H_ | 6 #define NET_SPDY_SPDY_TEST_UTIL_SPDY2_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "base/string_piece.h" | |
| 9 #include "net/base/cert_verifier.h" | 11 #include "net/base/cert_verifier.h" |
| 10 #include "net/base/host_port_pair.h" | 12 #include "net/base/host_port_pair.h" |
| 11 #include "net/base/mock_host_resolver.h" | 13 #include "net/base/mock_host_resolver.h" |
| 12 #include "net/base/request_priority.h" | 14 #include "net/base/request_priority.h" |
| 13 #include "net/base/ssl_config_service_defaults.h" | 15 #include "net/base/ssl_config_service_defaults.h" |
| 14 #include "net/http/http_auth_handler_factory.h" | 16 #include "net/http/http_auth_handler_factory.h" |
| 15 #include "net/http/http_cache.h" | 17 #include "net/http/http_cache.h" |
| 16 #include "net/http/http_network_session.h" | 18 #include "net/http/http_network_session.h" |
| 17 #include "net/http/http_network_layer.h" | 19 #include "net/http/http_network_layer.h" |
| 18 #include "net/http/http_server_properties_impl.h" | 20 #include "net/http/http_server_properties_impl.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 // Chop a SpdyFrame into an array of MockReads. | 70 // Chop a SpdyFrame into an array of MockReads. |
| 69 // |frame| is the frame to chop. | 71 // |frame| is the frame to chop. |
| 70 // |num_chunks| is the number of chunks to create. | 72 // |num_chunks| is the number of chunks to create. |
| 71 MockRead* ChopReadFrame(const SpdyFrame& frame, int num_chunks); | 73 MockRead* ChopReadFrame(const SpdyFrame& frame, int num_chunks); |
| 72 | 74 |
| 73 // Adds headers and values to a map. | 75 // Adds headers and values to a map. |
| 74 // |extra_headers| is an array of { name, value } pairs, arranged as strings | 76 // |extra_headers| is an array of { name, value } pairs, arranged as strings |
| 75 // where the even entries are the header names, and the odd entries are the | 77 // where the even entries are the header names, and the odd entries are the |
| 76 // header values. | 78 // header values. |
| 77 // |headers| gets filled in from |extra_headers|. | 79 // |headers| gets filled in from |extra_headers|. |
| 78 void AppendHeadersToSpdyFrame(const char* const extra_headers[], | 80 void AppendToHeaderBlock(const char* const extra_headers[], |
| 79 int extra_header_count, | 81 int extra_header_count, |
| 80 SpdyHeaderBlock* headers); | 82 SpdyHeaderBlock* headers); |
| 83 | |
| 84 // Constructs a HeaderBlock for the given URL. | |
| 85 scoped_ptr<SpdyHeaderBlock> ConstructHeaderBlock(base::StringPiece url); | |
| 81 | 86 |
| 82 // Writes |str| of the given |len| to the buffer pointed to by |buffer_handle|. | 87 // Writes |str| of the given |len| to the buffer pointed to by |buffer_handle|. |
| 83 // Uses a template so buffer_handle can be a char* or an unsigned char*. | 88 // Uses a template so buffer_handle can be a char* or an unsigned char*. |
| 84 // Updates the |*buffer_handle| pointer by |len| | 89 // Updates the |*buffer_handle| pointer by |len| |
| 85 // Returns the number of bytes written into *|buffer_handle| | 90 // Returns the number of bytes written into *|buffer_handle| |
| 86 template<class T> | 91 template<class T> |
| 87 int AppendToBuffer(const char* str, | 92 int AppendToBuffer(const char* str, |
| 88 int len, | 93 int len, |
| 89 T** buffer_handle, | 94 T** buffer_handle, |
| 90 int* buffer_len_remaining) { | 95 int* buffer_len_remaining) { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 103 // Writes |val| to a location of size |len|, in big-endian format. | 108 // Writes |val| to a location of size |len|, in big-endian format. |
| 104 // in the buffer pointed to by |buffer_handle|. | 109 // in the buffer pointed to by |buffer_handle|. |
| 105 // Updates the |*buffer_handle| pointer by |len| | 110 // Updates the |*buffer_handle| pointer by |len| |
| 106 // Returns the number of bytes written | 111 // Returns the number of bytes written |
| 107 int AppendToBuffer(int val, | 112 int AppendToBuffer(int val, |
| 108 int len, | 113 int len, |
| 109 unsigned char** buffer_handle, | 114 unsigned char** buffer_handle, |
| 110 int* buffer_len_remaining); | 115 int* buffer_len_remaining); |
| 111 | 116 |
| 112 // Construct a SPDY packet. | 117 // Construct a SPDY packet. |
| 113 // |head| is the start of the packet, up to but not including | 118 SpdyFrame* ConstructSpdyPacket(const SpdyHeaderInfo& header_info, |
|
Ryan Hamilton
2013/03/14 15:29:45
Yak: Can you rename this to ConstructSpdyFrame (or
akalin
2013/03/15 17:28:56
Done. search-and-replaced packet with frame in a b
| |
| 114 // the header value pairs. | 119 scoped_ptr<SpdyHeaderBlock> headers); |
| 120 | |
| 121 // Construct a SPDY packet. | |
| 115 // |extra_headers| are the extra header-value pairs, which typically | 122 // |extra_headers| are the extra header-value pairs, which typically |
| 116 // will vary the most between calls. | 123 // will vary the most between calls. |
| 117 // |tail| is any (relatively constant) header-value pairs to add. | 124 // |tail| is any (relatively constant) header-value pairs to add. |
| 118 // |buffer| is the buffer we're filling in. | |
| 119 // Returns a SpdyFrame. | 125 // Returns a SpdyFrame. |
| 120 SpdyFrame* ConstructSpdyPacket(const SpdyHeaderInfo& header_info, | 126 SpdyFrame* ConstructSpdyPacket(const SpdyHeaderInfo& header_info, |
| 121 const char* const extra_headers[], | 127 const char* const extra_headers[], |
| 122 int extra_header_count, | 128 int extra_header_count, |
| 123 const char* const tail[], | 129 const char* const tail[], |
| 124 int tail_header_count); | 130 int tail_header_count); |
| 125 | 131 |
| 126 // Construct a generic SpdyControlFrame. | 132 // Construct a generic SpdyControlFrame. |
| 127 SpdyFrame* ConstructSpdyControlFrame(const char* const extra_headers[], | 133 SpdyFrame* ConstructSpdyControlFrame(const char* const extra_headers[], |
| 128 int extra_header_count, | 134 int extra_header_count, |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 417 SpdySessionPool* const pool_; | 423 SpdySessionPool* const pool_; |
| 418 | 424 |
| 419 DISALLOW_COPY_AND_ASSIGN(SpdySessionPoolPeer); | 425 DISALLOW_COPY_AND_ASSIGN(SpdySessionPoolPeer); |
| 420 }; | 426 }; |
| 421 | 427 |
| 422 } // namespace test_spdy2 | 428 } // namespace test_spdy2 |
| 423 | 429 |
| 424 } // namespace net | 430 } // namespace net |
| 425 | 431 |
| 426 #endif // NET_SPDY_SPDY_TEST_UTIL_SPDY2_H_ | 432 #endif // NET_SPDY_SPDY_TEST_UTIL_SPDY2_H_ |
| OLD | NEW |