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

Unified Diff: content/browser/loader/async_resource_handler.cc

Issue 2624123002: Add UMA histograms to AsyncResourceHandler to track content size. (Closed)
Patch Set: comments Created 3 years, 11 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 | « content/browser/loader/async_resource_handler.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/loader/async_resource_handler.cc
diff --git a/content/browser/loader/async_resource_handler.cc b/content/browser/loader/async_resource_handler.cc
index d55bc0f9a72c14c08eeacd3c26729415dee696b6..2eaa22bdb7de434b6582b0e7615aa968291440ad 100644
--- a/content/browser/loader/async_resource_handler.cc
+++ b/content/browser/loader/async_resource_handler.cc
@@ -72,6 +72,15 @@ void InitializeResourceBufferConstants() {
GetNumericArg("resource-buffer-max-allocation-size", &kMaxAllocationSize);
}
+enum ExpectedContentSize {
+ EQ_RESPONSE_BODY = 0,
+ EQ_RESPONSE_BODY_MT_EQ_BUFFER_SIZE = 1,
+ LT_RESPONSE_BODY = 2,
+ MT_RESPONSE_BODY = 3,
+ UNKNOWN = 4,
+ EXPECTED_CONTENT_MAX,
+};
+
} // namespace
// Used when kOptimizeLoadingIPCForSmallResources is enabled.
@@ -191,14 +200,14 @@ class DependentIOBuffer : public net::WrappedIOBuffer {
scoped_refptr<ResourceBuffer> backing_;
};
-AsyncResourceHandler::AsyncResourceHandler(
- net::URLRequest* request,
- ResourceDispatcherHostImpl* rdh)
+AsyncResourceHandler::AsyncResourceHandler(net::URLRequest* request,
+ ResourceDispatcherHostImpl* rdh)
: ResourceHandler(request),
ResourceMessageDelegate(request),
rdh_(rdh),
pending_data_count_(0),
allocation_size_(0),
+ total_read_body_bytes_(0),
did_defer_(false),
has_checked_for_sufficient_resources_(false),
sent_received_response_msg_(false),
@@ -395,6 +404,8 @@ bool AsyncResourceHandler::OnReadCompleted(int bytes_read, bool* defer) {
buffer_->ShrinkLastAllocation(bytes_read);
+ total_read_body_bytes_ += bytes_read;
+
if (!sent_data_buffer_msg_) {
base::SharedMemoryHandle handle = base::SharedMemory::DuplicateHandle(
buffer_->GetSharedMemory().handle());
@@ -551,6 +562,40 @@ void AsyncResourceHandler::RecordHistogram() {
}
inlining_helper_->RecordHistogram(elapsed_time);
+
+ // Record if content size was known in advance.
+ int64_t expected_content_size = request()->GetExpectedContentSize();
+ if (expected_content_size >= 0) {
mmenke 2017/01/13 16:01:36 Having ExpectedContentSize be an enum that's not a
maksims (do not use this acc) 2017/01/16 07:25:22 Done.
+ // Compare response body size to expected content size.
+ if (expected_content_size == total_read_body_bytes_ &&
+ expected_content_size >= kBufferSize) {
+ UMA_HISTOGRAM_ENUMERATION(
+ "Net.ResourceLoader.ExpectedContentSize.CorrespondsBodySize",
mmenke 2017/01/13 16:01:36 Suggest just replacing "ExpectedContentSize.Corres
maksims (do not use this acc) 2017/01/16 07:25:22 Done.
+ ExpectedContentSize::EQ_RESPONSE_BODY_MT_EQ_BUFFER_SIZE,
+ ExpectedContentSize::EXPECTED_CONTENT_MAX);
mmenke 2017/01/13 16:01:36 You only need one UMA_HISTOGRAM_ENUMERATION call h
maksims (do not use this acc) 2017/01/16 07:25:21 Done.
+ } else if (expected_content_size == total_read_body_bytes_) {
+ UMA_HISTOGRAM_ENUMERATION(
+ "Net.ResourceLoader.ExpectedContentSize.CorrespondsBodySize",
+ ExpectedContentSize::EQ_RESPONSE_BODY,
+ ExpectedContentSize::EXPECTED_CONTENT_MAX);
+ } else if (expected_content_size < total_read_body_bytes_) {
+ UMA_HISTOGRAM_ENUMERATION(
+ "Net.ResourceLoader.ExpectedContentSize.CorrespondsBodySize",
+ ExpectedContentSize::LT_RESPONSE_BODY,
+ ExpectedContentSize::EXPECTED_CONTENT_MAX);
+ } else {
+ UMA_HISTOGRAM_ENUMERATION(
+ "Net.ResourceLoader.ExpectedContentSize.CorrespondsBodySize",
+ ExpectedContentSize::MT_RESPONSE_BODY,
+ ExpectedContentSize::EXPECTED_CONTENT_MAX);
+ }
+ } else {
+ UMA_HISTOGRAM_ENUMERATION(
+ "Net.ResourceLoader.ExpectedContentSize.CorrespondsBodySize",
+ ExpectedContentSize::UNKNOWN,
+ ExpectedContentSize::EXPECTED_CONTENT_MAX);
+ }
+ total_read_body_bytes_ = 0;
mmenke 2017/01/13 16:01:36 Not needed. This class is only used to read one r
maksims (do not use this acc) 2017/01/16 07:25:21 Done.
}
void AsyncResourceHandler::SendUploadProgress(int64_t current_position,
« no previous file with comments | « content/browser/loader/async_resource_handler.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698