| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "webkit/media/buffered_resource_loader.h" | 5 #include "webkit/media/buffered_resource_loader.h" |
| 6 | 6 |
| 7 #include "base/bits.h" | 7 #include "base/bits.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 // In this case we shouldn't do anything. | 371 // In this case we shouldn't do anything. |
| 372 if (start_cb_.is_null()) | 372 if (start_cb_.is_null()) |
| 373 return; | 373 return; |
| 374 | 374 |
| 375 uint32 reasons = GetReasonsForUncacheability(response); | 375 uint32 reasons = GetReasonsForUncacheability(response); |
| 376 might_be_reused_from_cache_in_future_ = reasons == 0; | 376 might_be_reused_from_cache_in_future_ = reasons == 0; |
| 377 UMA_HISTOGRAM_BOOLEAN("Media.CacheUseful", reasons == 0); | 377 UMA_HISTOGRAM_BOOLEAN("Media.CacheUseful", reasons == 0); |
| 378 int shift = 0; | 378 int shift = 0; |
| 379 int max_enum = base::bits::Log2Ceiling(kMaxReason); | 379 int max_enum = base::bits::Log2Ceiling(kMaxReason); |
| 380 while (reasons) { | 380 while (reasons) { |
| 381 DCHECK_LT(shift, max_enum); // Sanity check. |
| 381 if (reasons & 0x1) | 382 if (reasons & 0x1) |
| 382 UMA_HISTOGRAM_ENUMERATION("Media.UncacheableReason", shift, max_enum); | 383 UMA_HISTOGRAM_ENUMERATION("Media.UncacheableReason", shift, max_enum); |
| 383 reasons >>= 1; | 384 reasons >>= 1; |
| 384 ++shift; | 385 ++shift; |
| 385 } | 386 } |
| 386 DCHECK_LT(shift, max_enum); // Sanity check. | |
| 387 | 387 |
| 388 // Expected content length can be |kPositionNotSpecified|, in that case | 388 // Expected content length can be |kPositionNotSpecified|, in that case |
| 389 // |content_length_| is not specified and this is a streaming response. | 389 // |content_length_| is not specified and this is a streaming response. |
| 390 content_length_ = response.expectedContentLength(); | 390 content_length_ = response.expectedContentLength(); |
| 391 | 391 |
| 392 // We make a strong assumption that when we reach here we have either | 392 // We make a strong assumption that when we reach here we have either |
| 393 // received a response from HTTP/HTTPS protocol or the request was | 393 // received a response from HTTP/HTTPS protocol or the request was |
| 394 // successful (in particular range request). So we only verify the partial | 394 // successful (in particular range request). So we only verify the partial |
| 395 // response for HTTP and HTTPS protocol. | 395 // response for HTTP and HTTPS protocol. |
| 396 if (url_.SchemeIs(kHttpScheme) || url_.SchemeIs(kHttpsScheme)) { | 396 if (url_.SchemeIs(kHttpScheme) || url_.SchemeIs(kHttpsScheme)) { |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 832 | 832 |
| 833 void BufferedResourceLoader::Log() { | 833 void BufferedResourceLoader::Log() { |
| 834 media_log_->AddEvent( | 834 media_log_->AddEvent( |
| 835 media_log_->CreateBufferedExtentsChangedEvent( | 835 media_log_->CreateBufferedExtentsChangedEvent( |
| 836 offset_ - buffer_.backward_bytes(), | 836 offset_ - buffer_.backward_bytes(), |
| 837 offset_, | 837 offset_, |
| 838 offset_ + buffer_.forward_bytes())); | 838 offset_ + buffer_.forward_bytes())); |
| 839 } | 839 } |
| 840 | 840 |
| 841 } // namespace webkit_media | 841 } // namespace webkit_media |
| OLD | NEW |