diff options
author | iyengar@google.com <iyengar@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-19 02:09:49 +0000 |
---|---|---|
committer | iyengar@google.com <iyengar@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-19 02:09:49 +0000 |
commit | 84f89cacc8f09a2fbc1fd82b30af13dd35624869 (patch) | |
tree | 9e60daee9caffaaaa3da96fd46b0c4ba28318fc8 /webkit/glue/multipart_response_delegate.cc | |
parent | 172300b0cd0748cade220e03dcc2b3459ee14b80 (diff) | |
download | chromium_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.cc')
-rw-r--r-- | webkit/glue/multipart_response_delegate.cc | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/webkit/glue/multipart_response_delegate.cc b/webkit/glue/multipart_response_delegate.cc index 7bef1c3..1fc9e34 100644 --- a/webkit/glue/multipart_response_delegate.cc +++ b/webkit/glue/multipart_response_delegate.cc @@ -72,6 +72,11 @@ void MultipartResponseDelegate::OnReceivedData(const char* data, int data_len) { // Headers if (processing_headers_) { + // Eat leading \r\n + int pos = PushOverLine(data_, 0); + if (pos) + data_ = data_.substr(pos); + if (ParseHeaders()) { // Successfully parsed headers. processing_headers_ = false; @@ -227,3 +232,78 @@ size_t MultipartResponseDelegate::FindBoundary() { return boundary_pos; } +bool MultipartResponseDelegate::ReadMultipartBoundary( + const WebCore::ResourceResponse& response, + std::string* multipart_boundary) { + + WebCore::String content_type = response.httpHeaderField("Content-Type"); + std::string content_type_as_string = + webkit_glue::StringToStdString(content_type); + + size_t boundary_start_offset = content_type_as_string.find("boundary="); + if (boundary_start_offset == std::wstring::npos) { + return false; + } + + boundary_start_offset += strlen("boundary="); + size_t boundary_end_offset = content_type.length(); + + size_t boundary_length = boundary_end_offset - boundary_start_offset; + + *multipart_boundary = + content_type_as_string.substr(boundary_start_offset, boundary_length); + return true; +} + +bool MultipartResponseDelegate::ReadContentRanges( + const WebCore::ResourceResponse& response, + int* content_range_lower_bound, + int* content_range_upper_bound) { + + std::string content_range = + webkit_glue::StringToStdString( + response.httpHeaderField("Content-Range")); + + size_t byte_range_lower_bound_start_offset = + content_range.find(" "); + if (byte_range_lower_bound_start_offset == std::string::npos) { + return false; + } + + // Skip over the initial space. + byte_range_lower_bound_start_offset++; + + size_t byte_range_lower_bound_end_offset = + content_range.find("-", byte_range_lower_bound_start_offset); + if (byte_range_lower_bound_end_offset == std::string::npos) { + return false; + } + + size_t byte_range_lower_bound_characters = + byte_range_lower_bound_end_offset - byte_range_lower_bound_start_offset; + std::string byte_range_lower_bound = + content_range.substr(byte_range_lower_bound_start_offset, + byte_range_lower_bound_characters); + + size_t byte_range_upper_bound_start_offset = + byte_range_lower_bound_end_offset + 1; + + size_t byte_range_upper_bound_end_offset = + content_range.find("/", byte_range_upper_bound_start_offset); + if (byte_range_upper_bound_end_offset == std::string::npos) { + return false; + } + + size_t byte_range_upper_bound_characters = + byte_range_upper_bound_end_offset - byte_range_upper_bound_start_offset; + + std::string byte_range_upper_bound = + content_range.substr(byte_range_upper_bound_start_offset, + byte_range_upper_bound_characters); + + if (!StringToInt(byte_range_lower_bound, content_range_lower_bound)) + return false; + if (!StringToInt(byte_range_upper_bound, content_range_upper_bound)) + return false; + return true; +} |