summaryrefslogtreecommitdiffstats
path: root/webkit/glue/multipart_response_delegate_unittest.cc
diff options
context:
space:
mode:
authoriyengar@google.com <iyengar@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-19 02:09:49 +0000
committeriyengar@google.com <iyengar@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-19 02:09:49 +0000
commit84f89cacc8f09a2fbc1fd82b30af13dd35624869 (patch)
tree9e60daee9caffaaaa3da96fd46b0c4ba28318fc8 /webkit/glue/multipart_response_delegate_unittest.cc
parent172300b0cd0748cade220e03dcc2b3459ee14b80 (diff)
downloadchromium_src-84f89cacc8f09a2fbc1fd82b30af13dd35624869.zip
chromium_src-84f89cacc8f09a2fbc1fd82b30af13dd35624869.tar.gz
chromium_src-84f89cacc8f09a2fbc1fd82b30af13dd35624869.tar.bz2
This CB fixes the following issue1. http://code.google.com/p/chromium/issues/detail?id=206This is a performance issue while loading PDF documents. The fix is to support PDF fast webview, which is basically support for the NPN_RequestRead API, which allows a plugin to request specific byte ranges in HTTP GET requests. This also needs support for seekable streams. Our support for seekable streams is limited to HTTP servers which allow byte range requests. Firefox also supports a mode in which the the browser caches the file on disk for servers which don't support byte range requests. The plugin_data_stream.cc/.h files are being removed as there is not much value in their existence. The needed functionality is available in the PluginStreamUrl class, which now services manual data streams as well. Testing this is a touch tricky as we need a HTTP server which serves byte range requests. Will add those in a subsequent CB.Also fixed a bug in the multipart parser where we need to ignore leading newline characters while parsing the header.Bug=206
Review URL: http://codereview.chromium.org/2896 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2400 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/multipart_response_delegate_unittest.cc')
-rw-r--r--webkit/glue/multipart_response_delegate_unittest.cc89
1 files changed, 89 insertions, 0 deletions
diff --git a/webkit/glue/multipart_response_delegate_unittest.cc b/webkit/glue/multipart_response_delegate_unittest.cc
index 2e1d1f1..e5fd0c6 100644
--- a/webkit/glue/multipart_response_delegate_unittest.cc
+++ b/webkit/glue/multipart_response_delegate_unittest.cc
@@ -373,5 +373,94 @@ TEST(MultipartResponseTest, MultipleBoundaries) {
client.data_);
}
+TEST(MultipartResponseTest, MultipartByteRangeParsingTest) {
+ // Test multipart/byteranges based boundary parsing.
+ ResourceResponse response1(KURL(), "multipart/byteranges", 0, "en-US",
+ String());
+ response1.setHTTPHeaderField(String("Content-Length"), String("200"));
+ response1.setHTTPHeaderField(
+ String("Content-type"),
+ String("multipart/byteranges; boundary=--bound--"));
+
+ std::string multipart_boundary;
+ bool result = MultipartResponseDelegate::ReadMultipartBoundary(
+ response1, &multipart_boundary);
+ EXPECT_EQ(result, true);
+ EXPECT_EQ(string("--bound--"),
+ multipart_boundary);
+
+ ResourceResponse response2(KURL(), "image/png", 0, "en-US",
+ String());
+
+ response2.setHTTPHeaderField(String("Content-Length"), String("300"));
+ response2.setHTTPHeaderField(
+ String("Last-Modified"),
+ String("Mon, 04 Apr 2005 20:36:01 GMT"));
+ response2.setHTTPHeaderField(
+ String("Date"),
+ String("Thu, 11 Sep 2008 18:21:42 GMT"));
+
+ multipart_boundary.clear();
+ result = MultipartResponseDelegate::ReadMultipartBoundary(
+ response2, &multipart_boundary);
+ EXPECT_EQ(result, false);
+
+ ResourceResponse response3(KURL(), "multipart/byteranges", 0, "en-US",
+ String());
+
+ response3.setHTTPHeaderField(String("Content-Length"), String("300"));
+ response3.setHTTPHeaderField(
+ String("Last-Modified"),
+ String("Mon, 04 Apr 2005 20:36:01 GMT"));
+ response3.setHTTPHeaderField(
+ String("Date"),
+ String("Thu, 11 Sep 2008 18:21:42 GMT"));
+ response3.setHTTPHeaderField(
+ String("Content-type"),
+ String("multipart/byteranges"));
+
+ multipart_boundary.clear();
+ result = MultipartResponseDelegate::ReadMultipartBoundary(
+ response3, &multipart_boundary);
+ EXPECT_EQ(result, false);
+ EXPECT_EQ(multipart_boundary.length(), 0);
+}
+
+TEST(MultipartResponseTest, MultipartContentRangesTest) {
+ ResourceResponse response1(KURL(), "application/pdf", 0, "en-US",
+ String());
+ response1.setHTTPHeaderField(String("Content-Length"), String("200"));
+ response1.setHTTPHeaderField(
+ String("Content-Range"),
+ String("bytes 1000-1050/5000"));
+
+ int content_range_lower_bound = 0;
+ int content_range_upper_bound = 0;
+
+ bool result = MultipartResponseDelegate::ReadContentRanges(
+ response1, &content_range_lower_bound,
+ &content_range_upper_bound);
+
+ EXPECT_EQ(result, true);
+ EXPECT_EQ(content_range_lower_bound, 1000);
+ EXPECT_EQ(content_range_upper_bound, 1050);
+
+ ResourceResponse response2(KURL(), "application/pdf", 0, "en-US",
+ String());
+ response2.setHTTPHeaderField(String("Content-Length"), String("200"));
+ response2.setHTTPHeaderField(
+ String("Content-Range"),
+ String("bytes 1000/1050"));
+
+ content_range_lower_bound = 0;
+ content_range_upper_bound = 0;
+
+ result = MultipartResponseDelegate::ReadContentRanges(
+ response2, &content_range_lower_bound,
+ &content_range_upper_bound);
+
+ EXPECT_EQ(result, false);
+}
+
} // namespace