summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorvsevik@chromium.org <vsevik@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-08 18:52:10 +0000
committervsevik@chromium.org <vsevik@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-08 18:52:10 +0000
commit8bd0de7e38b1f56b00e2ee8c2680b9306ede5eee (patch)
treefa146e5937db671b67ba8a425e0fcc9448d98a8d /content
parent776c05d1347784290de3751bb753439204247591 (diff)
downloadchromium_src-8bd0de7e38b1f56b00e2ee8c2680b9306ede5eee.zip
chromium_src-8bd0de7e38b1f56b00e2ee8c2680b9306ede5eee.tar.gz
chromium_src-8bd0de7e38b1f56b00e2ee8c2680b9306ede5eee.tar.bz2
Enabled actual transfer size in chromium
BUG=40502 TEST=Open DevTools, open site having gzip/chunked encoding, ensure transfer size is correct. Review URL: http://codereview.chromium.org/6771043 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80965 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/renderer_host/async_resource_handler.cc6
-rw-r--r--content/browser/renderer_host/sync_resource_handler.cc5
-rw-r--r--content/common/resource_dispatcher.cc6
-rw-r--r--content/common/resource_dispatcher.h3
-rw-r--r--content/common/resource_dispatcher_unittest.cc28
-rw-r--r--content/common/resource_messages.h6
6 files changed, 41 insertions, 13 deletions
diff --git a/content/browser/renderer_host/async_resource_handler.cc b/content/browser/renderer_host/async_resource_handler.cc
index 4e80081..d8ac365 100644
--- a/content/browser/renderer_host/async_resource_handler.cc
+++ b/content/browser/renderer_host/async_resource_handler.cc
@@ -216,8 +216,12 @@ bool AsyncResourceHandler::OnReadCompleted(int request_id, int* bytes_read) {
// We just unmapped the memory.
read_buffer_ = NULL;
+ net::URLRequest* request = rdh_->GetURLRequest(
+ GlobalRequestID(filter_->child_id(), request_id));
+ int raw_data_length =
+ DevToolsNetLogObserver::GetAndResetRawDataLength(request);
filter_->Send(new ResourceMsg_DataReceived(
- routing_id_, request_id, handle, *bytes_read));
+ routing_id_, request_id, handle, *bytes_read, raw_data_length));
return true;
}
diff --git a/content/browser/renderer_host/sync_resource_handler.cc b/content/browser/renderer_host/sync_resource_handler.cc
index 7b19a08..b474cf6 100644
--- a/content/browser/renderer_host/sync_resource_handler.cc
+++ b/content/browser/renderer_host/sync_resource_handler.cc
@@ -103,6 +103,11 @@ bool SyncResourceHandler::OnResponseCompleted(
const std::string& security_info) {
result_.status = status;
+ net::URLRequest* request = rdh_->GetURLRequest(
+ GlobalRequestID(filter_->child_id(), request_id));
+ result_.raw_data_length =
+ DevToolsNetLogObserver::GetAndResetRawDataLength(request);
+
ResourceHostMsg_SyncLoad::WriteReplyParams(result_message_, result_);
filter_->Send(result_message_);
result_message_ = NULL;
diff --git a/content/common/resource_dispatcher.cc b/content/common/resource_dispatcher.cc
index 7542551..9ed50bd 100644
--- a/content/common/resource_dispatcher.cc
+++ b/content/common/resource_dispatcher.cc
@@ -212,6 +212,7 @@ void IPCResourceLoaderBridge::SyncLoad(SyncLoadResponse* response) {
response->charset = result.charset;
response->request_time = result.request_time;
response->response_time = result.response_time;
+ response->raw_data_length = result.raw_data_length;
response->connection_id = result.connection_id;
response->connection_reused = result.connection_reused;
response->load_timing = result.load_timing;
@@ -336,7 +337,8 @@ void ResourceDispatcher::OnReceivedCachedMetadata(
void ResourceDispatcher::OnReceivedData(const IPC::Message& message,
int request_id,
base::SharedMemoryHandle shm_handle,
- int data_len) {
+ int data_len,
+ int raw_data_length) {
// Acknowledge the reception of this data.
message_sender()->Send(
new ResourceHostMsg_DataReceived_ACK(message.routing_id(), request_id));
@@ -351,7 +353,7 @@ void ResourceDispatcher::OnReceivedData(const IPC::Message& message,
if (data_len > 0 && shared_mem.Map(data_len)) {
const char* data = static_cast<char*>(shared_mem.memory());
- request_info->peer->OnReceivedData(data, data_len);
+ request_info->peer->OnReceivedData(data, data_len, raw_data_length);
}
}
diff --git a/content/common/resource_dispatcher.h b/content/common/resource_dispatcher.h
index 83fa4511..efe4514 100644
--- a/content/common/resource_dispatcher.h
+++ b/content/common/resource_dispatcher.h
@@ -126,7 +126,8 @@ class ResourceDispatcher : public IPC::Channel::Listener {
const IPC::Message& message,
int request_id,
base::SharedMemoryHandle data,
- int data_len);
+ int data_len,
+ int raw_data_length);
void OnDownloadedData(
const IPC::Message& message,
int request_id,
diff --git a/content/common/resource_dispatcher_unittest.cc b/content/common/resource_dispatcher_unittest.cc
index c92ab5e..0236262 100644
--- a/content/common/resource_dispatcher_unittest.cc
+++ b/content/common/resource_dispatcher_unittest.cc
@@ -56,9 +56,12 @@ class TestRequestCallback : public ResourceLoaderBridge::Peer {
virtual void OnDownloadedData(int len) {
}
- virtual void OnReceivedData(const char* data, int len) {
+ virtual void OnReceivedData(const char* data,
+ int data_length,
+ int raw_data_length) {
EXPECT_FALSE(complete_);
- data_.append(data, len);
+ data_.append(data, data_length);
+ total_raw_data_length_ += raw_data_length;
}
virtual void OnCompletedRequest(const net::URLRequestStatus& status,
@@ -68,16 +71,20 @@ class TestRequestCallback : public ResourceLoaderBridge::Peer {
complete_ = true;
}
+ bool complete() const {
+ return complete_;
+ }
const std::string& data() const {
return data_;
}
- bool complete() const {
- return complete_;
+ int total_raw_data_length() const {
+ return total_raw_data_length_;
}
private:
bool complete_;
std::string data_;
+ int total_raw_data_length_;
};
@@ -123,7 +130,11 @@ class ResourceDispatcherTest : public testing::Test,
EXPECT_TRUE(shared_mem.GiveToProcess(
base::Process::Current().handle(), &dup_handle));
dispatcher_->OnReceivedData(
- message_queue_[0], request_id, dup_handle, test_page_contents_len);
+ message_queue_[0],
+ request_id,
+ dup_handle,
+ test_page_contents_len,
+ test_page_contents_len);
message_queue_.erase(message_queue_.begin());
@@ -183,6 +194,7 @@ TEST_F(ResourceDispatcherTest, RoundTrip) {
// and dispatched, uncomment this.
//EXPECT_TRUE(callback.complete());
//EXPECT_STREQ(test_page_contents, callback.data().c_str());
+ //EXPECT_EQ(test_page_contents_len, callback.total_raw_data_length());
delete bridge;
}
@@ -242,7 +254,7 @@ class DeferredResourceLoadingTest : public ResourceDispatcherTest,
&duplicated_handle));
response_message =
- new ResourceMsg_DataReceived(0, 0, duplicated_handle, 100);
+ new ResourceMsg_DataReceived(0, 0, duplicated_handle, 100, 100);
dispatcher_->OnMessageReceived(*response_message);
@@ -272,7 +284,9 @@ class DeferredResourceLoadingTest : public ResourceDispatcherTest,
virtual void OnDownloadedData(int len) {
}
- virtual void OnReceivedData(const char* data, int len) {
+ virtual void OnReceivedData(const char* data,
+ int data_length,
+ int raw_data_length) {
EXPECT_EQ(defer_loading_, false);
set_defer_loading(false);
}
diff --git a/content/common/resource_messages.h b/content/common/resource_messages.h
index cb40e1f..5e6874a 100644
--- a/content/common/resource_messages.h
+++ b/content/common/resource_messages.h
@@ -20,6 +20,7 @@ IPC_STRUCT_TRAITS_BEGIN(webkit_glue::ResourceResponseInfo)
IPC_STRUCT_TRAITS_MEMBER(charset)
IPC_STRUCT_TRAITS_MEMBER(security_info)
IPC_STRUCT_TRAITS_MEMBER(content_length)
+ IPC_STRUCT_TRAITS_MEMBER(raw_data_length)
IPC_STRUCT_TRAITS_MEMBER(appcache_id)
IPC_STRUCT_TRAITS_MEMBER(appcache_manifest_url)
IPC_STRUCT_TRAITS_MEMBER(connection_id)
@@ -121,10 +122,11 @@ IPC_MESSAGE_ROUTED3(ResourceMsg_ReceivedRedirect,
// Sent when some data from a resource request is ready. The handle should
// already be mapped into the process that receives this message.
-IPC_MESSAGE_ROUTED3(ResourceMsg_DataReceived,
+IPC_MESSAGE_ROUTED4(ResourceMsg_DataReceived,
int /* request_id */,
base::SharedMemoryHandle /* data */,
- int /* data_len */)
+ int /* data_len */,
+ int /* raw_data_length */)
// Sent when some data from a resource request has been downloaded to
// file. This is only called in the 'download_to_file' case and replaces