| 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 7d146f318664e9ad242c45493dca151121d06d04..932208ad3d1185c119c03914aef71cc359679729 100644
|
| --- a/content/browser/loader/async_resource_handler.cc
|
| +++ b/content/browser/loader/async_resource_handler.cc
|
| @@ -10,7 +10,6 @@
|
| #include "base/command_line.h"
|
| #include "base/containers/hash_tables.h"
|
| #include "base/debug/alias.h"
|
| -#include "base/feature_list.h"
|
| #include "base/logging.h"
|
| #include "base/macros.h"
|
| #include "base/memory/ptr_util.h"
|
| @@ -28,7 +27,6 @@
|
| #include "content/common/resource_messages.h"
|
| #include "content/common/resource_request_completion_status.h"
|
| #include "content/common/view_messages.h"
|
| -#include "content/public/common/content_features.h"
|
| #include "content/public/common/resource_response.h"
|
| #include "ipc/ipc_message_macros.h"
|
| #include "net/base/io_buffer.h"
|
| @@ -46,14 +44,6 @@ static int kBufferSize = 1024 * 512;
|
| static int kMinAllocationSize = 1024 * 4;
|
| static int kMaxAllocationSize = 1024 * 32;
|
|
|
| -// Used when kOptimizeLoadingIPCForSmallResources is enabled.
|
| -// Small resource typically issues two Read call: one for the content itself
|
| -// and another for getting zero response to detect EOF.
|
| -// Inline these two into the IPC message to avoid allocating an expensive
|
| -// SharedMemory for small resources.
|
| -const int kNumLeadingChunk = 2;
|
| -const int kInlinedLeadingChunkSize = 2048;
|
| -
|
| void GetNumericArg(const std::string& name, int* result) {
|
| const std::string& value =
|
| base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(name);
|
| @@ -85,112 +75,6 @@ enum ExpectedContentSizeResult {
|
|
|
| } // namespace
|
|
|
| -// Used when kOptimizeLoadingIPCForSmallResources is enabled.
|
| -// The instance hooks the buffer allocation of AsyncResourceHandler, and
|
| -// determine if we should use SharedMemory or should inline the data into
|
| -// the IPC message.
|
| -class AsyncResourceHandler::InliningHelper {
|
| - public:
|
| -
|
| - InliningHelper() {}
|
| - ~InliningHelper() {}
|
| -
|
| - void OnResponseReceived(const ResourceResponse& response) {
|
| - InliningStatus status = IsInliningApplicable(response);
|
| - UMA_HISTOGRAM_ENUMERATION(
|
| - "Net.ResourceLoader.InliningStatus",
|
| - static_cast<int>(status),
|
| - static_cast<int>(InliningStatus::INLINING_STATUS_COUNT));
|
| - inlining_applicable_ = status == InliningStatus::APPLICABLE;
|
| - }
|
| -
|
| - // Returns true if InliningHelper allocates the buffer for inlining.
|
| - bool PrepareInlineBufferIfApplicable(scoped_refptr<net::IOBuffer>* buf,
|
| - int* buf_size) {
|
| - ++num_allocation_;
|
| -
|
| - // If the server sends the resource in multiple small chunks,
|
| - // |num_allocation_| may exceed |kNumLeadingChunk|. Disable inlining and
|
| - // fall back to the regular resource loading path in that case.
|
| - if (!inlining_applicable_ ||
|
| - num_allocation_ > kNumLeadingChunk ||
|
| - !base::FeatureList::IsEnabled(
|
| - features::kOptimizeLoadingIPCForSmallResources)) {
|
| - return false;
|
| - }
|
| -
|
| - leading_chunk_buffer_ = new net::IOBuffer(kInlinedLeadingChunkSize);
|
| - *buf = leading_chunk_buffer_;
|
| - *buf_size = kInlinedLeadingChunkSize;
|
| - return true;
|
| - }
|
| -
|
| - // Returns true if the received data is sent to the consumer.
|
| - bool SendInlinedDataIfApplicable(int bytes_read,
|
| - int encoded_data_length,
|
| - IPC::Sender* sender,
|
| - int request_id) {
|
| - DCHECK(sender);
|
| - if (!leading_chunk_buffer_)
|
| - return false;
|
| -
|
| - std::vector<char> data(
|
| - leading_chunk_buffer_->data(),
|
| - leading_chunk_buffer_->data() + bytes_read);
|
| - leading_chunk_buffer_ = nullptr;
|
| -
|
| - sender->Send(new ResourceMsg_InlinedDataChunkReceived(
|
| - request_id, data, encoded_data_length));
|
| - return true;
|
| - }
|
| -
|
| - void RecordHistogram(int64_t elapsed_time) {
|
| - if (inlining_applicable_) {
|
| - UMA_HISTOGRAM_CUSTOM_COUNTS(
|
| - "Net.ResourceLoader.ResponseStartToEnd.InliningApplicable",
|
| - elapsed_time, 1, 100000, 100);
|
| - }
|
| - }
|
| -
|
| - private:
|
| - enum class InliningStatus : int {
|
| - APPLICABLE = 0,
|
| - EARLY_ALLOCATION = 1,
|
| - UNKNOWN_CONTENT_LENGTH = 2,
|
| - LARGE_CONTENT = 3,
|
| - HAS_TRANSFER_ENCODING = 4,
|
| - HAS_CONTENT_ENCODING = 5,
|
| - INLINING_STATUS_COUNT,
|
| - };
|
| -
|
| - InliningStatus IsInliningApplicable(const ResourceResponse& response) {
|
| - // Disable if the leading chunk is already arrived.
|
| - if (num_allocation_)
|
| - return InliningStatus::EARLY_ALLOCATION;
|
| -
|
| - // Disable if the content is known to be large.
|
| - if (response.head.content_length > kInlinedLeadingChunkSize)
|
| - return InliningStatus::LARGE_CONTENT;
|
| -
|
| - // Disable if the length of the content is unknown.
|
| - if (response.head.content_length < 0)
|
| - return InliningStatus::UNKNOWN_CONTENT_LENGTH;
|
| -
|
| - if (response.head.headers) {
|
| - if (response.head.headers->HasHeader("Transfer-Encoding"))
|
| - return InliningStatus::HAS_TRANSFER_ENCODING;
|
| - if (response.head.headers->HasHeader("Content-Encoding"))
|
| - return InliningStatus::HAS_CONTENT_ENCODING;
|
| - }
|
| -
|
| - return InliningStatus::APPLICABLE;
|
| - }
|
| -
|
| - int num_allocation_ = 0;
|
| - bool inlining_applicable_ = false;
|
| - scoped_refptr<net::IOBuffer> leading_chunk_buffer_;
|
| -};
|
| -
|
| class DependentIOBuffer : public net::WrappedIOBuffer {
|
| public:
|
| DependentIOBuffer(ResourceBuffer* backing, char* memory)
|
| @@ -213,7 +97,6 @@ AsyncResourceHandler::AsyncResourceHandler(net::URLRequest* request,
|
| has_checked_for_sufficient_resources_(false),
|
| sent_received_response_msg_(false),
|
| sent_data_buffer_msg_(false),
|
| - inlining_helper_(new InliningHelper),
|
| reported_transfer_size_(0) {
|
| DCHECK(GetRequestInfo()->requester_info()->IsRenderer());
|
| InitializeResourceBufferConstants();
|
| @@ -337,7 +220,6 @@ void AsyncResourceHandler::OnResponseStarted(
|
| filter->Send(new ResourceMsg_ReceivedCachedMetadata(GetRequestID(), copy));
|
| }
|
|
|
| - inlining_helper_->OnResponseReceived(*response);
|
| controller->Resume();
|
| }
|
|
|
| @@ -372,13 +254,6 @@ void AsyncResourceHandler::OnWillRead(
|
| return;
|
| }
|
|
|
| - // Return early if InliningHelper allocates the buffer, so that we should
|
| - // inline the data into the IPC message without allocating SharedMemory.
|
| - if (inlining_helper_->PrepareInlineBufferIfApplicable(buf, buf_size)) {
|
| - controller->Resume();
|
| - return;
|
| - }
|
| -
|
| if (!EnsureResourceBufferIsInitialized()) {
|
| controller->CancelWithError(net::ERR_INSUFFICIENT_RESOURCES);
|
| return;
|
| @@ -417,13 +292,6 @@ void AsyncResourceHandler::OnReadCompleted(
|
|
|
| first_chunk_read_ = true;
|
|
|
| - // Return early if InliningHelper handled the received data.
|
| - if (inlining_helper_->SendInlinedDataIfApplicable(
|
| - bytes_read, encoded_data_length, filter, GetRequestID())) {
|
| - controller->Resume();
|
| - return;
|
| - }
|
| -
|
| buffer_->ShrinkLastAllocation(bytes_read);
|
|
|
| total_read_body_bytes_ += bytes_read;
|
| @@ -587,8 +455,6 @@ void AsyncResourceHandler::RecordHistogram() {
|
| elapsed_time, 1, 100000, 100);
|
| }
|
|
|
| - inlining_helper_->RecordHistogram(elapsed_time);
|
| -
|
| // Record if content size was known in advance.
|
| int64_t expected_content_size = request()->GetExpectedContentSize();
|
| ExpectedContentSizeResult expected_content_size_result =
|
|
|