Chromium Code Reviews| 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, |