diff options
author | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-04 09:29:24 +0000 |
---|---|---|
committer | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-04 09:29:24 +0000 |
commit | d94dc1e2a900b936a731046f436d79388bfd8005 (patch) | |
tree | 507b745ca06f9891ca4d8c2c646259b91b4a6984 /webkit/glue | |
parent | a1b5b0a8c82a4ab349d41b854ba84cff94eb72a3 (diff) | |
download | chromium_src-d94dc1e2a900b936a731046f436d79388bfd8005.zip chromium_src-d94dc1e2a900b936a731046f436d79388bfd8005.tar.gz chromium_src-d94dc1e2a900b936a731046f436d79388bfd8005.tar.bz2 |
Avoid having every frame of a multipart response create a new
row in the history database. We do this by setting a flag
on the WebURLResponse created for multipart responses and not
updating the history db when this flag is set.
Take 2, the last landing failed because we weren't always
initializing m_isMultipartPayload in ResourceResponse.
BUG=34350
Review URL: http://codereview.chromium.org/668050
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40613 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r-- | webkit/glue/multipart_response_delegate.cc | 9 | ||||
-rw-r--r-- | webkit/glue/multipart_response_delegate.h | 3 | ||||
-rw-r--r-- | webkit/glue/multipart_response_delegate_unittest.cc | 31 |
3 files changed, 42 insertions, 1 deletions
diff --git a/webkit/glue/multipart_response_delegate.cc b/webkit/glue/multipart_response_delegate.cc index 20e207a..8de6469 100644 --- a/webkit/glue/multipart_response_delegate.cc +++ b/webkit/glue/multipart_response_delegate.cc @@ -64,7 +64,8 @@ MultipartResponseDelegate::MultipartResponseDelegate( boundary_("--"), first_received_data_(true), processing_headers_(false), - stop_sending_(false) { + stop_sending_(false), + has_sent_first_response_(false) { // Some servers report a boundary prefixed with "--". See bug 5786. if (StartsWithASCII(boundary, "--", true)) { boundary_.assign(boundary); @@ -227,6 +228,12 @@ bool MultipartResponseDelegate::ParseHeaders() { WebString::fromUTF8(value)); } } + // To avoid recording every multipart load as a separate visit in + // the history database, we want to keep track of whether the response + // is part of a multipart payload. We do want to record the first visit, + // so we only set isMultipartPayload to true after the first visit. + response.setIsMultipartPayload(has_sent_first_response_); + has_sent_first_response_ = true; // Send the response! client_->didReceiveResponse(loader_, response); diff --git a/webkit/glue/multipart_response_delegate.h b/webkit/glue/multipart_response_delegate.h index 8ac496e..268999b 100644 --- a/webkit/glue/multipart_response_delegate.h +++ b/webkit/glue/multipart_response_delegate.h @@ -130,6 +130,9 @@ class MultipartResponseDelegate { // processing AddData requests. bool stop_sending_; + // true after we've sent our first response to the WebURLLoaderClient. + bool has_sent_first_response_; + DISALLOW_COPY_AND_ASSIGN(MultipartResponseDelegate); }; diff --git a/webkit/glue/multipart_response_delegate_unittest.cc b/webkit/glue/multipart_response_delegate_unittest.cc index b8d5fbe..7e3cc32 100644 --- a/webkit/glue/multipart_response_delegate_unittest.cc +++ b/webkit/glue/multipart_response_delegate_unittest.cc @@ -603,4 +603,35 @@ TEST(MultipartResponseTest, MultipartContentRangesTest) { EXPECT_EQ(result, false); } +TEST(MultipartResponseTest, MultipartPayloadSet) { + WebURLResponse response; + response.initialize(); + response.setMIMEType(WebString::fromUTF8("multipart/x-mixed-replace")); + MockWebURLLoaderClient client; + MultipartResponseDelegate delegate(&client, NULL, response, "bound"); + + string data( + "--bound\n" + "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\n"), + client.data_); + EXPECT_EQ(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\n"), + client.data_); + EXPECT_EQ(true, client.response_.isMultipartPayload()); +} + } // namespace |