Skip to content

Commit

Permalink
Remove an unnecessary CachedMetadata copy in URLLoaderClientImpl
Browse files Browse the repository at this point in the history
BUG=711580

Review-Url: https://codereview.chromium.org/2814273006
Cr-Commit-Position: refs/heads/master@{#464685}
(cherry picked from commit 736905b)

Review-Url: https://codereview.chromium.org/2822923002 .
Cr-Commit-Position: refs/branch-heads/3071@{#12}
Cr-Branched-From: a106f0a-refs/heads/master@{#464641}
  • Loading branch information
yutakahirano committed Apr 17, 2017
1 parent 11af3a6 commit db95542
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
6 changes: 3 additions & 3 deletions content/browser/loader/async_resource_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ void AsyncResourceHandler::OnResponseStarted(
sent_received_response_msg_ = true;

if (request()->response_info().metadata.get()) {
std::vector<char> copy(request()->response_info().metadata->data(),
request()->response_info().metadata->data() +
request()->response_info().metadata->size());
std::vector<uint8_t> copy(request()->response_info().metadata->data(),
request()->response_info().metadata->data() +
request()->response_info().metadata->size());
filter->Send(new ResourceMsg_ReceivedCachedMetadata(GetRequestID(), copy));
}

Expand Down
9 changes: 6 additions & 3 deletions content/child/resource_dispatcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,16 @@ void ResourceDispatcher::OnReceivedResponse(
}

void ResourceDispatcher::OnReceivedCachedMetadata(
int request_id, const std::vector<char>& data) {
int request_id,
const std::vector<uint8_t>& data) {
PendingRequestInfo* request_info = GetPendingRequestInfo(request_id);
if (!request_info)
return;

if (data.size())
request_info->peer->OnReceivedCachedMetadata(&data.front(), data.size());
if (data.size()) {
request_info->peer->OnReceivedCachedMetadata(
reinterpret_cast<const char*>(&data.front()), data.size());
}
}

void ResourceDispatcher::OnSetDataBuffer(int request_id,
Expand Down
3 changes: 2 additions & 1 deletion content/child/resource_dispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ class CONTENT_EXPORT ResourceDispatcher : public IPC::Listener {
// Message response handlers, called by the message handler for this process.
void OnUploadProgress(int request_id, int64_t position, int64_t size);
void OnReceivedResponse(int request_id, const ResourceResponseHead&);
void OnReceivedCachedMetadata(int request_id, const std::vector<char>& data);
void OnReceivedCachedMetadata(int request_id,
const std::vector<uint8_t>& data);
void OnReceivedRedirect(int request_id,
const net::RedirectInfo& redirect_info,
const ResourceResponseHead& response_head);
Expand Down
7 changes: 2 additions & 5 deletions content/child/url_loader_client_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,10 @@ void URLLoaderClientImpl::OnDataDownloaded(int64_t data_len,

void URLLoaderClientImpl::OnReceiveCachedMetadata(
const std::vector<uint8_t>& data) {
const uint8_t* data_ptr = reinterpret_cast<const uint8_t*>(data.data());
std::vector<char> data_to_pass(data_ptr, data_ptr + data.size());
if (NeedsStoringMessage()) {
StoreAndDispatch(
ResourceMsg_ReceivedCachedMetadata(request_id_, data_to_pass));
StoreAndDispatch(ResourceMsg_ReceivedCachedMetadata(request_id_, data));
} else {
resource_dispatcher_->OnReceivedCachedMetadata(request_id_, data_to_pass);
resource_dispatcher_->OnReceivedCachedMetadata(request_id_, data);
}
}

Expand Down
2 changes: 1 addition & 1 deletion content/common/resource_messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ IPC_MESSAGE_CONTROL2(ResourceMsg_ReceivedResponse,
// Sent when cached metadata from a resource request is ready.
IPC_MESSAGE_CONTROL2(ResourceMsg_ReceivedCachedMetadata,
int /* request_id */,
std::vector<char> /* data */)
std::vector<uint8_t> /* data */)

// Sent as upload progress is being made.
IPC_MESSAGE_CONTROL3(ResourceMsg_UploadProgress,
Expand Down

0 comments on commit db95542

Please sign in to comment.