summaryrefslogtreecommitdiffstats
path: root/webkit/glue/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'webkit/glue/plugins')
-rw-r--r--webkit/glue/plugins/plugin_data_stream.cc46
-rw-r--r--webkit/glue/plugins/plugin_data_stream.h42
-rw-r--r--webkit/glue/plugins/plugin_host.cc17
-rw-r--r--webkit/glue/plugins/plugin_instance.cc79
-rw-r--r--webkit/glue/plugins/plugin_instance.h5
-rw-r--r--webkit/glue/plugins/plugin_stream.cc55
-rw-r--r--webkit/glue/plugins/plugin_stream.h32
-rw-r--r--webkit/glue/plugins/plugin_stream_url.cc29
-rw-r--r--webkit/glue/plugins/plugin_stream_url.h9
-rw-r--r--webkit/glue/plugins/plugin_string_stream.cc2
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl.cc13
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl.h3
12 files changed, 182 insertions, 150 deletions
diff --git a/webkit/glue/plugins/plugin_data_stream.cc b/webkit/glue/plugins/plugin_data_stream.cc
deleted file mode 100644
index da5f2d5..0000000
--- a/webkit/glue/plugins/plugin_data_stream.cc
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "webkit/glue/plugins/plugin_data_stream.h"
-
-#include "base/logging.h"
-
-namespace NPAPI {
-
-PluginDataStream::PluginDataStream(PluginInstance *instance,
- const std::string& url,
- const std::string& mime_type,
- const std::string& headers,
- uint32 expected_length,
- uint32 last_modified)
- : PluginStream(instance, url.c_str(), false, 0),
- mime_type_(mime_type),
- headers_(headers),
- expected_length_(expected_length),
- last_modified_(last_modified),
- stream_open_failed_(false) {
-}
-
-PluginDataStream::~PluginDataStream() {
-}
-
-void PluginDataStream::SendToPlugin(const char* buffer, int length) {
- if (stream_open_failed_)
- return;
-
- if (!open()) {
- if (!Open(mime_type_, headers_, expected_length_, last_modified_)) {
- stream_open_failed_ = true;
- return;
- }
- }
-
- // TODO(iyengar) - check if it was not fully sent, and figure out a
- // backup plan.
- int written = Write(buffer, length);
- DCHECK(written == length);
-}
-
-} // namespace NPAPI
-
diff --git a/webkit/glue/plugins/plugin_data_stream.h b/webkit/glue/plugins/plugin_data_stream.h
deleted file mode 100644
index cec0074..0000000
--- a/webkit/glue/plugins/plugin_data_stream.h
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef WEBKIT_GLUE_PLUGIN_PLUGIN_DATA_STREAM_H__
-#define WEBKIT_GLUE_PLUGIN_PLUGIN_DATA_STREAM_H__
-
-#include "webkit/glue/plugins/plugin_stream.h"
-
-namespace NPAPI {
-
-class PluginInstance;
-
-// A NPAPI stream based on data received from the renderer.
-class PluginDataStream : public PluginStream {
- public:
- // Create a new stream for sending to the plugin.
- PluginDataStream(PluginInstance *instance, const std::string& url,
- const std::string& mime_type, const std::string& headers,
- uint32 expected_length, uint32 last_modified);
- virtual ~PluginDataStream();
-
- // Initiates the sending of data to the plugin.
- void SendToPlugin(const char* buffer, int length);
-
- private:
- std::string mime_type_;
- std::string headers_;
- uint32 expected_length_;
- uint32 last_modified_;
- // This flag when set serves as an indicator that subsequent
- // data coming from the renderer should not be handed off to the plugin.
- bool stream_open_failed_;
-
- DISALLOW_EVIL_CONSTRUCTORS(PluginDataStream);
-};
-
-} // namespace NPAPI
-
-#endif // WEBKIT_GLUE_PLUGIN_PLUGIN_DATA_STREAM_H__
-
-
diff --git a/webkit/glue/plugins/plugin_host.cc b/webkit/glue/plugins/plugin_host.cc
index 8b92771..273219d 100644
--- a/webkit/glue/plugins/plugin_host.cc
+++ b/webkit/glue/plugins/plugin_host.cc
@@ -395,10 +395,19 @@ void NPN_ReloadPlugins(NPBool reloadPages) {
}
// Requests a range of bytes for a seekable stream.
-NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList) {
- // TODO: implement me
- DLOG(INFO) << "NPN_RequestedRead is not implemented yet.";
- return NPERR_GENERIC_ERROR;
+NPError NPN_RequestRead(NPStream* stream, NPByteRange* range_list) {
+ if (!stream || !range_list) {
+ return NPERR_GENERIC_ERROR;
+ }
+
+ scoped_refptr<NPAPI::PluginInstance> plugin =
+ reinterpret_cast<NPAPI::PluginInstance*>(stream->ndata);
+ if (!plugin.get()) {
+ return NPERR_GENERIC_ERROR;
+ }
+
+ plugin->RequestRead(stream, range_list);
+ return NPERR_NO_ERROR;
}
static bool IsJavaScriptUrl(const std::string& url) {
diff --git a/webkit/glue/plugins/plugin_instance.cc b/webkit/glue/plugins/plugin_instance.cc
index 46b28a9..0f81412 100644
--- a/webkit/glue/plugins/plugin_instance.cc
+++ b/webkit/glue/plugins/plugin_instance.cc
@@ -10,7 +10,6 @@
#include "webkit/glue/glue_util.h"
#include "webkit/glue/webplugin.h"
#include "webkit/glue/webkit_glue.h"
-#include "webkit/glue/plugins/plugin_data_stream.h"
#include "webkit/glue/plugins/plugin_host.h"
#include "webkit/glue/plugins/plugin_lib.h"
#include "webkit/glue/plugins/plugin_stream_url.h"
@@ -93,7 +92,7 @@ void PluginInstance::RemoveStream(PluginStream* stream) {
std::vector<scoped_refptr<PluginStream> >::iterator stream_index;
for (stream_index = open_streams_.begin();
- stream_index != open_streams_.end(); ++stream_index) {
+ stream_index != open_streams_.end(); ++stream_index) {
if (*stream_index == stream) {
open_streams_.erase(stream_index);
break;
@@ -356,32 +355,37 @@ void PluginInstance::DidReceiveManualResponse(const std::string& url,
response_url = instance_url_.spec();
}
- plugin_data_stream_ = new PluginDataStream(this, response_url, mime_type,
- headers, expected_length,
- last_modified);
+ bool cancel = false;
+
+ plugin_data_stream_ = CreateStream(-1, url, mime_type, false, NULL);
+
+ plugin_data_stream_->DidReceiveResponse(mime_type, headers, expected_length,
+ last_modified, &cancel);
AddStream(plugin_data_stream_.get());
}
void PluginInstance::DidReceiveManualData(const char* buffer, int length) {
DCHECK(load_manually_);
- DCHECK(plugin_data_stream_.get() != NULL);
- plugin_data_stream_->SendToPlugin(buffer, length);
+ if (plugin_data_stream_.get() != NULL) {
+ plugin_data_stream_->DidReceiveData(buffer, length, 0);
+ }
}
void PluginInstance::DidFinishManualLoading() {
DCHECK(load_manually_);
- DCHECK(plugin_data_stream_);
- plugin_data_stream_->Close(NPRES_DONE);
- RemoveStream(plugin_data_stream_.get());
- plugin_data_stream_ = NULL;
+ if (plugin_data_stream_.get() != NULL) {
+ plugin_data_stream_->DidFinishLoading();
+ plugin_data_stream_->Close(NPRES_DONE);
+ plugin_data_stream_ = NULL;
+ }
}
void PluginInstance::DidManualLoadFail() {
DCHECK(load_manually_);
- DCHECK(plugin_data_stream_);
- plugin_data_stream_->Close(NPRES_NETWORK_ERR);
- RemoveStream(plugin_data_stream_.get());
- plugin_data_stream_ = NULL;
+ if (plugin_data_stream_.get() != NULL) {
+ plugin_data_stream_->DidFail();
+ plugin_data_stream_ = NULL;
+ }
}
void PluginInstance::PluginThreadAsyncCall(void (*func)(void *),
@@ -436,5 +440,50 @@ void PluginInstance::PopPopupsEnabledState() {
popups_enabled_stack_.pop();
}
+void PluginInstance::RequestRead(NPStream* stream, NPByteRange* range_list) {
+ std::string range_info = "bytes=";
+
+ while (range_list) {
+ range_info += IntToString(range_list->offset);
+ range_info += "-";
+ range_info += IntToString(range_list->offset + range_list->length - 1);
+ range_list = range_list->next;
+ if (range_list) {
+ range_info += ",";
+ }
+ }
+
+ if (plugin_data_stream_) {
+ if (plugin_data_stream_->stream() == stream) {
+ webplugin_->CancelDocumentLoad();
+ plugin_data_stream_ = NULL;
+ }
+ }
+
+ // The lifetime of a NPStream instance depends on the PluginStream instance
+ // which owns it. When a plugin invokes NPN_RequestRead on a seekable stream,
+ // we don't want to create a new stream when the corresponding response is
+ // received. We send over a cookie which represents the PluginStream
+ // instance which is sent back from the renderer when the response is
+ // received.
+ std::vector<scoped_refptr<PluginStream> >::iterator stream_index;
+ for (stream_index = open_streams_.begin();
+ stream_index != open_streams_.end(); ++stream_index) {
+ PluginStream* plugin_stream = *stream_index;
+ if (plugin_stream->stream() == stream) {
+ // A stream becomes seekable the first time NPN_RequestRead
+ // is called on it.
+ plugin_stream->set_seekable(true);
+
+ webplugin_->InitiateHTTPRangeRequest(
+ stream->url, range_info.c_str(),
+ plugin_stream,
+ plugin_stream->notify_needed(),
+ plugin_stream->notify_data());
+ break;
+ }
+ }
+}
+
} // namespace NPAPI
diff --git a/webkit/glue/plugins/plugin_instance.h b/webkit/glue/plugins/plugin_instance.h
index b37153b..b6b1465 100644
--- a/webkit/glue/plugins/plugin_instance.h
+++ b/webkit/glue/plugins/plugin_instance.h
@@ -192,6 +192,9 @@ class PluginInstance : public base::RefCounted<PluginInstance> {
return popups_enabled_stack_.empty() ? false : popups_enabled_stack_.top();
}
+ // Initiates byte range reads for plugins.
+ void RequestRead(NPStream* stream, NPByteRange* range_list);
+
private:
void OnPluginThreadAsyncCall(void (*func)(void *),
void *userData);
@@ -238,7 +241,7 @@ class PluginInstance : public base::RefCounted<PluginInstance> {
// (MozillaExtensionApi) created as a result of NPN_GetValue
// in the context of NP_Initialize.
static ThreadLocalStorage::Slot plugin_instance_tls_index_;
- scoped_refptr<PluginDataStream> plugin_data_stream_;
+ scoped_refptr<PluginStreamUrl> plugin_data_stream_;
GURL instance_url_;
// This flag if true indicates that the plugin data would be passed from
diff --git a/webkit/glue/plugins/plugin_stream.cc b/webkit/glue/plugins/plugin_stream.cc
index 2c742ff..29cc99a 100644
--- a/webkit/glue/plugins/plugin_stream.cc
+++ b/webkit/glue/plugins/plugin_stream.cc
@@ -22,13 +22,14 @@ PluginStream::PluginStream(
bool need_notify,
void *notify_data)
: instance_(instance),
- bytes_sent_(0),
notify_needed_(need_notify),
notify_data_(notify_data),
close_on_write_data_(false),
opened_(false),
requested_plugin_mode_(NP_NORMAL),
- temp_file_handle_(INVALID_HANDLE_VALUE) {
+ temp_file_handle_(INVALID_HANDLE_VALUE),
+ seekable_stream_(false),
+ data_offset_(0) {
memset(&stream_, 0, sizeof(stream_));
stream_.url = _strdup(url);
temp_file_name_[0] = '\0';
@@ -37,7 +38,6 @@ PluginStream::PluginStream(
PluginStream::~PluginStream() {
// always cleanup our temporary files.
CleanupTempFile();
-
free(const_cast<char*>(stream_.url));
}
@@ -58,8 +58,14 @@ bool PluginStream::Open(const std::string &mime_type,
stream_.pdata = 0;
stream_.ndata = id->ndata;
stream_.notifyData = notify_data_;
- if (!headers_.empty())
+
+ bool seekable_stream = false;
+ if (!headers_.empty()) {
stream_.headers = headers_.c_str();
+ if (headers_.find("Accept-Ranges: bytes") != std::string::npos) {
+ seekable_stream = true;
+ }
+ }
const char *char_mime_type = "application/x-unknown-content-type";
std::string temp_mime_type;
@@ -75,26 +81,31 @@ bool PluginStream::Open(const std::string &mime_type,
// Silverlight expects a valid mime type
DCHECK(strlen(char_mime_type) != 0);
NPError err = instance_->NPP_NewStream((NPMIMEType)char_mime_type,
- &stream_, false,
+ &stream_, seekable_stream,
&requested_plugin_mode_);
if (err != NPERR_NO_ERROR)
return false;
opened_ = true;
+ if (requested_plugin_mode_ == NP_SEEK) {
+ seekable_stream_ = true;
+ }
+
// If the plugin has requested certain modes, then we need a copy
// of this file on disk. Open it and save it as we go.
if (requested_plugin_mode_ == NP_ASFILEONLY ||
- requested_plugin_mode_ == NP_ASFILE ||
- requested_plugin_mode_ == NP_SEEK) {
+ requested_plugin_mode_ == NP_ASFILE) {
if (OpenTempFile() == false)
return false;
}
+ mime_type_ = char_mime_type;
return true;
}
-int PluginStream::Write(const char *buffer, const int length) {
+int PluginStream::Write(const char *buffer, const int length,
+ int data_offset) {
// There may be two streams to write to - the plugin and the file.
// It is unclear what to do if we cannot write to both. The rules of
// this function are that the plugin must consume at least as many
@@ -103,7 +114,8 @@ int PluginStream::Write(const char *buffer, const int length) {
// to each stream, we'll return failure.
DCHECK(opened_);
- if (WriteToFile(buffer, length) && WriteToPlugin(buffer, length))
+ if (WriteToFile(buffer, length) &&
+ WriteToPlugin(buffer, length, data_offset))
return length;
return -1;
@@ -113,8 +125,7 @@ bool PluginStream::WriteToFile(const char *buf, const int length) {
// For ASFILEONLY, ASFILE, and SEEK modes, we need to write
// to the disk
if (temp_file_handle_ != INVALID_HANDLE_VALUE &&
- (requested_plugin_mode_ == NP_SEEK ||
- requested_plugin_mode_ == NP_ASFILE ||
+ (requested_plugin_mode_ == NP_ASFILE ||
requested_plugin_mode_ == NP_ASFILEONLY) ) {
int totalBytesWritten = 0;
DWORD bytes;
@@ -131,13 +142,15 @@ bool PluginStream::WriteToFile(const char *buf, const int length) {
return true;
}
-bool PluginStream::WriteToPlugin(const char *buf, const int length) {
+bool PluginStream::WriteToPlugin(const char *buf, const int length,
+ const int data_offset) {
// For NORMAL and ASFILE modes, we send the data to the plugin now
if (requested_plugin_mode_ != NP_NORMAL &&
- requested_plugin_mode_ != NP_ASFILE)
+ requested_plugin_mode_ != NP_ASFILE &&
+ requested_plugin_mode_ != NP_SEEK)
return true;
- int written = TryWriteToPlugin(buf, length);
+ int written = TryWriteToPlugin(buf, length, data_offset);
if (written == -1)
return false;
@@ -146,6 +159,7 @@ bool PluginStream::WriteToPlugin(const char *buf, const int length) {
size_t remaining = length - written;
size_t previous_size = delivery_data_.size();
delivery_data_.resize(previous_size + remaining);
+ data_offset_ = data_offset;
memcpy(&delivery_data_[previous_size], buf + written, remaining);
MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
this, &PluginStream::OnDelayDelivery));
@@ -162,7 +176,8 @@ void PluginStream::OnDelayDelivery() {
}
int size = static_cast<int>(delivery_data_.size());
- int written = TryWriteToPlugin(&delivery_data_.front(), size);
+ int written = TryWriteToPlugin(&delivery_data_.front(), size,
+ data_offset_);
if (written > 0) {
// Remove the data that we already wrote.
delivery_data_.erase(delivery_data_.begin(),
@@ -170,10 +185,14 @@ void PluginStream::OnDelayDelivery() {
}
}
-int PluginStream::TryWriteToPlugin(const char *buf, const int length) {
+int PluginStream::TryWriteToPlugin(const char *buf, const int length,
+ const int data_offset) {
bool result = true;
int byte_offset = 0;
+ if (data_offset > 0)
+ data_offset_ = data_offset;
+
while (byte_offset < length) {
int bytes_remaining = length - byte_offset;
int bytes_to_write = instance_->NPP_WriteReady(&stream_);
@@ -184,7 +203,7 @@ int PluginStream::TryWriteToPlugin(const char *buf, const int length) {
return byte_offset;
int bytes_consumed = instance_->NPP_Write(
- &stream_, bytes_sent_, bytes_to_write,
+ &stream_, data_offset_, 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.
@@ -199,7 +218,7 @@ int PluginStream::TryWriteToPlugin(const char *buf, const int length) {
// The plugin might report more that we gave it.
bytes_consumed = std::min(bytes_consumed, bytes_to_write);
- bytes_sent_ += bytes_consumed;
+ data_offset_ += bytes_consumed;
byte_offset += bytes_consumed;
}
diff --git a/webkit/glue/plugins/plugin_stream.h b/webkit/glue/plugins/plugin_stream.h
index f932be4..be9a594 100644
--- a/webkit/glue/plugins/plugin_stream.h
+++ b/webkit/glue/plugins/plugin_stream.h
@@ -12,6 +12,8 @@
#include "third_party/npapi/bindings/npapi.h"
+class WebPluginResourceClient;
+
namespace NPAPI {
class PluginInstance;
@@ -43,7 +45,7 @@ class PluginStream : public base::RefCounted<PluginStream> {
uint32 last_modified);
// Writes to the stream.
- int Write(const char *buf, const int len);
+ int Write(const char *buf, const int len, int data_offset);
// Write the result as a file.
void WriteAsFile();
@@ -54,9 +56,22 @@ class PluginStream : public base::RefCounted<PluginStream> {
// Close the stream.
virtual bool Close(NPReason reason);
- const NPStream* stream() const {
- return &stream_;
- }
+ virtual WebPluginResourceClient* AsResourceClient() { return NULL; }
+
+ // Cancels any HTTP requests initiated by the stream.
+ virtual void CancelRequest() {}
+
+ const NPStream* stream() const { return &stream_; }
+
+ // setter/getter for the seekable attribute on the stream.
+ bool seekable() const { return seekable_stream_; }
+
+ void set_seekable(bool seekable) { seekable_stream_ = seekable; }
+
+ // getters for reading the notification related attributes on the stream.
+ bool notify_needed() const { return notify_needed_; }
+
+ void* notify_data() const { return notify_data_; }
protected:
PluginInstance* instance() { return instance_.get(); }
@@ -80,11 +95,11 @@ class PluginStream : public base::RefCounted<PluginStream> {
// Sends the data to the plugin. If it's not ready, handles buffering it
// and retrying later.
- bool WriteToPlugin(const char *buf, const int length);
+ bool WriteToPlugin(const char *buf, const int length, const int data_offset);
// Send the data to the plugin, returning how many bytes it accepted, or -1
// if an error occurred.
- int TryWriteToPlugin(const char *buf, const int length);
+ int TryWriteToPlugin(const char *buf, const int length, const int data_offset);
// The callback which calls TryWriteToPlugin.
void OnDelayDelivery();
@@ -93,7 +108,6 @@ class PluginStream : public base::RefCounted<PluginStream> {
NPStream stream_;
std::string headers_;
scoped_refptr<PluginInstance> instance_;
- int bytes_sent_;
bool notify_needed_;
void * notify_data_;
bool close_on_write_data_;
@@ -102,7 +116,9 @@ class PluginStream : public base::RefCounted<PluginStream> {
char temp_file_name_[MAX_PATH];
HANDLE temp_file_handle_;
std::vector<char> delivery_data_;
-
+ int data_offset_;
+ bool seekable_stream_;
+ std::string mime_type_;
DISALLOW_EVIL_CONSTRUCTORS(PluginStream);
};
diff --git a/webkit/glue/plugins/plugin_stream_url.cc b/webkit/glue/plugins/plugin_stream_url.cc
index eda341a..c749ff7 100644
--- a/webkit/glue/plugins/plugin_stream_url.cc
+++ b/webkit/glue/plugins/plugin_stream_url.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+
#include "webkit/glue/plugins/plugin_stream_url.h"
#include "webkit/glue/glue_util.h"
@@ -26,14 +27,7 @@ PluginStreamUrl::~PluginStreamUrl() {
}
bool PluginStreamUrl::Close(NPReason reason) {
- if (id_ != 0) {
- if (instance()->webplugin()) {
- instance()->webplugin()->CancelResource(id_);
- }
-
- id_ = 0;
- }
-
+ CancelRequest();
bool result = PluginStream::Close(reason);
instance()->RemoveStream(this);
return result;
@@ -49,7 +43,6 @@ void PluginStreamUrl::DidReceiveResponse(const std::string& mime_type,
uint32 expected_length,
uint32 last_modified,
bool* cancel) {
-
bool opened = Open(mime_type,
headers,
expected_length,
@@ -60,21 +53,33 @@ void PluginStreamUrl::DidReceiveResponse(const std::string& mime_type,
}
}
-void PluginStreamUrl::DidReceiveData(const char* buffer, int length) {
+void PluginStreamUrl::DidReceiveData(const char* buffer, int length,
+ int data_offset) {
if (!open())
return;
if (length > 0)
- Write(const_cast<char*>(buffer), length);
+ Write(const_cast<char*>(buffer), length, data_offset);
}
void PluginStreamUrl::DidFinishLoading() {
- Close(NPRES_DONE);
+ if (!seekable()) {
+ Close(NPRES_DONE);
+ }
}
void PluginStreamUrl::DidFail() {
Close(NPRES_NETWORK_ERR);
}
+void PluginStreamUrl::CancelRequest() {
+ if (id_ > 0) {
+ if (instance()->webplugin()) {
+ instance()->webplugin()->CancelResource(id_);
+ }
+ id_ = 0;
+ }
+}
+
} // namespace NPAPI
diff --git a/webkit/glue/plugins/plugin_stream_url.h b/webkit/glue/plugins/plugin_stream_url.h
index ddffcd0..17213a2 100644
--- a/webkit/glue/plugins/plugin_stream_url.h
+++ b/webkit/glue/plugins/plugin_stream_url.h
@@ -34,6 +34,12 @@ class PluginStreamUrl : public PluginStream,
// it is still loading.
virtual bool Close(NPReason reason);
+ virtual WebPluginResourceClient* AsResourceClient() {
+ return static_cast<WebPluginResourceClient*>(this);
+ }
+
+ virtual void CancelRequest();
+
//
// WebPluginResourceClient methods
//
@@ -43,10 +49,11 @@ class PluginStreamUrl : public PluginStream,
uint32 expected_length,
uint32 last_modified,
bool* cancel);
- void DidReceiveData(const char* buffer, int length);
+ void DidReceiveData(const char* buffer, int length, int data_offset);
void DidFinishLoading();
void DidFail();
+
private:
GURL url_;
int id_;
diff --git a/webkit/glue/plugins/plugin_string_stream.cc b/webkit/glue/plugins/plugin_string_stream.cc
index eea9a45..b1ad8d1 100644
--- a/webkit/glue/plugins/plugin_string_stream.cc
+++ b/webkit/glue/plugins/plugin_string_stream.cc
@@ -22,7 +22,7 @@ void PluginStringStream::SendToPlugin(const std::string &data,
int length = static_cast<int>(data.length());
if (Open(mime_type, std::string(), length, 0)) {
// TODO - check if it was not fully sent, and figure out a backup plan.
- int written = Write(data.c_str(), length);
+ int written = Write(data.c_str(), length, 0);
NPReason reason = written == length ? NPRES_DONE : NPRES_NETWORK_ERR;
Close(reason);
}
diff --git a/webkit/glue/plugins/webplugin_delegate_impl.cc b/webkit/glue/plugins/webplugin_delegate_impl.cc
index 7c7c47f..ab8dc17 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl.cc
+++ b/webkit/glue/plugins/webplugin_delegate_impl.cc
@@ -1002,7 +1002,18 @@ WebCursor::Type WebPluginDelegateImpl::GetCursorType(
WebPluginResourceClient* WebPluginDelegateImpl::CreateResourceClient(
int resource_id, const std::string &url, bool notify_needed,
- void *notify_data) {
+ void *notify_data, void* existing_stream) {
+ // Stream already exists. This typically happens for range requests
+ // initiated via NPN_RequestRead.
+ if (existing_stream) {
+ NPAPI::PluginStream* plugin_stream =
+ reinterpret_cast<NPAPI::PluginStream*>(existing_stream);
+
+ plugin_stream->CancelRequest();
+
+ return plugin_stream->AsResourceClient();
+ }
+
if (notify_needed) {
instance()->SetURLLoadData(GURL(url.c_str()), notify_data);
}
diff --git a/webkit/glue/plugins/webplugin_delegate_impl.h b/webkit/glue/plugins/webplugin_delegate_impl.h
index 623bf02..7d750ae 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl.h
+++ b/webkit/glue/plugins/webplugin_delegate_impl.h
@@ -72,7 +72,8 @@ class WebPluginDelegateImpl : public WebPluginDelegate {
virtual WebPluginResourceClient* CreateResourceClient(int resource_id,
const std::string &url,
bool notify_needed,
- void *notify_data);
+ void *notify_data,
+ void* stream);
virtual void URLRequestRouted(const std::string&url, bool notify_needed,
void* notify_data);