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

Unified Diff: net/http/http_transaction_test_util.cc

Issue 793823002: Let prefetched resources skip cache revalidation once for a short duration. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments from PS2 Created 6 years 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
« net/http/http_response_info.cc ('K') | « net/http/http_transaction_test_util.h ('k') | no next file » | 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..4aa6fef7100bdf74110288c96b58934497aba10f 100644
--- a/net/http/http_transaction_test_util.cc
+++ b/net/http/http_transaction_test_util.cc
@@ -9,6 +9,8 @@
#include "base/bind.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/stringprintf.h"
+#include "base/time/clock.h"
+#include "base/time/default_clock.h"
#include "base/time/time.h"
#include "net/base/load_flags.h"
#include "net/base/load_timing_info.h"
@@ -399,14 +401,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_->clock()->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_->clock()->Now();
if (!t->response_time.is_null())
response_.response_time = t->response_time;
@@ -418,6 +420,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 +459,10 @@ 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),
+ default_clock_(new base::DefaultClock()),
+ clock_(default_clock_.get()) {
+}
MockNetworkLayer::~MockNetworkLayer() {}
@@ -486,6 +494,12 @@ net::HttpNetworkSession* MockNetworkLayer::GetSession() {
return NULL;
}
+void MockNetworkLayer::SetClock(base::Clock* clock) {
+ DCHECK(default_clock_);
+ clock_ = clock;
+ default_clock_.reset();
rvargas (doing something else) 2014/12/24 02:15:25 sounds like we need only one variable to store the
jkarlin 2015/01/08 16:13:04 Done.
+}
+
//-----------------------------------------------------------------------------
// helpers
« net/http/http_response_info.cc ('K') | « net/http/http_transaction_test_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698