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

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

Issue 667923003: Standardize usage of virtual/override/final in net/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « net/http/http_stream_parser.cc ('k') | net/http/mock_allow_url_security_manager.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_HTTP_HTTP_TRANSACTION_UNITTEST_H_ 5 #ifndef NET_HTTP_HTTP_TRANSACTION_UNITTEST_H_
6 #define NET_HTTP_HTTP_TRANSACTION_UNITTEST_H_ 6 #define NET_HTTP_HTTP_TRANSACTION_UNITTEST_H_
7 7
8 #include "net/http/http_transaction.h" 8 #include "net/http/http_transaction.h"
9 9
10 #include <string> 10 #include <string>
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 // find data for the request URL. It supports IO operations that complete 161 // find data for the request URL. It supports IO operations that complete
162 // synchronously or asynchronously to help exercise different code paths in the 162 // synchronously or asynchronously to help exercise different code paths in the
163 // HttpCache implementation. 163 // HttpCache implementation.
164 class MockNetworkTransaction 164 class MockNetworkTransaction
165 : public net::HttpTransaction, 165 : public net::HttpTransaction,
166 public base::SupportsWeakPtr<MockNetworkTransaction> { 166 public base::SupportsWeakPtr<MockNetworkTransaction> {
167 typedef net::WebSocketHandshakeStreamBase::CreateHelper CreateHelper; 167 typedef net::WebSocketHandshakeStreamBase::CreateHelper CreateHelper;
168 public: 168 public:
169 MockNetworkTransaction(net::RequestPriority priority, 169 MockNetworkTransaction(net::RequestPriority priority,
170 MockNetworkLayer* factory); 170 MockNetworkLayer* factory);
171 virtual ~MockNetworkTransaction(); 171 ~MockNetworkTransaction() override;
172 172
173 virtual int Start(const net::HttpRequestInfo* request, 173 int Start(const net::HttpRequestInfo* request,
174 const net::CompletionCallback& callback, 174 const net::CompletionCallback& callback,
175 const net::BoundNetLog& net_log) override; 175 const net::BoundNetLog& net_log) override;
176 176
177 virtual int RestartIgnoringLastError( 177 int RestartIgnoringLastError(
178 const net::CompletionCallback& callback) override; 178 const net::CompletionCallback& callback) override;
179 179
180 virtual int RestartWithCertificate( 180 int RestartWithCertificate(net::X509Certificate* client_cert,
181 net::X509Certificate* client_cert, 181 const net::CompletionCallback& callback) override;
182 const net::CompletionCallback& callback) override;
183 182
184 virtual int RestartWithAuth( 183 int RestartWithAuth(const net::AuthCredentials& credentials,
185 const net::AuthCredentials& credentials, 184 const net::CompletionCallback& callback) override;
186 const net::CompletionCallback& callback) override;
187 185
188 virtual bool IsReadyToRestartForAuth() override; 186 bool IsReadyToRestartForAuth() override;
189 187
190 virtual int Read(net::IOBuffer* buf, int buf_len, 188 int Read(net::IOBuffer* buf,
191 const net::CompletionCallback& callback) override; 189 int buf_len,
190 const net::CompletionCallback& callback) override;
192 191
193 virtual void StopCaching() override; 192 void StopCaching() override;
194 193
195 virtual bool GetFullRequestHeaders( 194 bool GetFullRequestHeaders(net::HttpRequestHeaders* headers) const override;
196 net::HttpRequestHeaders* headers) const override;
197 195
198 virtual int64 GetTotalReceivedBytes() const override; 196 int64 GetTotalReceivedBytes() const override;
199 197
200 virtual void DoneReading() override; 198 void DoneReading() override;
201 199
202 virtual const net::HttpResponseInfo* GetResponseInfo() const override; 200 const net::HttpResponseInfo* GetResponseInfo() const override;
203 201
204 virtual net::LoadState GetLoadState() const override; 202 net::LoadState GetLoadState() const override;
205 203
206 virtual net::UploadProgress GetUploadProgress() const override; 204 net::UploadProgress GetUploadProgress() const override;
207 205
208 virtual void SetQuicServerInfo( 206 void SetQuicServerInfo(net::QuicServerInfo* quic_server_info) override;
209 net::QuicServerInfo* quic_server_info) override;
210 207
211 virtual bool GetLoadTimingInfo( 208 bool GetLoadTimingInfo(net::LoadTimingInfo* load_timing_info) const override;
212 net::LoadTimingInfo* load_timing_info) const override;
213 209
214 virtual void SetPriority(net::RequestPriority priority) override; 210 void SetPriority(net::RequestPriority priority) override;
215 211
216 virtual void SetWebSocketHandshakeStreamCreateHelper( 212 void SetWebSocketHandshakeStreamCreateHelper(
217 CreateHelper* create_helper) override; 213 CreateHelper* create_helper) override;
218 214
219 virtual void SetBeforeNetworkStartCallback( 215 void SetBeforeNetworkStartCallback(
220 const BeforeNetworkStartCallback& callback) override; 216 const BeforeNetworkStartCallback& callback) override;
221 217
222 virtual void SetBeforeProxyHeadersSentCallback( 218 void SetBeforeProxyHeadersSentCallback(
223 const BeforeProxyHeadersSentCallback& callback) override; 219 const BeforeProxyHeadersSentCallback& callback) override;
224 220
225 virtual int ResumeNetworkStart() override; 221 int ResumeNetworkStart() override;
226 222
227 CreateHelper* websocket_handshake_stream_create_helper() { 223 CreateHelper* websocket_handshake_stream_create_helper() {
228 return websocket_handshake_stream_create_helper_; 224 return websocket_handshake_stream_create_helper_;
229 } 225 }
230 net::RequestPriority priority() const { return priority_; } 226 net::RequestPriority priority() const { return priority_; }
231 const net::HttpRequestInfo* request() const { return request_; } 227 const net::HttpRequestInfo* request() const { return request_; }
232 228
233 private: 229 private:
234 int StartInternal(const net::HttpRequestInfo* request, 230 int StartInternal(const net::HttpRequestInfo* request,
235 const net::CompletionCallback& callback, 231 const net::CompletionCallback& callback,
(...skipping 17 matching lines...) Expand all
253 unsigned int socket_log_id_; 249 unsigned int socket_log_id_;
254 250
255 base::WeakPtrFactory<MockNetworkTransaction> weak_factory_; 251 base::WeakPtrFactory<MockNetworkTransaction> weak_factory_;
256 252
257 }; 253 };
258 254
259 class MockNetworkLayer : public net::HttpTransactionFactory, 255 class MockNetworkLayer : public net::HttpTransactionFactory,
260 public base::SupportsWeakPtr<MockNetworkLayer> { 256 public base::SupportsWeakPtr<MockNetworkLayer> {
261 public: 257 public:
262 MockNetworkLayer(); 258 MockNetworkLayer();
263 virtual ~MockNetworkLayer(); 259 ~MockNetworkLayer() override;
264 260
265 int transaction_count() const { return transaction_count_; } 261 int transaction_count() const { return transaction_count_; }
266 bool done_reading_called() const { return done_reading_called_; } 262 bool done_reading_called() const { return done_reading_called_; }
267 bool stop_caching_called() const { return stop_caching_called_; } 263 bool stop_caching_called() const { return stop_caching_called_; }
268 void TransactionDoneReading(); 264 void TransactionDoneReading();
269 void TransactionStopCaching(); 265 void TransactionStopCaching();
270 266
271 // Returns the last priority passed to CreateTransaction, or 267 // Returns the last priority passed to CreateTransaction, or
272 // DEFAULT_PRIORITY if it hasn't been called yet. 268 // DEFAULT_PRIORITY if it hasn't been called yet.
273 net::RequestPriority last_create_transaction_priority() const { 269 net::RequestPriority last_create_transaction_priority() const {
274 return last_create_transaction_priority_; 270 return last_create_transaction_priority_;
275 } 271 }
276 272
277 // Returns the last transaction created by 273 // Returns the last transaction created by
278 // CreateTransaction. Returns a NULL WeakPtr if one has not been 274 // CreateTransaction. Returns a NULL WeakPtr if one has not been
279 // created yet, or the last transaction has been destroyed, or 275 // created yet, or the last transaction has been destroyed, or
280 // ClearLastTransaction() has been called and a new transaction 276 // ClearLastTransaction() has been called and a new transaction
281 // hasn't been created yet. 277 // hasn't been created yet.
282 base::WeakPtr<MockNetworkTransaction> last_transaction() { 278 base::WeakPtr<MockNetworkTransaction> last_transaction() {
283 return last_transaction_; 279 return last_transaction_;
284 } 280 }
285 281
286 // Makes last_transaction() return NULL until the next transaction 282 // Makes last_transaction() return NULL until the next transaction
287 // is created. 283 // is created.
288 void ClearLastTransaction() { 284 void ClearLastTransaction() {
289 last_transaction_.reset(); 285 last_transaction_.reset();
290 } 286 }
291 287
292 // net::HttpTransactionFactory: 288 // net::HttpTransactionFactory:
293 virtual int CreateTransaction( 289 int CreateTransaction(net::RequestPriority priority,
294 net::RequestPriority priority, 290 scoped_ptr<net::HttpTransaction>* trans) override;
295 scoped_ptr<net::HttpTransaction>* trans) override; 291 net::HttpCache* GetCache() override;
296 virtual net::HttpCache* GetCache() override; 292 net::HttpNetworkSession* GetSession() override;
297 virtual net::HttpNetworkSession* GetSession() override;
298 293
299 private: 294 private:
300 int transaction_count_; 295 int transaction_count_;
301 bool done_reading_called_; 296 bool done_reading_called_;
302 bool stop_caching_called_; 297 bool stop_caching_called_;
303 net::RequestPriority last_create_transaction_priority_; 298 net::RequestPriority last_create_transaction_priority_;
304 base::WeakPtr<MockNetworkTransaction> last_transaction_; 299 base::WeakPtr<MockNetworkTransaction> last_transaction_;
305 }; 300 };
306 301
307 //----------------------------------------------------------------------------- 302 //-----------------------------------------------------------------------------
308 // helpers 303 // helpers
309 304
310 // read the transaction completely 305 // read the transaction completely
311 int ReadTransaction(net::HttpTransaction* trans, std::string* result); 306 int ReadTransaction(net::HttpTransaction* trans, std::string* result);
312 307
313 #endif // NET_HTTP_HTTP_TRANSACTION_UNITTEST_H_ 308 #endif // NET_HTTP_HTTP_TRANSACTION_UNITTEST_H_
OLDNEW
« no previous file with comments | « net/http/http_stream_parser.cc ('k') | net/http/mock_allow_url_security_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698