Index: net/http/http_cache_transaction.cc |
=================================================================== |
--- net/http/http_cache_transaction.cc (revision 199488) |
+++ net/http/http_cache_transaction.cc (working copy) |
@@ -24,6 +24,7 @@ |
#include "net/base/completion_callback.h" |
#include "net/base/io_buffer.h" |
#include "net/base/load_flags.h" |
+#include "net/base/load_timing_info.h" |
#include "net/base/net_errors.h" |
#include "net/base/net_log.h" |
#include "net/base/upload_data_stream.h" |
@@ -488,9 +489,21 @@ |
LoadTimingInfo* load_timing_info) const { |
if (network_trans_) |
return network_trans_->GetLoadTimingInfo(load_timing_info); |
- // Don't modify |load_timing_info| when reading from the cache instead of the |
- // network. |
- return false; |
+ |
+ if (last_network_trans_load_timing_) { |
+ *load_timing_info = *last_network_trans_load_timing_; |
+ return true; |
+ } |
+ |
+ if (first_cache_access_since_.is_null()) |
+ return false; |
+ |
+ // If the cache entry was opened, return that time. |
+ load_timing_info->send_start = first_cache_access_since_; |
+ // This time doesn't make much sense when reading from the cache, so just use |
+ // the same time as send_start. |
+ load_timing_info->send_end = first_cache_access_since_; |
+ return true; |
} |
void HttpCache::Transaction::SetPriority(RequestPriority priority) { |
@@ -826,6 +839,9 @@ |
if (rv != OK) |
return rv; |
+ // Old load timing information, if any, is now obsolete. |
+ last_network_trans_load_timing_.reset(); |
+ |
ReportNetworkActionStart(); |
next_state_ = STATE_SEND_REQUEST_COMPLETE; |
rv = network_trans_->Start(request_, io_callback_, net_log_); |
@@ -907,6 +923,7 @@ |
// the new response. |
UpdateTransactionPattern(PATTERN_NOT_COVERED); |
response_ = HttpResponseInfo(); |
+ CacheLoadTimingInformation(); |
network_trans_.reset(); |
new_response_ = NULL; |
next_state_ = STATE_SEND_REQUEST; |
@@ -1259,12 +1276,14 @@ |
} |
// We no longer need the network transaction, so destroy it. |
final_upload_progress_ = network_trans_->GetUploadProgress(); |
+ CacheLoadTimingInformation(); |
network_trans_.reset(); |
} else if (entry_ && handling_206_ && truncated_ && |
partial_->initial_validation()) { |
// We just finished the validation of a truncated entry, and the server |
// is willing to resume the operation. Now we go back and start serving |
// the first part to the user. |
+ CacheLoadTimingInformation(); |
network_trans_.reset(); |
new_response_ = NULL; |
next_state_ = STATE_START_PARTIAL_CACHE_VALIDATION; |
@@ -2170,6 +2189,8 @@ |
} |
int HttpCache::Transaction::SetupEntryForRead() { |
+ if (network_trans_) |
+ CacheLoadTimingInformation(); |
network_trans_.reset(); |
if (partial_.get()) { |
if (truncated_ || is_sparse_ || !invalid_range_) { |
@@ -2319,6 +2340,7 @@ |
if (result == 0) { |
// We need to move on to the next range. |
+ CacheLoadTimingInformation(); |
network_trans_.reset(); |
next_state_ = STATE_START_PARTIAL_CACHE_VALIDATION; |
} |
@@ -2561,4 +2583,12 @@ |
return return_value; |
} |
+void HttpCache::Transaction::CacheLoadTimingInformation() { |
+ DCHECK(!last_network_trans_load_timing_); |
+ LoadTimingInfo load_timing; |
+ if (!network_trans_->GetLoadTimingInfo(&load_timing)) |
+ return; |
+ last_network_trans_load_timing_.reset(new LoadTimingInfo(load_timing)); |
+} |
+ |
} // namespace net |