summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authordarin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-08 20:02:07 +0000
committerdarin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-08 20:02:07 +0000
commit2964020f490c8ccd2fa24151ca68b8b90fc1296e (patch)
treedf84ce74ee10d09eec8f8a219558ec1288a7650d /webkit
parent7cc342811390ce2b26f27e80e8a79a28884574a1 (diff)
downloadchromium_src-2964020f490c8ccd2fa24151ca68b8b90fc1296e.zip
chromium_src-2964020f490c8ccd2fa24151ca68b8b90fc1296e.tar.gz
chromium_src-2964020f490c8ccd2fa24151ca68b8b90fc1296e.tar.bz2
Need to close the plugin stream if NPP_Write fails.
This occurs on YouTube when the user moves the slider to advance the video. Flash is doing this to inform the browser that it should cancel the existing stream. Without handling this error, we end up downloading the video multiple times from multiple offsets. After the user moves the slider 6 times, we will end up having saturated the maximum of 6 connections per host, and then YouTube video playback will appear to be wedged. R=joshia Review URL: http://codereview.chromium.org/1622 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1859 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/plugins/plugin_stream.cc24
-rw-r--r--webkit/glue/plugins/plugin_stream_url.h2
2 files changed, 17 insertions, 9 deletions
diff --git a/webkit/glue/plugins/plugin_stream.cc b/webkit/glue/plugins/plugin_stream.cc
index 370f588..2c742ff 100644
--- a/webkit/glue/plugins/plugin_stream.cc
+++ b/webkit/glue/plugins/plugin_stream.cc
@@ -183,16 +183,24 @@ int PluginStream::TryWriteToPlugin(const char *buf, const int length) {
if (bytes_to_write == 0)
return byte_offset;
- int bytesSent = instance_->NPP_Write(&stream_,
- bytes_sent_,
- bytes_to_write,
- const_cast<char*>(buf + byte_offset));
- if (bytesSent < bytes_to_write) {
- // We couldn't write all the bytes. This is an error.
+ int bytes_consumed = instance_->NPP_Write(
+ &stream_, bytes_sent_, bytes_to_write,
+ const_cast<char*>(buf + byte_offset));
+ if (bytes_consumed < 0) {
+ // The plugin failed, which means that we need to close the stream.
+ Close(NPRES_NETWORK_ERR);
return -1;
}
- bytes_sent_ += bytesSent;
- byte_offset += bytesSent;
+ if (bytes_consumed == 0) {
+ // The plugin couldn't take all of the data now.
+ return byte_offset;
+ }
+
+ // The plugin might report more that we gave it.
+ bytes_consumed = std::min(bytes_consumed, bytes_to_write);
+
+ bytes_sent_ += bytes_consumed;
+ byte_offset += bytes_consumed;
}
if (close_on_write_data_)
diff --git a/webkit/glue/plugins/plugin_stream_url.h b/webkit/glue/plugins/plugin_stream_url.h
index ee9f9da..ddffcd0 100644
--- a/webkit/glue/plugins/plugin_stream_url.h
+++ b/webkit/glue/plugins/plugin_stream_url.h
@@ -32,7 +32,7 @@ class PluginStreamUrl : public PluginStream,
// Stop sending the stream to the client.
// Overrides the base Close so we can cancel our fetching the URL if
// it is still loading.
- bool Close(NPReason reason);
+ virtual bool Close(NPReason reason);
//
// WebPluginResourceClient methods