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

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: %zu is win-unfriendly; use %PRIuS instead. 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
« no previous file with comments | « webkit/media/buffered_resource_loader.h ('k') | webkit/media/cache_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..6496f7fa9c95952c69e79c25ee05bba367988774 100644
--- a/webkit/media/buffered_resource_loader.cc
+++ b/webkit/media/buffered_resource_loader.cc
@@ -4,13 +4,16 @@
#include "webkit/media/buffered_resource_loader.h"
+#include "base/bits.h"
#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 +114,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 +372,19 @@ void BufferedResourceLoader::didReceiveResponse(
if (start_cb_.is_null())
return;
+ uint32 reasons = GetReasonsForUncacheability(response);
+ might_be_reused_from_cache_in_future_ = reasons == 0;
+ UMA_HISTOGRAM_BOOLEAN("Media.CacheUseful", reasons == 0);
+ int shift = 0;
+ int max_enum = base::bits::Log2Ceiling(kMaxReason);
+ while (reasons) {
+ if (reasons & 0x1)
+ UMA_HISTOGRAM_ENUMERATION("Media.UncacheableReason", shift, max_enum);
+ reasons >>= 1;
+ ++shift;
+ }
+ DCHECK_LT(shift, max_enum); // Sanity check.
+
// 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 +557,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();
}
« no previous file with comments | « webkit/media/buffered_resource_loader.h ('k') | webkit/media/cache_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698