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

Unified 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: Add missing MockTransaction initializers Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: net/http/http_transaction_test_util.h
diff --git a/net/http/http_transaction_test_util.h b/net/http/http_transaction_test_util.h
index 0c311df4cde55c3e646206f104f9e57673039611..865d7f99fefbe297ecbbcfb715428174016b0c43 100644
--- a/net/http/http_transaction_test_util.h
+++ b/net/http/http_transaction_test_util.h
@@ -52,10 +52,14 @@ enum {
TEST_MODE_SLOW_READ = 1 << 5
};
-typedef void (*MockTransactionHandler)(const HttpRequestInfo* request,
- std::string* response_status,
- std::string* response_headers,
- std::string* response_data);
+using MockTransactionReadHandler = int (*)(int64 content_length,
+ int64 offset,
+ IOBuffer* buf,
+ int buf_len);
+using MockTransactionHandler = void (*)(const HttpRequestInfo* request,
+ std::string* response_status,
+ std::string* response_headers,
+ std::string* response_data);
struct MockTransaction {
const char* url;
@@ -71,6 +75,7 @@ struct MockTransaction {
const char* data;
int test_mode;
MockTransactionHandler handler;
+ MockTransactionReadHandler read_handler;
scoped_refptr<X509Certificate> cert;
CertStatus cert_status;
int ssl_connection_status;
@@ -251,10 +256,13 @@ class MockNetworkTransaction
const HttpRequestInfo* request_;
HttpResponseInfo response_;
std::string data_;
- int data_cursor_;
+ int64 data_cursor_;
+ int64 content_length_;
int test_mode_;
RequestPriority priority_;
+ MockTransactionReadHandler read_handler_;
CreateHelper* websocket_handshake_stream_create_helper_;
+ BeforeNetworkStartCallback before_network_start_callback_;
base::WeakPtr<MockNetworkLayer> transaction_factory_;
int64 received_bytes_;
int64_t sent_bytes_;
@@ -280,6 +288,10 @@ class MockNetworkLayer : public HttpTransactionFactory,
void TransactionDoneReading();
void TransactionStopCaching();
+ // Resets the transaction count. Can be called after test setup in order to
+ // make test expectations independent of how test setup is performed.
+ void ResetTransactionCount();
+
// Returns the last priority passed to CreateTransaction, or
// DEFAULT_PRIORITY if it hasn't been called yet.
RequestPriority last_create_transaction_priority() const {

Powered by Google App Engine
This is Rietveld 408576698