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

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

Issue 1941083002: JobController 1: Adding a new class HttpStreamFactoryImpl::JobController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add JobFactory interface in JobController, remove JobControllerPeer Created 4 years, 6 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
(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 #ifndef NET_HTTP_HTTP_STREAM_FACTORY_TEST_UTIL_H_
6 #define NET_HTTP_HTTP_STREAM_FACTORY_TEST_UTIL_H_
7
8 #include "base/memory/ptr_util.h"
9 #include "net/http/http_stream.h"
10 #include "net/http/http_stream_factory.h"
11 #include "net/http/http_stream_factory_impl.h"
12 #include "net/http/http_stream_factory_impl_job.h"
13 #include "net/http/http_stream_factory_impl_job_controller.h"
14 #include "net/proxy/proxy_info.h"
15 #include "net/proxy/proxy_service.h"
16 #include "net/spdy/spdy_test_util_common.h"
17 #include "testing/gmock/include/gmock/gmock.h"
18
19 namespace net {
20
21 // This delegate does nothing when called.
22 class TestHttpStreamRequestDelegate : public HttpStreamRequest::Delegate {
Ryan Hamilton 2016/06/06 17:57:32 Since these classes MOCK_ the various methods, ins
Zhongyi Shi 2016/06/06 22:50:56 Done.
23 public:
24 TestHttpStreamRequestDelegate();
25
26 ~TestHttpStreamRequestDelegate() override;
27
28 MOCK_METHOD3(OnStreamReady,
29 void(const SSLConfig& used_ssl_config,
30 const ProxyInfo& used_proxy_info,
31 HttpStream* stream));
32
33 void OnBidirectionalStreamImplReady(
34 const SSLConfig& used_ssl_config,
35 const ProxyInfo& used_proxy_info,
36 BidirectionalStreamImpl* stream) override {}
37
38 void OnWebSocketHandshakeStreamReady(
39 const SSLConfig& used_ssl_config,
40 const ProxyInfo& used_proxy_info,
41 WebSocketHandshakeStreamBase* stream) override {}
42
43 MOCK_METHOD3(OnStreamFailed,
44 void(int status,
45 const SSLConfig& used_ssl_config,
46 SSLFailureState ssl_failure_state));
47
48 MOCK_METHOD3(OnCertificateError,
49 void(int status,
50 const SSLConfig& used_ssl_config,
51 const SSLInfo& ssl_info));
52
53 MOCK_METHOD4(OnNeedsProxyAuth,
54 void(const HttpResponseInfo& proxy_response,
55 const SSLConfig& used_ssl_config,
56 const ProxyInfo& used_proxy_info,
57 HttpAuthController* auth_controller));
58
59 MOCK_METHOD2(OnNeedsClientAuth,
60 void(const SSLConfig& used_ssl_config,
61 SSLCertRequestInfo* cert_info));
62
63 MOCK_METHOD4(OnHttpsProxyTunnelResponse,
64 void(const HttpResponseInfo& response_info,
65 const SSLConfig& used_ssl_config,
66 const ProxyInfo& used_proxy_info,
67 HttpStream* stream));
68
69 MOCK_METHOD0(OnQuicBroken, void());
70
71 private:
72 DISALLOW_COPY_AND_ASSIGN(TestHttpStreamRequestDelegate);
73 };
74
75 class TestHttpStreamFactoryImplJob : public HttpStreamFactoryImpl::Job {
76 public:
77 TestHttpStreamFactoryImplJob(HttpStreamFactoryImpl::Job::Delegate* delegate,
78 HttpStreamFactoryImpl::JobType job_type,
79 HttpNetworkSession* session,
80 const HttpRequestInfo& request_info,
81 RequestPriority priority,
82 const SSLConfig& server_ssl_config,
83 const SSLConfig& proxy_ssl_config,
84 HostPortPair destination,
85 GURL origin_url,
86 NetLog* net_log);
87
88 TestHttpStreamFactoryImplJob(HttpStreamFactoryImpl::Job::Delegate* delegate,
89 HttpStreamFactoryImpl::JobType job_type,
90 HttpNetworkSession* session,
91 const HttpRequestInfo& request_info,
92 RequestPriority priority,
93 const SSLConfig& server_ssl_config,
94 const SSLConfig& proxy_ssl_config,
95 HostPortPair destination,
96 GURL origin_url,
97 AlternativeService alternative_service,
98 NetLog* net_log);
99
100 ~TestHttpStreamFactoryImplJob() override;
101
102 MOCK_METHOD1(Start, void(HttpStreamRequest::StreamType stream_type));
103
104 MOCK_METHOD1(MarkOtherJobComplete, void(const Job& job));
105
106 MOCK_METHOD0(Orphan, void());
107 };
108
109 class TestJobFactory : public HttpStreamFactoryImpl::JobController::JobFactory {
110 public:
111 TestJobFactory();
112 ~TestJobFactory() override;
113
114 HttpStreamFactoryImpl::Job* CreateJob(
115 HttpStreamFactoryImpl::Job::Delegate* delegate,
116 HttpStreamFactoryImpl::JobType job_type,
117 HttpNetworkSession* session,
118 const HttpRequestInfo& request_info,
119 RequestPriority priority,
120 const SSLConfig& server_ssl_config,
121 const SSLConfig& proxy_ssl_config,
122 HostPortPair destination,
123 GURL origin_url,
124 NetLog* net_log) override;
125
126 HttpStreamFactoryImpl::Job* CreateJob(
127 HttpStreamFactoryImpl::Job::Delegate* delegate,
128 HttpStreamFactoryImpl::JobType job_type,
129 HttpNetworkSession* session,
130 const HttpRequestInfo& request_info,
131 RequestPriority priority,
132 const SSLConfig& server_ssl_config,
133 const SSLConfig& proxy_ssl_config,
134 HostPortPair destination,
135 GURL origin_url,
136 AlternativeService alternative_service,
137 NetLog* net_log) override;
138
139 TestHttpStreamFactoryImplJob* main_job() const { return main_job_; }
140 TestHttpStreamFactoryImplJob* alternative_job() const {
141 return alternative_job_;
142 }
143
144 private:
145 TestHttpStreamFactoryImplJob* main_job_;
146 TestHttpStreamFactoryImplJob* alternative_job_;
147 };
148
149 } // namespace net
150
151 #endif // NET_HTTP_HTTP_STREAM_FACTORY_TEST_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698