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

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

Issue 1230113012: [net] Better StopCaching() handling for HttpCache::Transaction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Release cache lock early and request open range if it's the final range. Created 5 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 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 TEST_MODE_SYNC_NET_READ = 1 << 1, 43 TEST_MODE_SYNC_NET_READ = 1 << 1,
44 TEST_MODE_SYNC_CACHE_START = 1 << 2, 44 TEST_MODE_SYNC_CACHE_START = 1 << 2,
45 TEST_MODE_SYNC_CACHE_READ = 1 << 3, 45 TEST_MODE_SYNC_CACHE_READ = 1 << 3,
46 TEST_MODE_SYNC_CACHE_WRITE = 1 << 4, 46 TEST_MODE_SYNC_CACHE_WRITE = 1 << 4,
47 TEST_MODE_SYNC_ALL = (TEST_MODE_SYNC_NET_START | TEST_MODE_SYNC_NET_READ | 47 TEST_MODE_SYNC_ALL = (TEST_MODE_SYNC_NET_START | TEST_MODE_SYNC_NET_READ |
48 TEST_MODE_SYNC_CACHE_START | TEST_MODE_SYNC_CACHE_READ | 48 TEST_MODE_SYNC_CACHE_START | TEST_MODE_SYNC_CACHE_READ |
49 TEST_MODE_SYNC_CACHE_WRITE), 49 TEST_MODE_SYNC_CACHE_WRITE),
50 TEST_MODE_SLOW_READ = 1 << 5 50 TEST_MODE_SLOW_READ = 1 << 5
51 }; 51 };
52 52
53 typedef void (*MockTransactionHandler)(const HttpRequestInfo* request, 53 using MockTransactionReadHandler = int (*)(int64 content_length,
54 std::string* response_status, 54 int64 offset,
55 std::string* response_headers, 55 IOBuffer* buf,
56 std::string* response_data); 56 int buf_len);
57 using MockTransactionHandler = void (*)(const HttpRequestInfo* request,
58 std::string* response_status,
59 std::string* response_headers,
60 std::string* response_data);
57 61
58 struct MockTransaction { 62 struct MockTransaction {
59 const char* url; 63 const char* url;
60 const char* method; 64 const char* method;
61 // If |request_time| is unspecified, the current time will be used. 65 // If |request_time| is unspecified, the current time will be used.
62 base::Time request_time; 66 base::Time request_time;
63 const char* request_headers; 67 const char* request_headers;
64 int load_flags; 68 int load_flags;
65 const char* status; 69 const char* status;
66 const char* response_headers; 70 const char* response_headers;
67 // If |response_time| is unspecified, the current time will be used. 71 // If |response_time| is unspecified, the current time will be used.
68 base::Time response_time; 72 base::Time response_time;
69 const char* data; 73 const char* data;
70 int test_mode; 74 int test_mode;
71 MockTransactionHandler handler; 75 MockTransactionHandler handler;
76 MockTransactionReadHandler read_handler;
72 scoped_refptr<X509Certificate> cert; 77 scoped_refptr<X509Certificate> cert;
73 CertStatus cert_status; 78 CertStatus cert_status;
74 int ssl_connection_status; 79 int ssl_connection_status;
75 // Value returned by MockNetworkTransaction::Start (potentially 80 // Value returned by MockNetworkTransaction::Start (potentially
76 // asynchronously if |!(test_mode & TEST_MODE_SYNC_NET_START)|.) 81 // asynchronously if |!(test_mode & TEST_MODE_SYNC_NET_START)|.)
77 Error return_code; 82 Error return_code;
78 }; 83 };
79 84
80 extern const MockTransaction kSimpleGET_Transaction; 85 extern const MockTransaction kSimpleGET_Transaction;
81 extern const MockTransaction kSimplePOST_Transaction; 86 extern const MockTransaction kSimplePOST_Transaction;
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 private: 238 private:
234 int StartInternal(const HttpRequestInfo* request, 239 int StartInternal(const HttpRequestInfo* request,
235 const CompletionCallback& callback, 240 const CompletionCallback& callback,
236 const BoundNetLog& net_log); 241 const BoundNetLog& net_log);
237 void CallbackLater(const CompletionCallback& callback, int result); 242 void CallbackLater(const CompletionCallback& callback, int result);
238 void RunCallback(const CompletionCallback& callback, int result); 243 void RunCallback(const CompletionCallback& callback, int result);
239 244
240 const HttpRequestInfo* request_; 245 const HttpRequestInfo* request_;
241 HttpResponseInfo response_; 246 HttpResponseInfo response_;
242 std::string data_; 247 std::string data_;
243 int data_cursor_; 248 int64 data_cursor_;
249 int64 content_length_;
244 int test_mode_; 250 int test_mode_;
245 RequestPriority priority_; 251 RequestPriority priority_;
252 MockTransactionReadHandler read_handler_;
246 CreateHelper* websocket_handshake_stream_create_helper_; 253 CreateHelper* websocket_handshake_stream_create_helper_;
254 BeforeNetworkStartCallback before_network_start_callback_;
247 base::WeakPtr<MockNetworkLayer> transaction_factory_; 255 base::WeakPtr<MockNetworkLayer> transaction_factory_;
248 int64 received_bytes_; 256 int64 received_bytes_;
249 257
250 // NetLog ID of the fake / non-existent underlying socket used by the 258 // NetLog ID of the fake / non-existent underlying socket used by the
251 // connection. Requires Start() be passed a BoundNetLog with a real NetLog to 259 // connection. Requires Start() be passed a BoundNetLog with a real NetLog to
252 // be initialized. 260 // be initialized.
253 unsigned int socket_log_id_; 261 unsigned int socket_log_id_;
254 262
255 base::WeakPtrFactory<MockNetworkTransaction> weak_factory_; 263 base::WeakPtrFactory<MockNetworkTransaction> weak_factory_;
256 264
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 325
318 //----------------------------------------------------------------------------- 326 //-----------------------------------------------------------------------------
319 // helpers 327 // helpers
320 328
321 // read the transaction completely 329 // read the transaction completely
322 int ReadTransaction(HttpTransaction* trans, std::string* result); 330 int ReadTransaction(HttpTransaction* trans, std::string* result);
323 331
324 } // namespace net 332 } // namespace net
325 333
326 #endif // NET_HTTP_HTTP_TRANSACTION_UNITTEST_H_ 334 #endif // NET_HTTP_HTTP_TRANSACTION_UNITTEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698