Chromium Code Reviews| Index: webkit/media/buffered_resource_loader.cc |
| diff --git a/webkit/media/buffered_resource_loader.cc b/webkit/media/buffered_resource_loader.cc |
| index 14ca0a12625058e61d70919b3de945f23cb05cbc..b1b7541a90e2ece1bf6d0555be47daccc6957c04 100644 |
| --- a/webkit/media/buffered_resource_loader.cc |
| +++ b/webkit/media/buffered_resource_loader.cc |
| @@ -6,11 +6,13 @@ |
| #include "base/callback_helpers.h" |
| #include "base/format_macros.h" |
| +#include "base/metrics/histogram.h" |
| #include "base/string_number_conversions.h" |
| #include "base/string_util.h" |
| #include "base/stringprintf.h" |
| #include "media/base/media_log.h" |
| #include "net/http/http_request_headers.h" |
| +#include "webkit/media/cache_util.h" |
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" |
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLLoaderOptions.h" |
| #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebKitPlatformSupport.h" |
| @@ -111,6 +113,7 @@ BufferedResourceLoader::BufferedResourceLoader( |
| : buffer_(kMinBufferCapacity, kMinBufferCapacity), |
| loader_failed_(false), |
| defer_strategy_(strategy), |
| + might_be_reused_from_cache_in_future_(true), |
| range_supported_(false), |
| saved_forward_capacity_(0), |
| url_(url), |
| @@ -368,6 +371,15 @@ void BufferedResourceLoader::didReceiveResponse( |
| if (start_cb_.is_null()) |
| return; |
| + std::vector<UncacheableReason> reasons = |
| + GetReasonsForUncacheability(response); |
| + might_be_reused_from_cache_in_future_ = reasons.empty(); |
| + UMA_HISTOGRAM_BOOLEAN("Media.CacheUseful", reasons.empty()); |
| + for (size_t i = 0; i < reasons.size(); ++i) { |
| + UMA_HISTOGRAM_ENUMERATION( |
| + "Media.UncacheableReason", reasons[i], kMaxReason); |
|
scherkus (not reviewing)
2012/05/23 01:16:03
one nit: we would increment counts every time we r
Ami GONE FROM CHROMIUM
2012/05/23 01:27:28
But the whole idea is to classify reusability of i
scherkus (not reviewing)
2012/05/23 01:34:19
I suppose so but how could we answer that out of N
Ami GONE FROM CHROMIUM
2012/05/23 01:38:25
UMA is by its nature not per-site (aggregated alon
scherkus (not reviewing)
2012/05/23 01:43:01
I'm not interested in the domain but setting the s
|
| + } |
| + |
| // Expected content length can be |kPositionNotSpecified|, in that case |
| // |content_length_| is not specified and this is a streaming response. |
| content_length_ = response.expectedContentLength(); |
| @@ -540,6 +552,8 @@ bool BufferedResourceLoader::HasSingleOrigin() const { |
| } |
| void BufferedResourceLoader::UpdateDeferStrategy(DeferStrategy strategy) { |
| + if (!might_be_reused_from_cache_in_future_ && strategy == kNeverDefer) |
| + strategy = kThresholdDefer; |
| defer_strategy_ = strategy; |
| UpdateDeferBehavior(); |
| } |