diff options
author | vsevik@chromium.org <vsevik@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-08 18:52:10 +0000 |
---|---|---|
committer | vsevik@chromium.org <vsevik@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-08 18:52:10 +0000 |
commit | 8bd0de7e38b1f56b00e2ee8c2680b9306ede5eee (patch) | |
tree | fa146e5937db671b67ba8a425e0fcc9448d98a8d /webkit/glue | |
parent | 776c05d1347784290de3751bb753439204247591 (diff) | |
download | chromium_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 'webkit/glue')
-rw-r--r-- | webkit/glue/media/buffered_resource_loader.cc | 2 | ||||
-rw-r--r-- | webkit/glue/media/buffered_resource_loader.h | 2 | ||||
-rw-r--r-- | webkit/glue/multipart_response_delegate.cc | 18 | ||||
-rw-r--r-- | webkit/glue/multipart_response_delegate.h | 5 | ||||
-rw-r--r-- | webkit/glue/multipart_response_delegate_unittest.cc | 170 | ||||
-rw-r--r-- | webkit/glue/resource_fetcher.cc | 2 | ||||
-rw-r--r-- | webkit/glue/resource_fetcher.h | 2 | ||||
-rw-r--r-- | webkit/glue/resource_loader_bridge.cc | 1 | ||||
-rw-r--r-- | webkit/glue/resource_loader_bridge.h | 11 | ||||
-rw-r--r-- | webkit/glue/weburlloader_impl.cc | 19 |
10 files changed, 141 insertions, 91 deletions
diff --git a/webkit/glue/media/buffered_resource_loader.cc b/webkit/glue/media/buffered_resource_loader.cc index 8cca6f8..4eefe16 100644 --- a/webkit/glue/media/buffered_resource_loader.cc +++ b/webkit/glue/media/buffered_resource_loader.cc @@ -322,7 +322,7 @@ void BufferedResourceLoader::didReceiveData( WebURLLoader* loader, const char* data, int data_length, - int length_received) { + int raw_data_length) { DCHECK(!completed_); DCHECK_GT(data_length, 0); diff --git a/webkit/glue/media/buffered_resource_loader.h b/webkit/glue/media/buffered_resource_loader.h index 06b0590..52513e8 100644 --- a/webkit/glue/media/buffered_resource_loader.h +++ b/webkit/glue/media/buffered_resource_loader.h @@ -135,7 +135,7 @@ class BufferedResourceLoader : WebKit::WebURLLoader* loader, const char* data, int data_length, - int length_received); + int raw_data_length); virtual void didReceiveCachedMetadata( WebKit::WebURLLoader* loader, const char* data, int dataLength); diff --git a/webkit/glue/multipart_response_delegate.cc b/webkit/glue/multipart_response_delegate.cc index 53cdc3f..f45ec0f 100644 --- a/webkit/glue/multipart_response_delegate.cc +++ b/webkit/glue/multipart_response_delegate.cc @@ -62,6 +62,7 @@ MultipartResponseDelegate::MultipartResponseDelegate( : client_(client), loader_(loader), original_response_(response), + raw_data_length_(0), boundary_("--"), first_received_data_(true), processing_headers_(false), @@ -76,7 +77,8 @@ MultipartResponseDelegate::MultipartResponseDelegate( } void MultipartResponseDelegate::OnReceivedData(const char* data, - int data_len) { + int data_len, + int raw_data_length) { // stop_sending_ means that we've already received the final boundary token. // The server should stop sending us data at this point, but if it does, we // just throw it away. @@ -84,6 +86,7 @@ void MultipartResponseDelegate::OnReceivedData(const char* data, return; data_.append(data, data_len); + raw_data_length_ += raw_data_length; if (first_received_data_) { // Some servers don't send a boundary token before the first chunk of // data. We handle this case anyway (Gecko does too). @@ -141,7 +144,8 @@ void MultipartResponseDelegate::OnReceivedData(const char* data, client_->didReceiveData(loader_, data_.data(), static_cast<int>(data_length), - -1); + raw_data_length_); + raw_data_length_ = 0; } } size_t boundary_end_pos = boundary_pos + boundary_.length(); @@ -172,8 +176,12 @@ void MultipartResponseDelegate::OnReceivedData(const char* data, if (data_[data_.length() - 1] == '\n') send_length = data_.length(); if (client_) - client_->didReceiveData(loader_, data_.data(), send_length, -1); + client_->didReceiveData(loader_, + data_.data(), + send_length, + raw_data_length_); data_ = data_.substr(send_length); + raw_data_length_ = 0; } } @@ -183,7 +191,9 @@ void MultipartResponseDelegate::OnCompletedRequest() { if (!processing_headers_ && !data_.empty() && !stop_sending_ && client_) { client_->didReceiveData(loader_, data_.data(), - static_cast<int>(data_.length()), -1); + static_cast<int>(data_.length()), + raw_data_length_); + raw_data_length_ = 0; } } diff --git a/webkit/glue/multipart_response_delegate.h b/webkit/glue/multipart_response_delegate.h index d4583bb..7c82958 100644 --- a/webkit/glue/multipart_response_delegate.h +++ b/webkit/glue/multipart_response_delegate.h @@ -72,7 +72,7 @@ class MultipartResponseDelegate { const std::string& boundary); // Passed through from ResourceHandleInternal - void OnReceivedData(const char* data, int data_len); + void OnReceivedData(const char* data, int data_len, int raw_data_length); void OnCompletedRequest(); // The request has been canceled, so stop making calls to the client. @@ -120,6 +120,9 @@ class MultipartResponseDelegate { // full token. size_t FindBoundary(); + // Transferred data size accumulated between client callbacks. + int raw_data_length_; + // A temporary buffer to hold data between reads for multipart data that // gets split in the middle of a header. std::string data_; diff --git a/webkit/glue/multipart_response_delegate_unittest.cc b/webkit/glue/multipart_response_delegate_unittest.cc index b0fb6e6..0aba6e9 100644 --- a/webkit/glue/multipart_response_delegate_unittest.cc +++ b/webkit/glue/multipart_response_delegate_unittest.cc @@ -70,15 +70,16 @@ class MockWebURLLoaderClient : public WebURLLoaderClient { WebKit::WebURLLoader* loader, const char* data, int data_length, - int length_received) { + int raw_data_length) { ++received_data_; data_.append(data, data_length); + total_raw_data_length_ += raw_data_length; } virtual void didFinishLoading(WebURLLoader*, double finishTime) {} virtual void didFail(WebURLLoader*, const WebURLError&) {} void Reset() { - received_response_ = received_data_ = 0; + received_response_ = received_data_ = total_raw_data_length_ = 0; data_.clear(); response_.reset(); } @@ -87,7 +88,7 @@ class MockWebURLLoaderClient : public WebURLLoaderClient { return string(response_.httpHeaderField(WebString::fromUTF8(name)).utf8()); } - int received_response_, received_data_; + int received_response_, received_data_, total_raw_data_length_; string data_; WebURLResponse response_; }; @@ -216,11 +217,13 @@ TEST(MultipartResponseTest, MissingBoundaries) { "--bound--" "ignore junk after end token --bound\n\nTest2\n"); delegate.OnReceivedData(no_start_boundary.c_str(), + static_cast<int>(no_start_boundary.length()), static_cast<int>(no_start_boundary.length())); EXPECT_EQ(1, client.received_response_); EXPECT_EQ(1, client.received_data_); - EXPECT_EQ(string("This is a sample response"), - client.data_); + EXPECT_EQ(string("This is a sample response"), client.data_); + EXPECT_EQ(static_cast<int>(no_start_boundary.length()), + client.total_raw_data_length_); delegate.OnCompletedRequest(); EXPECT_EQ(1, client.received_response_); @@ -233,16 +236,20 @@ TEST(MultipartResponseTest, MissingBoundaries) { "bound\nContent-type: text/plain\n\n" "This is a sample response\n"); delegate2.OnReceivedData(no_end_boundary.c_str(), + static_cast<int>(no_end_boundary.length()), static_cast<int>(no_end_boundary.length())); EXPECT_EQ(1, client.received_response_); EXPECT_EQ(1, client.received_data_); EXPECT_EQ("This is a sample response\n", client.data_); + EXPECT_EQ(static_cast<int>(no_end_boundary.length()), + client.total_raw_data_length_); delegate2.OnCompletedRequest(); EXPECT_EQ(1, client.received_response_); EXPECT_EQ(1, client.received_data_); - EXPECT_EQ(string("This is a sample response\n"), - client.data_); + EXPECT_EQ(string("This is a sample response\n"), client.data_); + EXPECT_EQ(static_cast<int>(no_end_boundary.length()), + client.total_raw_data_length_); // Neither boundary client.Reset(); @@ -251,16 +258,20 @@ TEST(MultipartResponseTest, MissingBoundaries) { "Content-type: text/plain\n\n" "This is a sample response\n"); delegate3.OnReceivedData(no_boundaries.c_str(), + static_cast<int>(no_boundaries.length()), static_cast<int>(no_boundaries.length())); EXPECT_EQ(1, client.received_response_); EXPECT_EQ(1, client.received_data_); EXPECT_EQ("This is a sample response\n", client.data_); + EXPECT_EQ(static_cast<int>(no_boundaries.length()), + client.total_raw_data_length_); delegate3.OnCompletedRequest(); EXPECT_EQ(1, client.received_response_); EXPECT_EQ(1, client.received_data_); - EXPECT_EQ(string("This is a sample response\n"), - client.data_); + EXPECT_EQ(string("This is a sample response\n"), client.data_); + EXPECT_EQ(static_cast<int>(no_boundaries.length()), + client.total_raw_data_length_); } TEST(MultipartResponseTest, MalformedBoundary) { @@ -280,10 +291,13 @@ TEST(MultipartResponseTest, MalformedBoundary) { "This is a sample response\n" "--bound--" "ignore junk after end token --bound\n\nTest2\n"); - delegate.OnReceivedData(data.c_str(), static_cast<int>(data.length())); + delegate.OnReceivedData(data.c_str(), + static_cast<int>(data.length()), + static_cast<int>(data.length())); EXPECT_EQ(1, client.received_response_); EXPECT_EQ(1, client.received_data_); EXPECT_EQ(string("This is a sample response"), client.data_); + EXPECT_EQ(static_cast<int>(data.length()), client.total_raw_data_length_); delegate.OnCompletedRequest(); EXPECT_EQ(1, client.received_response_); @@ -298,11 +312,13 @@ struct TestChunk { const int expected_responses; const int expected_received_data; const char* expected_data; + const int expected_raw_data_length; }; void VariousChunkSizesTest(const TestChunk chunks[], int chunks_size, int responses, int received_data, - const char* completed_data) { + const char* completed_data, + int completed_raw_data_length) { const string data( "--bound\n" // 0-7 "Content-type: image/png\n\n" // 8-32 @@ -322,106 +338,107 @@ void VariousChunkSizesTest(const TestChunk chunks[], int chunks_size, ASSERT_TRUE(chunks[i].start_pos < chunks[i].end_pos); string chunk = data.substr(chunks[i].start_pos, chunks[i].end_pos - chunks[i].start_pos); - delegate.OnReceivedData(chunk.c_str(), static_cast<int>(chunk.length())); - EXPECT_EQ(chunks[i].expected_responses, - client.received_response_); - EXPECT_EQ(chunks[i].expected_received_data, - client.received_data_); - EXPECT_EQ(string(chunks[i].expected_data), - client.data_); + delegate.OnReceivedData( + chunk.c_str(), + static_cast<int>(chunk.length()), + static_cast<int>(chunk.length())); + EXPECT_EQ(chunks[i].expected_responses, client.received_response_); + EXPECT_EQ(chunks[i].expected_received_data, client.received_data_); + EXPECT_EQ(string(chunks[i].expected_data), client.data_); + EXPECT_EQ(chunks[i].expected_raw_data_length, + client.total_raw_data_length_); } // Check final state delegate.OnCompletedRequest(); - EXPECT_EQ(responses, - client.received_response_); - EXPECT_EQ(received_data, - client.received_data_); - EXPECT_EQ(string(completed_data), - client.data_); + EXPECT_EQ(responses, client.received_response_); + EXPECT_EQ(received_data, client.received_data_); + string completed_data_string(completed_data); + EXPECT_EQ(completed_data_string, client.data_); + EXPECT_EQ(completed_raw_data_length, client.total_raw_data_length_); } TEST(MultipartResponseTest, BreakInBoundary) { // Break in the first boundary const TestChunk bound1[] = { - { 0, 4, 0, 0, ""}, - { 4, 110, 2, 2, "foofoofoofoofoo" }, + { 0, 4, 0, 0, "", 0 }, + { 4, 110, 2, 2, "foofoofoofoofoo", 110 }, }; VariousChunkSizesTest(bound1, arraysize(bound1), - 2, 2, "foofoofoofoofoo"); + 2, 2, "foofoofoofoofoo", 110); // Break in first and second const TestChunk bound2[] = { - { 0, 4, 0, 0, ""}, - { 4, 55, 1, 1, "datadatadatadat" }, - { 55, 65, 1, 2, "datadatadatadatadata" }, - { 65, 110, 2, 3, "foofoofoofoofoo" }, + { 0, 4, 0, 0, "", 0 }, + { 4, 55, 1, 1, "datadatadatadat", 55 }, + { 55, 65, 1, 2, "datadatadatadatadata", 65 }, + { 65, 110, 2, 3, "foofoofoofoofoo", 110 }, }; VariousChunkSizesTest(bound2, arraysize(bound2), - 2, 3, "foofoofoofoofoo"); + 2, 3, "foofoofoofoofoo", 110); // Break in second only const TestChunk bound3[] = { - { 0, 55, 1, 1, "datadatadatadat" }, - { 55, 110, 2, 3, "foofoofoofoofoo" }, + { 0, 55, 1, 1, "datadatadatadat", 55 }, + { 55, 110, 2, 3, "foofoofoofoofoo", 110 }, }; VariousChunkSizesTest(bound3, arraysize(bound3), - 2, 3, "foofoofoofoofoo"); + 2, 3, "foofoofoofoofoo", 110); } TEST(MultipartResponseTest, BreakInHeaders) { // Break in first header const TestChunk header1[] = { - { 0, 10, 0, 0, "" }, - { 10, 35, 1, 0, "" }, - { 35, 110, 2, 2, "foofoofoofoofoo" }, + { 0, 10, 0, 0, "", 0 }, + { 10, 35, 1, 0, "", 0 }, + { 35, 110, 2, 2, "foofoofoofoofoo", 110 }, }; VariousChunkSizesTest(header1, arraysize(header1), - 2, 2, "foofoofoofoofoo"); + 2, 2, "foofoofoofoofoo", 110); // Break in both headers const TestChunk header2[] = { - { 0, 10, 0, 0, "" }, - { 10, 65, 1, 1, "datadatadatadatadata" }, - { 65, 110, 2, 2, "foofoofoofoofoo" }, + { 0, 10, 0, 0, "", 0 }, + { 10, 65, 1, 1, "datadatadatadatadata", 65 }, + { 65, 110, 2, 2, "foofoofoofoofoo", 110 }, }; VariousChunkSizesTest(header2, arraysize(header2), - 2, 2, "foofoofoofoofoo"); + 2, 2, "foofoofoofoofoo", 110); // Break at end of a header const TestChunk header3[] = { - { 0, 33, 1, 0, "" }, - { 33, 65, 1, 1, "datadatadatadatadata" }, - { 65, 110, 2, 2, "foofoofoofoofoo" }, + { 0, 33, 1, 0, "", 0 }, + { 33, 65, 1, 1, "datadatadatadatadata", 65 }, + { 65, 110, 2, 2, "foofoofoofoofoo", 110 }, }; VariousChunkSizesTest(header3, arraysize(header3), - 2, 2, "foofoofoofoofoo"); + 2, 2, "foofoofoofoofoo", 110); } TEST(MultipartResponseTest, BreakInData) { // All data as one chunk const TestChunk data1[] = { - { 0, 110, 2, 2, "foofoofoofoofoo" }, + { 0, 110, 2, 2, "foofoofoofoofoo", 110 }, }; VariousChunkSizesTest(data1, arraysize(data1), - 2, 2, "foofoofoofoofoo"); + 2, 2, "foofoofoofoofoo", 110); // breaks in data segment const TestChunk data2[] = { - { 0, 35, 1, 0, "" }, - { 35, 65, 1, 1, "datadatadatadatadata" }, - { 65, 90, 2, 1, "" }, - { 90, 110, 2, 2, "foofoofoofoofoo" }, + { 0, 35, 1, 0, "", 0 }, + { 35, 65, 1, 1, "datadatadatadatadata", 65 }, + { 65, 90, 2, 1, "", 65 }, + { 90, 110, 2, 2, "foofoofoofoofoo", 110 }, }; VariousChunkSizesTest(data2, arraysize(data2), - 2, 2, "foofoofoofoofoo"); + 2, 2, "foofoofoofoofoo", 110); // Incomplete send const TestChunk data3[] = { - { 0, 35, 1, 0, "" }, - { 35, 90, 2, 1, "" }, + { 0, 35, 1, 0, "", 0 }, + { 35, 90, 2, 1, "", 90 }, }; VariousChunkSizesTest(data3, arraysize(data3), - 2, 2, "foof"); + 2, 2, "foof", 90); } TEST(MultipartResponseTest, SmallChunk) { @@ -440,10 +457,12 @@ TEST(MultipartResponseTest, SmallChunk) { "--boundContent-type: text/plain\n\n" "end--bound--"); delegate.OnReceivedData(data.c_str(), + static_cast<int>(data.length()), static_cast<int>(data.length())); EXPECT_EQ(4, client.received_response_); EXPECT_EQ(2, client.received_data_); EXPECT_EQ(string("end"), client.data_); + EXPECT_EQ(static_cast<int>(data.length()), client.total_raw_data_length_); delegate.OnCompletedRequest(); EXPECT_EQ(4, client.received_response_); @@ -459,13 +478,13 @@ TEST(MultipartResponseTest, MultipleBoundaries) { MultipartResponseDelegate delegate(&client, NULL, response, "bound"); string data("--bound\r\n\r\n--bound\r\n\r\nfoofoo--bound--"); - delegate.OnReceivedData(data.c_str(), static_cast<int>(data.length())); - EXPECT_EQ(2, - client.received_response_); - EXPECT_EQ(1, - client.received_data_); - EXPECT_EQ(string("foofoo"), - client.data_); + delegate.OnReceivedData(data.c_str(), + static_cast<int>(data.length()), + static_cast<int>(data.length())); + EXPECT_EQ(2, client.received_response_); + EXPECT_EQ(1, client.received_data_); + EXPECT_EQ(string("foofoo"), client.data_); + EXPECT_EQ(static_cast<int>(data.length()), client.total_raw_data_length_); } TEST(MultipartResponseTest, MultipartByteRangeParsingTest) { @@ -628,22 +647,25 @@ TEST(MultipartResponseTest, MultipartPayloadSet) { "Content-type: text/plain\n\n" "response data\n" "--bound\n"); - delegate.OnReceivedData(data.c_str(), static_cast<int>(data.length())); - EXPECT_EQ(1, - client.received_response_); - EXPECT_EQ(string("response data"), - client.data_); + delegate.OnReceivedData(data.c_str(), + static_cast<int>(data.length()), + static_cast<int>(data.length())); + EXPECT_EQ(1, client.received_response_); + EXPECT_EQ(string("response data"), client.data_); + EXPECT_EQ(static_cast<int>(data.length()), client.total_raw_data_length_); EXPECT_FALSE(client.response_.isMultipartPayload()); string data2( "Content-type: text/plain\n\n" "response data2\n" "--bound\n"); - delegate.OnReceivedData(data2.c_str(), static_cast<int>(data2.length())); - EXPECT_EQ(2, - client.received_response_); - EXPECT_EQ(string("response data2"), - client.data_); + delegate.OnReceivedData(data2.c_str(), + static_cast<int>(data2.length()), + static_cast<int>(data2.length())); + EXPECT_EQ(2, client.received_response_); + EXPECT_EQ(string("response data2"), client.data_); + EXPECT_EQ(static_cast<int>(data.length()) + static_cast<int>(data2.length()), + client.total_raw_data_length_); EXPECT_TRUE(client.response_.isMultipartPayload()); } diff --git a/webkit/glue/resource_fetcher.cc b/webkit/glue/resource_fetcher.cc index f7907fb..2e2fc74 100644 --- a/webkit/glue/resource_fetcher.cc +++ b/webkit/glue/resource_fetcher.cc @@ -86,7 +86,7 @@ void ResourceFetcher::didReceiveResponse( void ResourceFetcher::didReceiveData( WebURLLoader* loader, const char* data, int data_length, - int length_received) { + int raw_data_length) { DCHECK(!completed_); DCHECK(data_length > 0); diff --git a/webkit/glue/resource_fetcher.h b/webkit/glue/resource_fetcher.h index d9b3460..908658e 100644 --- a/webkit/glue/resource_fetcher.h +++ b/webkit/glue/resource_fetcher.h @@ -66,7 +66,7 @@ class ResourceFetcher : public WebKit::WebURLLoaderClient { virtual void didReceiveData( WebKit::WebURLLoader* loader, const char* data, int data_length, - int length_received); + int raw_data_length); virtual void didFinishLoading( WebKit::WebURLLoader* loader, double finishTime); virtual void didFail( diff --git a/webkit/glue/resource_loader_bridge.cc b/webkit/glue/resource_loader_bridge.cc index b757921..ab757df 100644 --- a/webkit/glue/resource_loader_bridge.cc +++ b/webkit/glue/resource_loader_bridge.cc @@ -35,6 +35,7 @@ ResourceDevToolsInfo::~ResourceDevToolsInfo() {} ResourceResponseInfo::ResourceResponseInfo() : content_length(-1), + raw_data_length(-1), appcache_id(appcache::kNoCacheId), connection_id(0), connection_reused(false), diff --git a/webkit/glue/resource_loader_bridge.h b/webkit/glue/resource_loader_bridge.h index e5f7d2e..df55897 100644 --- a/webkit/glue/resource_loader_bridge.h +++ b/webkit/glue/resource_loader_bridge.h @@ -141,6 +141,10 @@ struct ResourceResponseInfo { // Content length if available. -1 if not available int64 content_length; + // Length of the raw data transferred over the network. In case there is no + // data, contains -1. + int64 raw_data_length; + // The appcache this response was loaded from, or kNoCacheId. int64 appcache_id; @@ -301,7 +305,12 @@ class ResourceLoaderBridge { // Called when a chunk of response data is available. This method may // be called multiple times or not at all if an error occurs. - virtual void OnReceivedData(const char* data, int len) = 0; + // The raw_data_length is the length of the raw data transferred over the + // network, which could be different from data length (e.g. for gzipped + // content), or -1 if if unknown. + virtual void OnReceivedData(const char* data, + int data_length, + int raw_data_length) = 0; // Called when metadata generated by the renderer is retrieved from the // cache. This method may be called zero or one times. diff --git a/webkit/glue/weburlloader_impl.cc b/webkit/glue/weburlloader_impl.cc index 2c0659a..c3d79be 100644 --- a/webkit/glue/weburlloader_impl.cc +++ b/webkit/glue/weburlloader_impl.cc @@ -157,6 +157,7 @@ bool GetInfoFromDataURL(const GURL& url, info->charset.swap(charset); info->security_info.clear(); info->content_length = -1; + info->raw_data_length = 0; info->load_timing.base_time = Time::Now(); return true; @@ -295,7 +296,9 @@ class WebURLLoaderImpl::Context : public base::RefCounted<Context>, GURL* new_first_party_for_cookies); virtual void OnReceivedResponse(const ResourceResponseInfo& info); 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); virtual void OnReceivedCachedMetadata(const char* data, int len); virtual void OnCompletedRequest(const net::URLRequestStatus& status, const std::string& security_info, @@ -591,23 +594,25 @@ void WebURLLoaderImpl::Context::OnDownloadedData(int len) { client_->didDownloadData(loader_, len); } -void WebURLLoaderImpl::Context::OnReceivedData(const char* data, int len) { +void WebURLLoaderImpl::Context::OnReceivedData(const char* data, + int data_length, + int raw_data_length) { if (!client_) return; // Temporary logging, see site_isolation_metrics.h/cc. - SiteIsolationMetrics::SniffCrossOriginHTML(response_url_, data, len); + SiteIsolationMetrics::SniffCrossOriginHTML(response_url_, data, data_length); if (ftp_listing_delegate_.get()) { // The FTP listing delegate will make the appropriate calls to // client_->didReceiveData and client_->didReceiveResponse. - ftp_listing_delegate_->OnReceivedData(data, len); + ftp_listing_delegate_->OnReceivedData(data, data_length); } else if (multipart_delegate_.get()) { // The multipart delegate will make the appropriate calls to // client_->didReceiveData and client_->didReceiveResponse. - multipart_delegate_->OnReceivedData(data, len); + multipart_delegate_->OnReceivedData(data, data_length, raw_data_length); } else { - client_->didReceiveData(loader_, data, len, -1); + client_->didReceiveData(loader_, data, data_length, raw_data_length); } } @@ -694,7 +699,7 @@ void WebURLLoaderImpl::Context::HandleDataURL() { if (GetInfoFromDataURL(request_.url(), &info, &data, &status)) { OnReceivedResponse(info); if (!data.empty()) - OnReceivedData(data.data(), data.size()); + OnReceivedData(data.data(), data.size(), 0); } OnCompletedRequest(status, info.security_info, base::Time::Now()); |