| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "net/http/http_stream_factory_test_util.h" |
| 6 |
| 7 #include "net/proxy/proxy_info.h" |
| 8 |
| 9 namespace net { |
| 10 TestHttpStreamRequestDelegate::TestHttpStreamRequestDelegate() {} |
| 11 |
| 12 TestHttpStreamRequestDelegate::~TestHttpStreamRequestDelegate() {} |
| 13 |
| 14 TestHttpStreamFactoryImplJob::TestHttpStreamFactoryImplJob( |
| 15 HttpStreamFactoryImpl::Job::Delegate* delegate, |
| 16 HttpStreamFactoryImpl::JobType job_type, |
| 17 HttpNetworkSession* session, |
| 18 const HttpRequestInfo& request_info, |
| 19 RequestPriority priority, |
| 20 const SSLConfig& server_ssl_config, |
| 21 const SSLConfig& proxy_ssl_config, |
| 22 HostPortPair destination, |
| 23 GURL origin_url, |
| 24 NetLog* net_log) |
| 25 : HttpStreamFactoryImpl::Job(delegate, |
| 26 job_type, |
| 27 session, |
| 28 request_info, |
| 29 priority, |
| 30 server_ssl_config, |
| 31 proxy_ssl_config, |
| 32 destination, |
| 33 origin_url, |
| 34 net_log) {} |
| 35 |
| 36 TestHttpStreamFactoryImplJob::TestHttpStreamFactoryImplJob( |
| 37 HttpStreamFactoryImpl::Job::Delegate* delegate, |
| 38 HttpStreamFactoryImpl::JobType job_type, |
| 39 HttpNetworkSession* session, |
| 40 const HttpRequestInfo& request_info, |
| 41 RequestPriority priority, |
| 42 const SSLConfig& server_ssl_config, |
| 43 const SSLConfig& proxy_ssl_config, |
| 44 HostPortPair destination, |
| 45 GURL origin_url, |
| 46 AlternativeService alternative_service, |
| 47 NetLog* net_log) |
| 48 : HttpStreamFactoryImpl::Job(delegate, |
| 49 job_type, |
| 50 session, |
| 51 request_info, |
| 52 priority, |
| 53 server_ssl_config, |
| 54 proxy_ssl_config, |
| 55 destination, |
| 56 origin_url, |
| 57 alternative_service, |
| 58 net_log) {} |
| 59 |
| 60 TestHttpStreamFactoryImplJob::~TestHttpStreamFactoryImplJob() {} |
| 61 |
| 62 TestJobControllerPeer::TestJobControllerPeer( |
| 63 NextProto protocol, |
| 64 TestHttpStreamRequestDelegate* request_delegate) |
| 65 : session_deps_(protocol, ProxyService::CreateDirect()), |
| 66 request_delegate_(request_delegate), |
| 67 main_job_(nullptr), |
| 68 alternative_job_(nullptr) { |
| 69 session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps_); |
| 70 factory_ = |
| 71 static_cast<HttpStreamFactoryImpl*>(session_->http_stream_factory()); |
| 72 job_controller_ = new HttpStreamFactoryImpl::JobController( |
| 73 factory_, request_delegate_, session_.get()); |
| 74 factory_->job_controller_set_.insert(base::WrapUnique(job_controller_)); |
| 75 } |
| 76 |
| 77 TestJobControllerPeer::~TestJobControllerPeer() {} |
| 78 |
| 79 void TestJobControllerPeer::CreateRequest(HttpRequestInfo request_info) { |
| 80 request_.reset(new HttpStreamFactoryImpl::Request( |
| 81 request_info.url, job_controller_, request_delegate_, nullptr, |
| 82 BoundNetLog(), HttpStreamFactoryImpl::Request::HTTP_STREAM)); |
| 83 job_controller_->request_ = request_.get(); |
| 84 } |
| 85 |
| 86 GURL TestJobControllerPeer::ApplyHostMappingRules(const GURL& url, |
| 87 HostPortPair* endpoint) { |
| 88 return job_controller_->ApplyHostMappingRules(url, endpoint); |
| 89 } |
| 90 |
| 91 void TestJobControllerPeer::ClearMainJob() { |
| 92 factory_->request_map_.erase(job_controller_->main_job_.get()); |
| 93 job_controller_->main_job_.reset(); |
| 94 } |
| 95 |
| 96 void TestJobControllerPeer::SetMainJob(HttpStreamFactoryImpl::Job* main_job) { |
| 97 job_controller_->main_job_.reset(main_job); |
| 98 job_controller_->AttachJob(main_job); |
| 99 } |
| 100 |
| 101 void TestJobControllerPeer::SetAlternativeJob( |
| 102 HttpStreamFactoryImpl::Job* alternative_job) { |
| 103 job_controller_->alternative_job_.reset(alternative_job); |
| 104 job_controller_->AttachJob(alternative_job); |
| 105 } |
| 106 |
| 107 void TestJobControllerPeer::OnStreamFailed(HttpStreamFactoryImpl::Job* job, |
| 108 int status, |
| 109 const SSLConfig& used_ssl_config, |
| 110 SSLFailureState ssl_failure_state) { |
| 111 job_controller_->OnStreamFailed(job, status, used_ssl_config, |
| 112 ssl_failure_state); |
| 113 } |
| 114 |
| 115 void TestJobControllerPeer::OnStreamReady(HttpStreamFactoryImpl::Job* job, |
| 116 const SSLConfig& used_ssl_config, |
| 117 const ProxyInfo& used_proxy_info) { |
| 118 job_controller_->OnStreamReady(job, used_ssl_config, used_proxy_info); |
| 119 } |
| 120 |
| 121 void TestJobControllerPeer::MaybeNotifyFactoryOfCompletion() { |
| 122 job_controller_->MaybeNotifyFactoryOfCompletion(); |
| 123 } |
| 124 |
| 125 } // namespace net |
| OLD | NEW |