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/proxy_delegate.h" | |
20 #include "net/base/request_priority.h" | 21 #include "net/base/request_priority.h" |
21 #include "net/base/test_completion_callback.h" | 22 #include "net/base/test_completion_callback.h" |
22 #include "net/cert/cert_verifier.h" | 23 #include "net/cert/cert_verifier.h" |
23 #include "net/dns/mock_host_resolver.h" | 24 #include "net/dns/mock_host_resolver.h" |
24 #include "net/http/http_auth_handler_factory.h" | 25 #include "net/http/http_auth_handler_factory.h" |
25 #include "net/http/http_network_session.h" | 26 #include "net/http/http_network_session.h" |
26 #include "net/http/http_response_info.h" | 27 #include "net/http/http_response_info.h" |
27 #include "net/http/http_server_properties_impl.h" | 28 #include "net/http/http_server_properties_impl.h" |
28 #include "net/http/transport_security_state.h" | 29 #include "net/http/transport_security_state.h" |
29 #include "net/proxy/proxy_service.h" | 30 #include "net/proxy/proxy_service.h" |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
197 bool enable_ip_pooling; | 198 bool enable_ip_pooling; |
198 bool enable_compression; | 199 bool enable_compression; |
199 bool enable_ping; | 200 bool enable_ping; |
200 bool enable_user_alternate_protocol_ports; | 201 bool enable_user_alternate_protocol_ports; |
201 bool enable_npn; | 202 bool enable_npn; |
202 NextProto protocol; | 203 NextProto protocol; |
203 size_t session_max_recv_window_size; | 204 size_t session_max_recv_window_size; |
204 size_t stream_max_recv_window_size; | 205 size_t stream_max_recv_window_size; |
205 SpdySession::TimeFunc time_func; | 206 SpdySession::TimeFunc time_func; |
206 NextProtoVector next_protos; | 207 NextProtoVector next_protos; |
207 std::string trusted_spdy_proxy; | 208 scoped_ptr<ProxyDelegate> proxy_delegate; |
208 bool use_alternative_services; | 209 bool use_alternative_services; |
209 NetLog* net_log; | 210 NetLog* net_log; |
210 }; | 211 }; |
211 | 212 |
212 class SpdyURLRequestContext : public URLRequestContext { | 213 class SpdyURLRequestContext : public URLRequestContext { |
213 public: | 214 public: |
214 explicit SpdyURLRequestContext(NextProto protocol); | 215 explicit SpdyURLRequestContext(NextProto protocol); |
215 ~SpdyURLRequestContext() override; | 216 ~SpdyURLRequestContext() override; |
216 | 217 |
217 MockClientSocketFactory& socket_factory() { return socket_factory_; } | 218 MockClientSocketFactory& socket_factory() { return socket_factory_; } |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
576 | 577 |
577 const NextProto protocol_; | 578 const NextProto protocol_; |
578 const SpdyMajorVersion spdy_version_; | 579 const SpdyMajorVersion spdy_version_; |
579 GURL default_url_; | 580 GURL default_url_; |
580 bool dependency_priorities_; | 581 bool dependency_priorities_; |
581 | 582 |
582 // Track a FIFO list of the stream_id of all created requests by priority. | 583 // Track a FIFO list of the stream_id of all created requests by priority. |
583 std::map<int, std::vector<int>> priority_to_stream_id_list_; | 584 std::map<int, std::vector<int>> priority_to_stream_id_list_; |
584 }; | 585 }; |
585 | 586 |
587 class TestProxyDelegate : public ProxyDelegate { | |
588 public: | |
589 TestProxyDelegate(); | |
590 ~TestProxyDelegate() override; | |
591 | |
592 bool on_before_tunnel_request_called() const { | |
593 return on_before_tunnel_request_called_; | |
594 } | |
595 | |
596 bool on_tunnel_request_completed_called() const { | |
597 return on_tunnel_request_completed_called_; | |
598 } | |
599 | |
600 bool on_tunnel_headers_received_called() const { | |
601 return on_tunnel_headers_received_called_; | |
602 } | |
603 | |
604 void set_trusted_spdy_proxy(const net::ProxyServer& proxy_server) { | |
605 trusted_spdy_proxy_ = proxy_server; | |
606 } | |
607 | |
608 void VerifyOnTunnelRequestCompleted(const std::string& endpoint, | |
609 const std::string& proxy_server) const; | |
610 | |
611 void VerifyOnTunnelHeadersReceived(const std::string& origin, | |
612 const std::string& proxy_server, | |
613 const std::string& status_line) const; | |
614 | |
615 // ProxyDelegate implementation: | |
616 void OnResolveProxy(const GURL& url, | |
617 int load_flags, | |
618 const ProxyService& proxy_service, | |
619 ProxyInfo* result) override; | |
bengr
2016/01/26 23:23:27
Forward declare ProxyInfo.
tbansal1
2016/01/27 00:13:34
Done but is it necessary since this class is overr
| |
620 void OnTunnelConnectCompleted(const HostPortPair& endpoint, | |
621 const HostPortPair& proxy_server, | |
622 int net_error) override; | |
623 void OnFallback(const ProxyServer& bad_proxy, int net_error) override; | |
624 void OnBeforeSendHeaders(URLRequest* request, | |
bengr
2016/01/26 23:23:27
Forward declare URLRequest.
tbansal1
2016/01/27 00:13:34
Done.
| |
625 const ProxyInfo& proxy_info, | |
626 HttpRequestHeaders* headers) override; | |
bengr
2016/01/26 23:23:26
Forward declare HttpRequestHeaders.
tbansal1
2016/01/27 00:13:34
Done.
| |
627 void OnBeforeTunnelRequest(const HostPortPair& proxy_server, | |
628 HttpRequestHeaders* extra_headers) override; | |
629 void OnTunnelHeadersReceived( | |
630 const HostPortPair& origin, | |
631 const HostPortPair& proxy_server, | |
632 const HttpResponseHeaders& response_headers) override; | |
bengr
2016/01/26 23:23:26
Forward declare HttpResponseHeaders.
tbansal1
2016/01/27 00:13:34
Done.
| |
633 bool IsTrustedSpdyProxy(const net::ProxyServer& proxy_server) const override; | |
634 | |
635 private: | |
636 bool on_before_tunnel_request_called_; | |
637 bool on_tunnel_request_completed_called_; | |
638 bool on_tunnel_headers_received_called_; | |
639 net::ProxyServer trusted_spdy_proxy_; | |
bengr
2016/01/26 23:23:27
#include "net/proxy/proxy_server.h"
tbansal1
2016/01/27 00:13:34
Done.
| |
640 HostPortPair on_tunnel_request_completed_endpoint_; | |
bengr
2016/01/26 23:23:26
#include "net/base/host_port_pair.h"
tbansal1
2016/01/27 00:13:34
Done.
| |
641 HostPortPair on_tunnel_request_completed_proxy_server_; | |
642 HostPortPair on_tunnel_headers_received_origin_; | |
643 HostPortPair on_tunnel_headers_received_proxy_server_; | |
644 std::string on_tunnel_headers_received_status_line_; | |
645 }; | |
646 | |
586 } // namespace net | 647 } // namespace net |
587 | 648 |
588 #endif // NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ | 649 #endif // NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ |
OLD | NEW |