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

Unified Diff: net/http/http_transaction_test_util.cc

Issue 2721933002: HttpCache::Transaction layer allowing parallel validation (Closed)
Patch Set: Feedback addressed Created 3 years, 8 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
« no previous file with comments | « net/http/http_transaction_test_util.h ('k') | net/http/mock_http_cache.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_transaction_test_util.cc
diff --git a/net/http/http_transaction_test_util.cc b/net/http/http_transaction_test_util.cc
index a5b57461df5a2e49568fa045bc285f9d01e006bc..b272c442736dea22694429114049180f9d97ee17 100644
--- a/net/http/http_transaction_test_util.cc
+++ b/net/http/http_transaction_test_util.cc
@@ -409,13 +409,6 @@ int MockNetworkTransaction::StartInternal(const HttpRequestInfo* request,
if (!t)
return ERR_FAILED;
- if (!before_network_start_callback_.is_null()) {
- bool defer = false;
- before_network_start_callback_.Run(&defer);
- if (defer)
- return net::ERR_IO_PENDING;
- }
-
test_mode_ = t->test_mode;
// Return immediately if we're returning an error.
@@ -466,6 +459,16 @@ int MockNetworkTransaction::StartInternal(const HttpRequestInfo* request,
if (request_->load_flags & LOAD_PREFETCH)
response_.unused_since_prefetch = true;
+ // Pause and resume.
+ if (!before_network_start_callback_.is_null()) {
+ bool defer = false;
+ before_network_start_callback_.Run(&defer);
+ if (defer) {
+ callback_ = callback;
+ return net::ERR_IO_PENDING;
+ }
+ }
+
if (test_mode_ & TEST_MODE_SYNC_NET_START)
return OK;
@@ -482,8 +485,14 @@ void MockNetworkTransaction::SetBeforeHeadersSentCallback(
const BeforeHeadersSentCallback& callback) {}
int MockNetworkTransaction::ResumeNetworkStart() {
- // Should not get here.
- return ERR_FAILED;
+ DCHECK(!callback_.is_null());
+ CallbackLater(callback_, OK);
+ return ERR_IO_PENDING;
+}
+
+// static
+void MockNetworkTransaction::DeferNetworkStart(bool* defer) {
Randy Smith (Not in Mondays) 2017/04/11 19:56:45 nit, suggestion: This function seems trivial enoug
shivanisha 2017/04/12 16:46:03 done
+ *defer = true;
}
void MockNetworkTransaction::GetConnectionAttempts(
« no previous file with comments | « net/http/http_transaction_test_util.h ('k') | net/http/mock_http_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698