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

Unified Diff: net/http/http_transaction_test_util.cc

Issue 851503003: Update from https://crrev.com/311076 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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/transport_security_state_static.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 dbbca6c3d9e9bff6c2c8cc8f808154bfe2df88c2..f3bbf98df3dd4acc4c260e08ebfd7c78946910ca 100644
--- a/net/http/http_transaction_test_util.cc
+++ b/net/http/http_transaction_test_util.cc
@@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/stringprintf.h"
+#include "base/time/clock.h"
#include "base/time/time.h"
#include "net/base/load_flags.h"
#include "net/base/load_timing_info.h"
@@ -399,14 +400,14 @@ int MockNetworkTransaction::StartInternal(
"%s\n%s\n", resp_status.c_str(), resp_headers.c_str());
std::replace(header_data.begin(), header_data.end(), '\n', '\0');
- response_.request_time = base::Time::Now();
+ response_.request_time = transaction_factory_->Now();
if (!t->request_time.is_null())
response_.request_time = t->request_time;
response_.was_cached = false;
response_.network_accessed = true;
- response_.response_time = base::Time::Now();
+ response_.response_time = transaction_factory_->Now();
if (!t->response_time.is_null())
response_.response_time = t->response_time;
@@ -418,6 +419,9 @@ int MockNetworkTransaction::StartInternal(
if (net_log.net_log())
socket_log_id_ = net_log.net_log()->NextID();
+ if (request_->load_flags & net::LOAD_PREFETCH)
+ response_.unused_since_prefetch = true;
+
if (test_mode_ & TEST_MODE_SYNC_NET_START)
return net::OK;
@@ -454,7 +458,9 @@ MockNetworkLayer::MockNetworkLayer()
: transaction_count_(0),
done_reading_called_(false),
stop_caching_called_(false),
- last_create_transaction_priority_(net::DEFAULT_PRIORITY) {}
+ last_create_transaction_priority_(net::DEFAULT_PRIORITY),
+ clock_(nullptr) {
+}
MockNetworkLayer::~MockNetworkLayer() {}
@@ -486,6 +492,17 @@ net::HttpNetworkSession* MockNetworkLayer::GetSession() {
return NULL;
}
+void MockNetworkLayer::SetClock(base::Clock* clock) {
+ DCHECK(!clock_);
+ clock_ = clock;
+}
+
+base::Time MockNetworkLayer::Now() {
+ if (clock_)
+ return clock_->Now();
+ return base::Time::Now();
+}
+
//-----------------------------------------------------------------------------
// helpers
« no previous file with comments | « net/http/http_transaction_test_util.h ('k') | net/http/transport_security_state_static.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698