Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: net/spdy/spdy_test_util.cc

Issue 6341004: More net/ reordering. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Window gyp dependency Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/spdy/spdy_test_util.h ('k') | net/test/test_server.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "net/spdy/spdy_test_util.h" 5 #include "net/spdy/spdy_test_util.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 DCHECK_LE(total_len, buff_len); 845 DCHECK_LE(total_len, buff_len);
846 char* ptr = buff; 846 char* ptr = buff;
847 for (int i = 0; i < num_frames; ++i) { 847 for (int i = 0; i < num_frames; ++i) {
848 int len = frames[i]->length() + spdy::SpdyFrame::size(); 848 int len = frames[i]->length() + spdy::SpdyFrame::size();
849 memcpy(ptr, frames[i]->data(), len); 849 memcpy(ptr, frames[i]->data(), len);
850 ptr += len; 850 ptr += len;
851 } 851 }
852 return total_len; 852 return total_len;
853 } 853 }
854 854
855 SpdySessionDependencies::SpdySessionDependencies()
856 : host_resolver(new MockHostResolver),
857 cert_verifier(new CertVerifier),
858 proxy_service(ProxyService::CreateDirect()),
859 ssl_config_service(new SSLConfigServiceDefaults),
860 socket_factory(new MockClientSocketFactory),
861 deterministic_socket_factory(new DeterministicMockClientSocketFactory),
862 http_auth_handler_factory(
863 HttpAuthHandlerFactory::CreateDefault(host_resolver.get())) {
864 // Note: The CancelledTransaction test does cleanup by running all
865 // tasks in the message loop (RunAllPending). Unfortunately, that
866 // doesn't clean up tasks on the host resolver thread; and
867 // TCPConnectJob is currently not cancellable. Using synchronous
868 // lookups allows the test to shutdown cleanly. Until we have
869 // cancellable TCPConnectJobs, use synchronous lookups.
870 host_resolver->set_synchronous_mode(true);
871 }
872
873 SpdySessionDependencies::SpdySessionDependencies(ProxyService* proxy_service)
874 : host_resolver(new MockHostResolver),
875 cert_verifier(new CertVerifier),
876 proxy_service(proxy_service),
877 ssl_config_service(new SSLConfigServiceDefaults),
878 socket_factory(new MockClientSocketFactory),
879 deterministic_socket_factory(new DeterministicMockClientSocketFactory),
880 http_auth_handler_factory(
881 HttpAuthHandlerFactory::CreateDefault(host_resolver.get())) {}
882
883 SpdySessionDependencies::~SpdySessionDependencies() {}
884
885 // static
886 HttpNetworkSession* SpdySessionDependencies::SpdyCreateSession(
887 SpdySessionDependencies* session_deps) {
888 return new HttpNetworkSession(session_deps->host_resolver.get(),
889 session_deps->cert_verifier.get(),
890 NULL /* dnsrr_resolver */,
891 NULL /* dns_cert_checker */,
892 NULL /* ssl_host_info_factory */,
893 session_deps->proxy_service,
894 session_deps->socket_factory.get(),
895 session_deps->ssl_config_service,
896 new SpdySessionPool(NULL),
897 session_deps->http_auth_handler_factory.get(),
898 NULL,
899 NULL);
900 }
901
902 // static
903 HttpNetworkSession* SpdySessionDependencies::SpdyCreateSessionDeterministic(
904 SpdySessionDependencies* session_deps) {
905 return new HttpNetworkSession(session_deps->host_resolver.get(),
906 session_deps->cert_verifier.get(),
907 NULL /* dnsrr_resolver */,
908 NULL /* dns_cert_checker */,
909 NULL /* ssl_host_info_factory */,
910 session_deps->proxy_service,
911 session_deps->
912 deterministic_socket_factory.get(),
913 session_deps->ssl_config_service,
914 new SpdySessionPool(NULL),
915 session_deps->http_auth_handler_factory.get(),
916 NULL,
917 NULL);
918 }
919
920 SpdyURLRequestContext::SpdyURLRequestContext() {
921 host_resolver_ = new MockHostResolver();
922 cert_verifier_ = new CertVerifier;
923 proxy_service_ = ProxyService::CreateDirect();
924 ssl_config_service_ = new SSLConfigServiceDefaults;
925 http_auth_handler_factory_ = HttpAuthHandlerFactory::CreateDefault(
926 host_resolver_);
927 http_transaction_factory_ = new HttpCache(
928 new HttpNetworkLayer(&socket_factory_,
929 host_resolver_,
930 cert_verifier_,
931 NULL /* dnsrr_resolver */,
932 NULL /* dns_cert_checker */,
933 NULL /* ssl_host_info_factory */,
934 proxy_service_,
935 ssl_config_service_,
936 new SpdySessionPool(NULL),
937 http_auth_handler_factory_,
938 network_delegate_,
939 NULL),
940 NULL /* net_log */,
941 HttpCache::DefaultBackend::InMemory(0));
942 }
943
944 SpdyURLRequestContext::~SpdyURLRequestContext() {
945 delete http_transaction_factory_;
946 delete http_auth_handler_factory_;
947 delete cert_verifier_;
948 delete host_resolver_;
949 }
950
855 const SpdyHeaderInfo make_spdy_header(spdy::SpdyControlType type) { 951 const SpdyHeaderInfo make_spdy_header(spdy::SpdyControlType type) {
856 const SpdyHeaderInfo kHeader = { 952 const SpdyHeaderInfo kHeader = {
857 type, // Kind = Syn 953 type, // Kind = Syn
858 1, // Stream ID 954 1, // Stream ID
859 0, // Associated stream ID 955 0, // Associated stream ID
860 2, // Priority 956 2, // Priority
861 spdy::CONTROL_FLAG_FIN, // Control Flags 957 spdy::CONTROL_FLAG_FIN, // Control Flags
862 false, // Compressed 958 false, // Compressed
863 spdy::INVALID, // Status 959 spdy::INVALID, // Status
864 NULL, // Data 960 NULL, // Data
865 0, // Length 961 0, // Length
866 spdy::DATA_FLAG_NONE // Data Flags 962 spdy::DATA_FLAG_NONE // Data Flags
867 }; 963 };
868 return kHeader; 964 return kHeader;
869 } 965 }
870 } // namespace net 966 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_test_util.h ('k') | net/test/test_server.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698