summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-01 05:03:01 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-01 05:03:01 +0000
commitd55d90f2b56a250503ff865d4eb398e538a9384d (patch)
tree3e97a1ec6bdfaba02180b9adb8e994d1e4d6eee4
parent6ad6487eb2a02e6657863ff79821a5755ca2139c (diff)
downloadchromium_src-d55d90f2b56a250503ff865d4eb398e538a9384d.zip
chromium_src-d55d90f2b56a250503ff865d4eb398e538a9384d.tar.gz
chromium_src-d55d90f2b56a250503ff865d4eb398e538a9384d.tar.bz2
Make http range requests by plugins also go directly to the browser process instead of going through the renderers.
BUG=286074 R=ananta@chromium.org Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=260678 Review URL: https://codereview.chromium.org/217593003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@260776 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/browser/plugin_process_host.cc15
-rw-r--r--content/child/npapi/plugin_instance.cc18
-rw-r--r--content/child/npapi/plugin_stream_url.cc27
-rw-r--r--content/child/npapi/plugin_stream_url.h7
-rw-r--r--content/child/npapi/plugin_url_fetcher.cc7
-rw-r--r--content/child/npapi/plugin_url_fetcher.h10
-rw-r--r--content/child/npapi/webplugin_delegate_impl.cc2
-rw-r--r--content/plugin/plugin_thread.cc6
-rw-r--r--content/plugin/plugin_thread.h3
9 files changed, 78 insertions, 17 deletions
diff --git a/content/browser/plugin_process_host.cc b/content/browser/plugin_process_host.cc
index 8aa69dd..b6d54b9 100644
--- a/content/browser/plugin_process_host.cc
+++ b/content/browser/plugin_process_host.cc
@@ -205,15 +205,9 @@ bool PluginProcessHost::Init(const WebPluginInfo& info) {
// any associated values) if present in the browser command line
static const char* const kSwitchNames[] = {
switches::kDisableBreakpad,
-#if defined(OS_MACOSX)
- switches::kDisableCoreAnimationPlugins,
- switches::kEnableSandboxLogging,
-#endif
+ switches::kDisableDirectNPAPIRequests,
switches::kEnableStatsTable,
switches::kFullMemoryCrashReport,
-#if defined(OS_WIN)
- switches::kHighDPISupport,
-#endif
switches::kLoggingLevel,
switches::kLogPluginMessages,
switches::kNoSandbox,
@@ -221,6 +215,13 @@ bool PluginProcessHost::Init(const WebPluginInfo& info) {
switches::kTestSandbox,
switches::kTraceStartup,
switches::kUseGL,
+#if defined(OS_MACOSX)
+ switches::kDisableCoreAnimationPlugins,
+ switches::kEnableSandboxLogging,
+#endif
+#if defined(OS_WIN)
+ switches::kHighDPISupport,
+#endif
};
cmd_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
diff --git a/content/child/npapi/plugin_instance.cc b/content/child/npapi/plugin_instance.cc
index a7e2b94..b141c5a 100644
--- a/content/child/npapi/plugin_instance.cc
+++ b/content/child/npapi/plugin_instance.cc
@@ -5,6 +5,7 @@
#include "content/child/npapi/plugin_instance.h"
#include "base/bind.h"
+#include "base/command_line.h"
#include "base/file_util.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/string_number_conversions.h"
@@ -18,6 +19,7 @@
#include "content/child/npapi/webplugin_delegate.h"
#include "content/child/npapi/webplugin_resource_client.h"
#include "content/public/common/content_constants.h"
+#include "content/public/common/content_switches.h"
#include "net/base/escape.h"
#if defined(OS_MACOSX)
@@ -557,10 +559,18 @@ void PluginInstance::RequestRead(NPStream* stream, NPByteRange* range_list) {
// is called on it.
plugin_stream->set_seekable(true);
- pending_range_requests_[++next_range_request_id_] = plugin_stream;
- webplugin_->InitiateHTTPRangeRequest(
- stream->url, range_info.c_str(), next_range_request_id_);
- return;
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kDisableDirectNPAPIRequests)) {
+ pending_range_requests_[++next_range_request_id_] = plugin_stream;
+ webplugin_->InitiateHTTPRangeRequest(
+ stream->url, range_info.c_str(), next_range_request_id_);
+ return;
+ } else {
+ PluginStreamUrl* plugin_stream_url =
+ static_cast<PluginStreamUrl*>(plugin_stream);
+ plugin_stream_url->FetchRange(range_info);
+ return;
+ }
}
}
NOTREACHED();
diff --git a/content/child/npapi/plugin_stream_url.cc b/content/child/npapi/plugin_stream_url.cc
index d042e1c..84490d7 100644
--- a/content/child/npapi/plugin_stream_url.cc
+++ b/content/child/npapi/plugin_stream_url.cc
@@ -6,6 +6,7 @@
#include <algorithm>
+#include "base/stl_util.h"
#include "base/strings/string_util.h"
#include "content/child/npapi/plugin_host.h"
#include "content/child/npapi/plugin_instance.h"
@@ -42,6 +43,17 @@ void PluginStreamUrl::URLRedirectResponse(bool allow) {
UpdateUrl(pending_redirect_url_.c_str());
}
+void PluginStreamUrl::FetchRange(const std::string& range) {
+ PluginURLFetcher* range_fetcher = new PluginURLFetcher(
+ this, url_, plugin_url_fetcher_->first_party_for_cookies(), "GET", NULL,
+ 0, plugin_url_fetcher_->referrer(), range, false, false,
+ plugin_url_fetcher_->origin_pid(),
+ plugin_url_fetcher_->render_frame_id(),
+ plugin_url_fetcher_->render_view_id(), id_,
+ plugin_url_fetcher_->copy_stream_data());
+ range_request_fetchers_.push_back(range_fetcher);
+}
+
bool PluginStreamUrl::Close(NPReason reason) {
// Protect the stream against it being destroyed or the whole plugin instance
// being destroyed within the destroy stream handler.
@@ -71,7 +83,10 @@ void PluginStreamUrl::CancelRequest() {
for (size_t i = 0; i < range_requests_.size(); ++i)
instance()->webplugin()->CancelResource(range_requests_[i]);
}
+
range_requests_.clear();
+
+ STLDeleteElements(&range_request_fetchers_);
}
void PluginStreamUrl::WillSendRequest(const GURL& url, int http_status_code) {
@@ -165,6 +180,8 @@ PluginStreamUrl::~PluginStreamUrl() {
if (!plugin_url_fetcher_.get() && instance() && instance()->webplugin()) {
instance()->webplugin()->ResourceClientDeleted(AsResourceClient());
}
+
+ STLDeleteElements(&range_request_fetchers_);
}
void PluginStreamUrl::AddRangeRequestResourceId(unsigned long resource_id) {
@@ -176,11 +193,11 @@ void PluginStreamUrl::SetDeferLoading(bool value) {
// If we determined that the request had failed via the HTTP headers in the
// response then we send out a failure notification to the plugin process, as
// certain plugins don't handle HTTP failure codes correctly.
- if (!value &&
- plugin_url_fetcher_.get() &&
- plugin_url_fetcher_->pending_failure_notification()) {
- // This object may be deleted now.
- DidFail(id_);
+ if (plugin_url_fetcher_.get()) {
+ if (!value && plugin_url_fetcher_->pending_failure_notification()) {
+ // This object may be deleted now.
+ DidFail(id_);
+ }
return;
}
if (id_ > 0)
diff --git a/content/child/npapi/plugin_stream_url.h b/content/child/npapi/plugin_stream_url.h
index 3b52d85..f63593d 100644
--- a/content/child/npapi/plugin_stream_url.h
+++ b/content/child/npapi/plugin_stream_url.h
@@ -34,6 +34,8 @@ class PluginStreamUrl : public PluginStream,
void URLRedirectResponse(bool allow);
+ void FetchRange(const std::string& range);
+
// Stop sending the stream to the client.
// Overrides the base Close so we can cancel our fetching the URL if
// it is still loading.
@@ -69,9 +71,14 @@ class PluginStreamUrl : public PluginStream,
GURL url_;
unsigned long id_;
+
// Ids of additional resources requested via range requests issued on
// seekable streams.
+ // This is used when we're loading resources through the renderer, i.e. not
+ // using plugin_url_fetcher_.
std::vector<unsigned long> range_requests_;
+ // This is used when we're using plugin_url_fetcher_.
+ std::vector<PluginURLFetcher*> range_request_fetchers_;
// If the plugin participates in HTTP URL redirect handling then this member
// holds the url being redirected to while we wait for the plugin to make a
diff --git a/content/child/npapi/plugin_url_fetcher.cc b/content/child/npapi/plugin_url_fetcher.cc
index 6695f76..0b5d6eb 100644
--- a/content/child/npapi/plugin_url_fetcher.cc
+++ b/content/child/npapi/plugin_url_fetcher.cc
@@ -81,6 +81,7 @@ PluginURLFetcher::PluginURLFetcher(PluginStreamUrl* plugin_stream,
const char* buf,
unsigned int len,
const GURL& referrer,
+ const std::string& range,
bool notify_redirects,
bool is_plugin_src_load,
int origin_pid,
@@ -95,6 +96,9 @@ PluginURLFetcher::PluginURLFetcher(PluginStreamUrl* plugin_stream,
referrer_(referrer),
notify_redirects_(notify_redirects),
is_plugin_src_load_(is_plugin_src_load),
+ origin_pid_(origin_pid),
+ render_frame_id_(render_frame_id),
+ render_view_id_(render_view_id),
resource_id_(resource_id),
copy_stream_data_(copy_stream_data),
data_offset_(0),
@@ -133,6 +137,9 @@ PluginURLFetcher::PluginURLFetcher(PluginStreamUrl* plugin_stream,
request_info.headers += "\r\n";
request_info.headers += "Content-Type: application/x-www-form-urlencoded";
}
+ } else {
+ if (!range.empty())
+ request_info.headers = std::string("Range: ") + range;
}
bridge_.reset(ChildThread::current()->resource_dispatcher()->CreateBridge(
diff --git a/content/child/npapi/plugin_url_fetcher.h b/content/child/npapi/plugin_url_fetcher.h
index 4e5e2ff..dca40ec 100644
--- a/content/child/npapi/plugin_url_fetcher.h
+++ b/content/child/npapi/plugin_url_fetcher.h
@@ -29,6 +29,7 @@ class PluginURLFetcher : public webkit_glue::ResourceLoaderBridge::Peer {
const char* buf,
unsigned int len,
const GURL& referrer,
+ const std::string& range,
bool notify_redirects,
bool is_plugin_src_load,
int origin_pid,
@@ -44,6 +45,12 @@ class PluginURLFetcher : public webkit_glue::ResourceLoaderBridge::Peer {
// Called with the plugin's reply to NPP_URLRedirectNotify.
void URLRedirectResponse(bool allow);
+ GURL first_party_for_cookies() { return first_party_for_cookies_; }
+ GURL referrer() { return referrer_; }
+ int origin_pid() { return origin_pid_; }
+ int render_frame_id() { return render_frame_id_; }
+ int render_view_id() { return render_view_id_; }
+ bool copy_stream_data() { return copy_stream_data_; }
bool pending_failure_notification() { return pending_failure_notification_; }
private:
@@ -74,6 +81,9 @@ class PluginURLFetcher : public webkit_glue::ResourceLoaderBridge::Peer {
GURL referrer_;
bool notify_redirects_;
bool is_plugin_src_load_;
+ int origin_pid_;
+ int render_frame_id_;
+ int render_view_id_;
unsigned long resource_id_;
bool copy_stream_data_;
int64 data_offset_;
diff --git a/content/child/npapi/webplugin_delegate_impl.cc b/content/child/npapi/webplugin_delegate_impl.cc
index c904278..e53cbc3 100644
--- a/content/child/npapi/webplugin_delegate_impl.cc
+++ b/content/child/npapi/webplugin_delegate_impl.cc
@@ -325,7 +325,7 @@ void WebPluginDelegateImpl::FetchURL(unsigned long resource_id,
bool copy_stream_data = !!(quirks_ & PLUGIN_QUIRK_COPY_STREAM_DATA);
plugin_stream->SetPluginURLFetcher(new PluginURLFetcher(
plugin_stream, url, first_party_for_cookies, method, buf, len,
- referrer, notify_redirects, is_plugin_src_load, origin_pid,
+ referrer, std::string(), notify_redirects, is_plugin_src_load, origin_pid,
render_frame_id, render_view_id, resource_id, copy_stream_data));
}
diff --git a/content/plugin/plugin_thread.cc b/content/plugin/plugin_thread.cc
index 204bc02..2573256 100644
--- a/content/plugin/plugin_thread.cc
+++ b/content/plugin/plugin_thread.cc
@@ -21,12 +21,14 @@
#include "base/process/kill.h"
#include "base/process/process_handle.h"
#include "base/threading/thread_local.h"
+#include "content/child/blink_platform_impl.h"
#include "content/child/child_process.h"
#include "content/child/npapi/npobject_util.h"
#include "content/child/npapi/plugin_lib.h"
#include "content/common/plugin_process_messages.h"
#include "content/public/common/content_switches.h"
#include "content/public/plugin/content_plugin_client.h"
+#include "third_party/WebKit/public/web/WebKit.h"
#include "ipc/ipc_channel_handle.h"
#if defined(TOOLKIT_GTK)
@@ -124,6 +126,10 @@ PluginThread::PluginThread()
plugin.get() ? plugin->plugin_info().name : base::string16());
channel()->AddFilter(new EnsureTerminateMessageFilter());
+
+ // This is needed because we call some code which uses WebKit strings.
+ webkit_platform_support_.reset(new BlinkPlatformImpl);
+ blink::initialize(webkit_platform_support_.get());
}
PluginThread::~PluginThread() {
diff --git a/content/plugin/plugin_thread.h b/content/plugin/plugin_thread.h
index 5ca2c02..f76cfa1 100644
--- a/content/plugin/plugin_thread.h
+++ b/content/plugin/plugin_thread.h
@@ -17,6 +17,7 @@
#endif
namespace content {
+class BlinkPlatformImpl;
// The PluginThread class represents a background thread where plugin instances
// live. Communication occurs between WebPluginDelegateProxy in the renderer
@@ -51,6 +52,8 @@ class PluginThread : public ChildThread {
bool forcefully_terminate_plugin_process_;
+ scoped_ptr<BlinkPlatformImpl> webkit_platform_support_;
+
DISALLOW_COPY_AND_ASSIGN(PluginThread);
};