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> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
15 #include "base/callback.h" | 15 #include "base/callback.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/scoped_ptr.h" | 17 #include "base/scoped_ptr.h" |
18 #include "base/scoped_vector.h" | 18 #include "base/scoped_vector.h" |
| 19 #include "base/string16.h" |
19 #include "net/base/address_list.h" | 20 #include "net/base/address_list.h" |
20 #include "net/base/io_buffer.h" | 21 #include "net/base/io_buffer.h" |
21 #include "net/base/net_errors.h" | 22 #include "net/base/net_errors.h" |
22 #include "net/base/net_log.h" | 23 #include "net/base/net_log.h" |
23 #include "net/base/ssl_config_service.h" | 24 #include "net/base/ssl_config_service.h" |
24 #include "net/base/test_completion_callback.h" | 25 #include "net/base/test_completion_callback.h" |
25 #include "net/http/http_auth_controller.h" | 26 #include "net/http/http_auth_controller.h" |
26 #include "net/http/http_proxy_client_socket_pool.h" | 27 #include "net/http/http_proxy_client_socket_pool.h" |
27 #include "net/socket/client_socket_factory.h" | 28 #include "net/socket/client_socket_factory.h" |
28 #include "net/socket/client_socket_handle.h" | 29 #include "net/socket/client_socket_handle.h" |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 | 630 |
630 DISALLOW_COPY_AND_ASSIGN(MockConnectJob); | 631 DISALLOW_COPY_AND_ASSIGN(MockConnectJob); |
631 }; | 632 }; |
632 | 633 |
633 MockTCPClientSocketPool( | 634 MockTCPClientSocketPool( |
634 int max_sockets, | 635 int max_sockets, |
635 int max_sockets_per_group, | 636 int max_sockets_per_group, |
636 const scoped_refptr<ClientSocketPoolHistograms>& histograms, | 637 const scoped_refptr<ClientSocketPoolHistograms>& histograms, |
637 ClientSocketFactory* socket_factory); | 638 ClientSocketFactory* socket_factory); |
638 | 639 |
639 int release_count() const { return release_count_; }; | 640 int release_count() const { return release_count_; } |
640 int cancel_count() const { return cancel_count_; }; | 641 int cancel_count() const { return cancel_count_; } |
641 | 642 |
642 // TCPClientSocketPool methods. | 643 // TCPClientSocketPool methods. |
643 virtual int RequestSocket(const std::string& group_name, | 644 virtual int RequestSocket(const std::string& group_name, |
644 const void* socket_params, | 645 const void* socket_params, |
645 RequestPriority priority, | 646 RequestPriority priority, |
646 ClientSocketHandle* handle, | 647 ClientSocketHandle* handle, |
647 CompletionCallback* callback, | 648 CompletionCallback* callback, |
648 const BoundNetLog& net_log); | 649 const BoundNetLog& net_log); |
649 | 650 |
650 virtual void CancelRequest(const std::string& group_name, | 651 virtual void CancelRequest(const std::string& group_name, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 protected: | 689 protected: |
689 virtual ~MockSOCKSClientSocketPool(); | 690 virtual ~MockSOCKSClientSocketPool(); |
690 | 691 |
691 private: | 692 private: |
692 const scoped_refptr<TCPClientSocketPool> tcp_pool_; | 693 const scoped_refptr<TCPClientSocketPool> tcp_pool_; |
693 | 694 |
694 DISALLOW_COPY_AND_ASSIGN(MockSOCKSClientSocketPool); | 695 DISALLOW_COPY_AND_ASSIGN(MockSOCKSClientSocketPool); |
695 }; | 696 }; |
696 | 697 |
697 struct MockHttpAuthControllerData { | 698 struct MockHttpAuthControllerData { |
698 MockHttpAuthControllerData(std::string header) : auth_header(header) {} | 699 explicit MockHttpAuthControllerData(std::string header) |
| 700 : auth_header(header) {} |
699 | 701 |
700 std::string auth_header; | 702 std::string auth_header; |
701 }; | 703 }; |
702 | 704 |
703 class MockHttpAuthController : public HttpAuthController { | 705 class MockHttpAuthController : public HttpAuthController { |
704 public: | 706 public: |
705 MockHttpAuthController(); | 707 MockHttpAuthController(); |
706 void SetMockAuthControllerData(struct MockHttpAuthControllerData* data, | 708 void SetMockAuthControllerData(struct MockHttpAuthControllerData* data, |
707 size_t data_length); | 709 size_t data_length); |
708 | 710 |
709 // HttpAuthController methods. | 711 // HttpAuthController methods. |
710 virtual int MaybeGenerateAuthToken(const HttpRequestInfo* request, | 712 virtual int MaybeGenerateAuthToken(const HttpRequestInfo* request, |
711 CompletionCallback* callback, | 713 CompletionCallback* callback, |
712 const BoundNetLog& net_log); | 714 const BoundNetLog& net_log); |
713 virtual void AddAuthorizationHeader( | 715 virtual void AddAuthorizationHeader( |
714 HttpRequestHeaders* authorization_headers); | 716 HttpRequestHeaders* authorization_headers); |
715 virtual int HandleAuthChallenge(scoped_refptr<HttpResponseHeaders> headers, | 717 virtual int HandleAuthChallenge(scoped_refptr<HttpResponseHeaders> headers, |
716 bool do_not_send_server_auth, | 718 bool do_not_send_server_auth, |
717 bool establishing_tunnel, | 719 bool establishing_tunnel, |
718 const BoundNetLog& net_log); | 720 const BoundNetLog& net_log); |
719 virtual void ResetAuth(const std::wstring& username, | 721 virtual void ResetAuth(const string16& username, |
720 const std::wstring& password); | 722 const string16& password); |
721 virtual bool HaveAuthHandler() const; | 723 virtual bool HaveAuthHandler() const; |
722 virtual bool HaveAuth() const; | 724 virtual bool HaveAuth() const; |
723 | 725 |
724 private: | 726 private: |
725 virtual ~MockHttpAuthController() {} | 727 virtual ~MockHttpAuthController() {} |
726 const struct MockHttpAuthControllerData& CurrentData() const { | 728 const struct MockHttpAuthControllerData& CurrentData() const { |
727 DCHECK(data_index_ < data_count_); | 729 DCHECK(data_index_ < data_count_); |
728 return data_[data_index_]; | 730 return data_[data_index_]; |
729 } | 731 } |
730 | 732 |
(...skipping 11 matching lines...) Expand all Loading... |
742 | 744 |
743 extern const char kSOCKS5OkRequest[]; | 745 extern const char kSOCKS5OkRequest[]; |
744 extern const int kSOCKS5OkRequestLength; | 746 extern const int kSOCKS5OkRequestLength; |
745 | 747 |
746 extern const char kSOCKS5OkResponse[]; | 748 extern const char kSOCKS5OkResponse[]; |
747 extern const int kSOCKS5OkResponseLength; | 749 extern const int kSOCKS5OkResponseLength; |
748 | 750 |
749 } // namespace net | 751 } // namespace net |
750 | 752 |
751 #endif // NET_SOCKET_SOCKET_TEST_UTIL_H_ | 753 #endif // NET_SOCKET_SOCKET_TEST_UTIL_H_ |
OLD | NEW |