OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_SOCKET_SOCKET_TEST_UTIL_H_ | 5 #ifndef NET_SOCKET_SOCKET_TEST_UTIL_H_ |
6 #define NET_SOCKET_SOCKET_TEST_UTIL_H_ | 6 #define NET_SOCKET_SOCKET_TEST_UTIL_H_ |
7 | 7 |
8 #include <cstring> | 8 #include <cstring> |
9 #include <deque> | 9 #include <deque> |
10 #include <string> | 10 #include <string> |
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 | 686 |
687 protected: | 687 protected: |
688 virtual ~MockSOCKSClientSocketPool(); | 688 virtual ~MockSOCKSClientSocketPool(); |
689 | 689 |
690 private: | 690 private: |
691 const scoped_refptr<TCPClientSocketPool> tcp_pool_; | 691 const scoped_refptr<TCPClientSocketPool> tcp_pool_; |
692 | 692 |
693 DISALLOW_COPY_AND_ASSIGN(MockSOCKSClientSocketPool); | 693 DISALLOW_COPY_AND_ASSIGN(MockSOCKSClientSocketPool); |
694 }; | 694 }; |
695 | 695 |
696 struct MockHttpAuthControllerData { | |
697 MockHttpAuthControllerData(std::string header) : auth_header(header) {} | |
698 | |
699 std::string auth_header; | |
700 }; | |
701 | |
702 class MockHttpAuthController : public HttpAuthController { | |
703 public: | |
704 MockHttpAuthController(); | |
705 void SetMockAuthControllerData(struct MockHttpAuthControllerData* data, | |
706 size_t data_length); | |
707 | |
708 // HttpAuthController methods. | |
709 virtual int MaybeGenerateAuthToken(const HttpRequestInfo* request, | |
710 CompletionCallback* callback, | |
711 const BoundNetLog& net_log); | |
712 virtual void AddAuthorizationHeader( | |
713 HttpRequestHeaders* authorization_headers); | |
714 virtual int HandleAuthChallenge(scoped_refptr<HttpResponseHeaders> headers, | |
715 bool do_not_send_server_auth, | |
716 bool establishing_tunnel, | |
717 const BoundNetLog& net_log); | |
718 virtual void ResetAuth(const std::wstring& username, | |
719 const std::wstring& password); | |
720 virtual bool HaveAuthHandler() const; | |
721 virtual bool HaveAuth() const; | |
722 | |
723 private: | |
724 virtual ~MockHttpAuthController() {} | |
725 const struct MockHttpAuthControllerData& CurrentData() const { | |
726 DCHECK(data_index_ < data_count_); | |
727 return data_[data_index_]; | |
728 } | |
729 | |
730 MockHttpAuthControllerData* data_; | |
731 size_t data_index_; | |
732 size_t data_count_; | |
733 }; | |
734 | |
735 // Constants for a successful SOCKS v5 handshake. | 696 // Constants for a successful SOCKS v5 handshake. |
736 extern const char kSOCKS5GreetRequest[]; | 697 extern const char kSOCKS5GreetRequest[]; |
737 extern const int kSOCKS5GreetRequestLength; | 698 extern const int kSOCKS5GreetRequestLength; |
738 | 699 |
739 extern const char kSOCKS5GreetResponse[]; | 700 extern const char kSOCKS5GreetResponse[]; |
740 extern const int kSOCKS5GreetResponseLength; | 701 extern const int kSOCKS5GreetResponseLength; |
741 | 702 |
742 extern const char kSOCKS5OkRequest[]; | 703 extern const char kSOCKS5OkRequest[]; |
743 extern const int kSOCKS5OkRequestLength; | 704 extern const int kSOCKS5OkRequestLength; |
744 | 705 |
745 extern const char kSOCKS5OkResponse[]; | 706 extern const char kSOCKS5OkResponse[]; |
746 extern const int kSOCKS5OkResponseLength; | 707 extern const int kSOCKS5OkResponseLength; |
747 | 708 |
748 } // namespace net | 709 } // namespace net |
749 | 710 |
750 #endif // NET_SOCKET_SOCKET_TEST_UTIL_H_ | 711 #endif // NET_SOCKET_SOCKET_TEST_UTIL_H_ |
OLD | NEW |