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