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

Side by Side Diff: net/http/http_stream_factory_test_util.cc

Issue 1952423002: JobController 2: Remove reference between HttpStreamFactoryImpl::Jobs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Job_Controller_1
Patch Set: use unmocked Job::Start() and asyncronous Proxy resolution in tests Created 4 years, 5 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
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 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 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/http/http_stream_factory_test_util.h" 5 #include "net/http/http_stream_factory_test_util.h"
6 6
7 #include "net/proxy/proxy_info.h" 7 #include "net/proxy/proxy_info.h"
8 8
9 using ::testing::_; 9 using ::testing::_;
10 10
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 server_ssl_config, 55 server_ssl_config,
56 proxy_ssl_config, 56 proxy_ssl_config,
57 destination, 57 destination,
58 origin_url, 58 origin_url,
59 alternative_service, 59 alternative_service,
60 net_log) {} 60 net_log) {}
61 61
62 MockHttpStreamFactoryImplJob::~MockHttpStreamFactoryImplJob() {} 62 MockHttpStreamFactoryImplJob::~MockHttpStreamFactoryImplJob() {}
63 63
64 TestJobFactory::TestJobFactory() 64 TestJobFactory::TestJobFactory()
65 : main_job_(nullptr), alternative_job_(nullptr) {} 65 : main_job_(nullptr),
66 alternative_job_(nullptr),
67 disable_mocked_start_(false),
68 override_main_job_url_(false) {}
66 69
67 TestJobFactory::~TestJobFactory() {} 70 TestJobFactory::~TestJobFactory() {}
68 71
69 HttpStreamFactoryImpl::Job* TestJobFactory::CreateJob( 72 HttpStreamFactoryImpl::Job* TestJobFactory::CreateJob(
70 HttpStreamFactoryImpl::Job::Delegate* delegate, 73 HttpStreamFactoryImpl::Job::Delegate* delegate,
71 HttpStreamFactoryImpl::JobType job_type, 74 HttpStreamFactoryImpl::JobType job_type,
72 HttpNetworkSession* session, 75 HttpNetworkSession* session,
73 const HttpRequestInfo& request_info, 76 const HttpRequestInfo& request_info,
74 RequestPriority priority, 77 RequestPriority priority,
75 const SSLConfig& server_ssl_config, 78 const SSLConfig& server_ssl_config,
76 const SSLConfig& proxy_ssl_config, 79 const SSLConfig& proxy_ssl_config,
77 HostPortPair destination, 80 HostPortPair destination,
78 GURL origin_url, 81 GURL origin_url,
79 NetLog* net_log) { 82 NetLog* net_log) {
80 DCHECK(!main_job_); 83 DCHECK(!main_job_);
84
85 if (override_main_job_url_)
86 origin_url = main_job_alternative_url_;
87
81 main_job_ = new MockHttpStreamFactoryImplJob( 88 main_job_ = new MockHttpStreamFactoryImplJob(
82 delegate, job_type, session, request_info, priority, SSLConfig(), 89 delegate, job_type, session, request_info, priority, SSLConfig(),
83 SSLConfig(), destination, origin_url, nullptr); 90 SSLConfig(), destination, origin_url, nullptr);
84 91
85 EXPECT_CALL(*main_job_, Start(_)).Times(1); 92 if (disable_mocked_start_) {
93 EXPECT_CALL(*main_job_, Start(_))
94 .WillOnce(
95 Invoke(main_job_, &MockHttpStreamFactoryImplJob::UnmockedStart));
96 } else {
97 EXPECT_CALL(*main_job_, Start(_)).Times(1);
98 }
86 99
87 return main_job_; 100 return main_job_;
88 } 101 }
89 102
90 HttpStreamFactoryImpl::Job* TestJobFactory::CreateJob( 103 HttpStreamFactoryImpl::Job* TestJobFactory::CreateJob(
91 HttpStreamFactoryImpl::Job::Delegate* delegate, 104 HttpStreamFactoryImpl::Job::Delegate* delegate,
92 HttpStreamFactoryImpl::JobType job_type, 105 HttpStreamFactoryImpl::JobType job_type,
93 HttpNetworkSession* session, 106 HttpNetworkSession* session,
94 const HttpRequestInfo& request_info, 107 const HttpRequestInfo& request_info,
95 RequestPriority priority, 108 RequestPriority priority,
96 const SSLConfig& server_ssl_config, 109 const SSLConfig& server_ssl_config,
97 const SSLConfig& proxy_ssl_config, 110 const SSLConfig& proxy_ssl_config,
98 HostPortPair destination, 111 HostPortPair destination,
99 GURL origin_url, 112 GURL origin_url,
100 AlternativeService alternative_service, 113 AlternativeService alternative_service,
101 NetLog* net_log) { 114 NetLog* net_log) {
102 DCHECK(!alternative_job_); 115 DCHECK(!alternative_job_);
103 alternative_job_ = new MockHttpStreamFactoryImplJob( 116 alternative_job_ = new MockHttpStreamFactoryImplJob(
104 delegate, job_type, session, request_info, priority, SSLConfig(), 117 delegate, job_type, session, request_info, priority, SSLConfig(),
105 SSLConfig(), destination, origin_url, alternative_service, nullptr); 118 SSLConfig(), destination, origin_url, alternative_service, nullptr);
106 119
107 EXPECT_CALL(*alternative_job_, Start(_)).Times(1); 120 if (disable_mocked_start_) {
121 EXPECT_CALL(*alternative_job_, Start(_))
122 .WillOnce(Invoke(alternative_job_,
123 &MockHttpStreamFactoryImplJob::UnmockedStart));
124 } else {
125 EXPECT_CALL(*alternative_job_, Start(_)).Times(1);
126 }
108 127
109 return alternative_job_; 128 return alternative_job_;
110 } 129 }
111 130
112 } // namespace net 131 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698