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

Unified Diff: webkit/media/buffered_resource_loader.cc

Issue 10387200: Suppress pause-and-buffer behavior when the HTTP response won't satisfy future requests via cache. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: indent-to-first-paren Created 8 years, 7 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
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);
+ }
+
// 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();
}

Powered by Google App Engine
This is Rietveld 408576698