Use blocking worker pool for sync file operations in Pepper.
Switch from posting file operations on the file thread to posting them on the blocking worker pool. Previous instrumentation indicated that this reduces hung-plugin infobars by around 20%. BUG=153383 Review URL: https://chromiumcodereview.appspot.com/11093059 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161459 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
content/browser
renderer_host
web_contents
@ -10,6 +10,7 @@
|
||||
#include "base/logging.h"
|
||||
#include "base/platform_file.h"
|
||||
#include "base/process_util.h"
|
||||
#include "base/threading/sequenced_worker_pool.h"
|
||||
#include "content/browser/child_process_security_policy_impl.h"
|
||||
#include "content/browser/renderer_host/render_process_host_impl.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
@ -67,11 +68,19 @@ PepperFileMessageFilter::PepperFileMessageFilter(int child_id)
|
||||
channel_(NULL) {
|
||||
}
|
||||
|
||||
void PepperFileMessageFilter::OverrideThreadForMessage(
|
||||
const IPC::Message& message,
|
||||
BrowserThread::ID* thread) {
|
||||
base::TaskRunner* PepperFileMessageFilter::OverrideTaskRunnerForMessage(
|
||||
const IPC::Message& message) {
|
||||
// The blocking pool provides a pool of threads to run file
|
||||
// operations, instead of a single thread which might require
|
||||
// queuing time. Since these messages are synchronous as sent from
|
||||
// the plugin, the sending thread cannot send a new message until
|
||||
// this one returns, so there is no need to sequence tasks here. If
|
||||
// the plugin has multiple threads, it cannot make assumptions about
|
||||
// ordering of IPC message sends, so it cannot make assumptions
|
||||
// about ordering of operations caused by those IPC messages.
|
||||
if (IPC_MESSAGE_CLASS(message) == PepperFileMsgStart)
|
||||
*thread = BrowserThread::FILE;
|
||||
return BrowserThread::GetBlockingPool();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool PepperFileMessageFilter::OnMessageReceived(const IPC::Message& message,
|
||||
|
@ -33,9 +33,8 @@ class PepperFileMessageFilter : public content::BrowserMessageFilter {
|
||||
explicit PepperFileMessageFilter(int child_id);
|
||||
|
||||
// content::BrowserMessageFilter methods:
|
||||
virtual void OverrideThreadForMessage(
|
||||
const IPC::Message& message,
|
||||
content::BrowserThread::ID* thread) OVERRIDE;
|
||||
virtual base::TaskRunner* OverrideTaskRunnerForMessage(
|
||||
const IPC::Message& message) OVERRIDE;
|
||||
virtual bool OnMessageReceived(const IPC::Message& message,
|
||||
bool* message_was_ok) OVERRIDE;
|
||||
virtual void OnDestruct() const OVERRIDE;
|
||||
|
@ -2344,6 +2344,8 @@ void WebContentsImpl::OnSetSelectedColorInColorChooser(int color_chooser_id,
|
||||
void WebContentsImpl::OnPepperPluginHung(int plugin_child_id,
|
||||
const FilePath& path,
|
||||
bool is_hung) {
|
||||
UMA_HISTOGRAM_COUNTS("Pepper.PluginHung", 1);
|
||||
|
||||
FOR_EACH_OBSERVER(WebContentsObserver, observers_,
|
||||
PluginHungStatusChanged(plugin_child_id, path, is_hung));
|
||||
}
|
||||
|
Reference in New Issue
Block a user