OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_COMMON_H_ | 5 #ifndef NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ |
6 #define NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ | 6 #define NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "crypto/ec_private_key.h" | 17 #include "crypto/ec_private_key.h" |
18 #include "crypto/ec_signature_creator.h" | 18 #include "crypto/ec_signature_creator.h" |
19 #include "net/base/completion_callback.h" | 19 #include "net/base/completion_callback.h" |
20 #include "net/base/host_port_pair.h" | |
21 #include "net/base/proxy_delegate.h" | |
20 #include "net/base/request_priority.h" | 22 #include "net/base/request_priority.h" |
21 #include "net/base/test_completion_callback.h" | 23 #include "net/base/test_completion_callback.h" |
22 #include "net/cert/cert_verifier.h" | 24 #include "net/cert/cert_verifier.h" |
23 #include "net/dns/mock_host_resolver.h" | 25 #include "net/dns/mock_host_resolver.h" |
24 #include "net/http/http_auth_handler_factory.h" | 26 #include "net/http/http_auth_handler_factory.h" |
25 #include "net/http/http_network_session.h" | 27 #include "net/http/http_network_session.h" |
26 #include "net/http/http_response_info.h" | 28 #include "net/http/http_response_info.h" |
27 #include "net/http/http_server_properties_impl.h" | 29 #include "net/http/http_server_properties_impl.h" |
28 #include "net/http/transport_security_state.h" | 30 #include "net/http/transport_security_state.h" |
31 #include "net/proxy/proxy_server.h" | |
29 #include "net/proxy/proxy_service.h" | 32 #include "net/proxy/proxy_service.h" |
30 #include "net/socket/next_proto.h" | 33 #include "net/socket/next_proto.h" |
31 #include "net/socket/socket_test_util.h" | 34 #include "net/socket/socket_test_util.h" |
32 #include "net/spdy/spdy_protocol.h" | 35 #include "net/spdy/spdy_protocol.h" |
33 #include "net/ssl/ssl_config_service_defaults.h" | 36 #include "net/ssl/ssl_config_service_defaults.h" |
34 #include "net/url_request/url_request_context.h" | 37 #include "net/url_request/url_request_context.h" |
35 #include "net/url_request/url_request_context_storage.h" | 38 #include "net/url_request/url_request_context_storage.h" |
36 #include "testing/gtest/include/gtest/gtest.h" | 39 #include "testing/gtest/include/gtest/gtest.h" |
37 | 40 |
38 class GURL; | 41 class GURL; |
39 | 42 |
40 namespace net { | 43 namespace net { |
41 | 44 |
42 class BoundNetLog; | 45 class BoundNetLog; |
46 class HttpRequestHeaders; | |
47 class HttpResponseHeaders; | |
48 class ProxyInfo; | |
43 class SpdySession; | 49 class SpdySession; |
44 class SpdySessionKey; | 50 class SpdySessionKey; |
45 class SpdySessionPool; | 51 class SpdySessionPool; |
46 class SpdyStream; | 52 class SpdyStream; |
47 class SpdyStreamRequest; | 53 class SpdyStreamRequest; |
54 class URLRequest; | |
48 | 55 |
49 // Default upload data used by both, mock objects and framer when creating | 56 // Default upload data used by both, mock objects and framer when creating |
50 // data frames. | 57 // data frames. |
51 const char kDefaultURL[] = "http://www.example.org/"; | 58 const char kDefaultURL[] = "http://www.example.org/"; |
52 const char kUploadData[] = "hello!"; | 59 const char kUploadData[] = "hello!"; |
53 const int kUploadDataSize = arraysize(kUploadData)-1; | 60 const int kUploadDataSize = arraysize(kUploadData)-1; |
54 | 61 |
55 // SpdyNextProtos returns a vector of next protocols for negotiating | 62 // SpdyNextProtos returns a vector of next protocols for negotiating |
56 // SPDY. | 63 // SPDY. |
57 NextProtoVector SpdyNextProtos(); | 64 NextProtoVector SpdyNextProtos(); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
198 bool enable_ip_pooling; | 205 bool enable_ip_pooling; |
199 bool enable_compression; | 206 bool enable_compression; |
200 bool enable_ping; | 207 bool enable_ping; |
201 bool enable_user_alternate_protocol_ports; | 208 bool enable_user_alternate_protocol_ports; |
202 bool enable_npn; | 209 bool enable_npn; |
203 NextProto protocol; | 210 NextProto protocol; |
204 size_t session_max_recv_window_size; | 211 size_t session_max_recv_window_size; |
205 size_t stream_max_recv_window_size; | 212 size_t stream_max_recv_window_size; |
206 SpdySession::TimeFunc time_func; | 213 SpdySession::TimeFunc time_func; |
207 NextProtoVector next_protos; | 214 NextProtoVector next_protos; |
208 std::string trusted_spdy_proxy; | 215 scoped_ptr<ProxyDelegate> proxy_delegate; |
209 bool parse_alternative_services; | 216 bool parse_alternative_services; |
210 bool enable_alternative_service_with_different_host; | 217 bool enable_alternative_service_with_different_host; |
211 NetLog* net_log; | 218 NetLog* net_log; |
212 }; | 219 }; |
213 | 220 |
214 class SpdyURLRequestContext : public URLRequestContext { | 221 class SpdyURLRequestContext : public URLRequestContext { |
215 public: | 222 public: |
216 explicit SpdyURLRequestContext(NextProto protocol); | 223 explicit SpdyURLRequestContext(NextProto protocol); |
217 ~SpdyURLRequestContext() override; | 224 ~SpdyURLRequestContext() override; |
218 | 225 |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
578 | 585 |
579 const NextProto protocol_; | 586 const NextProto protocol_; |
580 const SpdyMajorVersion spdy_version_; | 587 const SpdyMajorVersion spdy_version_; |
581 GURL default_url_; | 588 GURL default_url_; |
582 bool dependency_priorities_; | 589 bool dependency_priorities_; |
583 | 590 |
584 // Track a FIFO list of the stream_id of all created requests by priority. | 591 // Track a FIFO list of the stream_id of all created requests by priority. |
585 std::map<int, std::vector<int>> priority_to_stream_id_list_; | 592 std::map<int, std::vector<int>> priority_to_stream_id_list_; |
586 }; | 593 }; |
587 | 594 |
595 class TestProxyDelegate : public ProxyDelegate { | |
mmenke
2016/02/03 22:43:04
This seems like a weird place for this file. Mayb
tbansal1
2016/02/04 00:36:52
net/base/test_proxy_delegate definitely makes more
| |
596 public: | |
597 TestProxyDelegate(); | |
598 ~TestProxyDelegate() override; | |
599 | |
600 bool on_before_tunnel_request_called() const { | |
601 return on_before_tunnel_request_called_; | |
602 } | |
603 | |
604 bool on_tunnel_request_completed_called() const { | |
605 return on_tunnel_request_completed_called_; | |
606 } | |
607 | |
608 bool on_tunnel_headers_received_called() const { | |
609 return on_tunnel_headers_received_called_; | |
610 } | |
611 | |
612 void set_trusted_spdy_proxy(const net::ProxyServer& proxy_server) { | |
613 trusted_spdy_proxy_ = proxy_server; | |
614 } | |
615 | |
616 void VerifyOnTunnelRequestCompleted(const std::string& endpoint, | |
617 const std::string& proxy_server) const; | |
618 | |
619 void VerifyOnTunnelHeadersReceived(const std::string& origin, | |
620 const std::string& proxy_server, | |
621 const std::string& status_line) const; | |
622 | |
623 // ProxyDelegate implementation: | |
624 void OnResolveProxy(const GURL& url, | |
625 int load_flags, | |
626 const ProxyService& proxy_service, | |
627 ProxyInfo* result) override; | |
628 void OnTunnelConnectCompleted(const HostPortPair& endpoint, | |
629 const HostPortPair& proxy_server, | |
630 int net_error) override; | |
631 void OnFallback(const ProxyServer& bad_proxy, int net_error) override; | |
632 void OnBeforeSendHeaders(URLRequest* request, | |
633 const ProxyInfo& proxy_info, | |
634 HttpRequestHeaders* headers) override; | |
635 void OnBeforeTunnelRequest(const HostPortPair& proxy_server, | |
636 HttpRequestHeaders* extra_headers) override; | |
637 void OnTunnelHeadersReceived( | |
638 const HostPortPair& origin, | |
639 const HostPortPair& proxy_server, | |
640 const HttpResponseHeaders& response_headers) override; | |
641 bool IsTrustedSpdyProxy(const net::ProxyServer& proxy_server) override; | |
642 | |
643 private: | |
644 bool on_before_tunnel_request_called_; | |
645 bool on_tunnel_request_completed_called_; | |
646 bool on_tunnel_headers_received_called_; | |
647 net::ProxyServer trusted_spdy_proxy_; | |
648 HostPortPair on_tunnel_request_completed_endpoint_; | |
649 HostPortPair on_tunnel_request_completed_proxy_server_; | |
650 HostPortPair on_tunnel_headers_received_origin_; | |
651 HostPortPair on_tunnel_headers_received_proxy_server_; | |
652 std::string on_tunnel_headers_received_status_line_; | |
653 }; | |
654 | |
588 } // namespace net | 655 } // namespace net |
589 | 656 |
590 #endif // NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ | 657 #endif // NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ |
OLD | NEW |