summaryrefslogtreecommitdiffstats
path: root/content/ppapi_plugin
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-20 02:35:48 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-20 02:35:48 +0000
commitcd781859e94bc4cedb35371cf4d6d1e161e87a11 (patch)
tree568ca78f3ec265af5dae2b1f178fdc95604f0134 /content/ppapi_plugin
parentd38c1b0a6e3f4cfeb5a5700f00523c5364d49f27 (diff)
downloadchromium_src-cd781859e94bc4cedb35371cf4d6d1e161e87a11.zip
chromium_src-cd781859e94bc4cedb35371cf4d6d1e161e87a11.tar.gz
chromium_src-cd781859e94bc4cedb35371cf4d6d1e161e87a11.tar.bz2
Revert 118385 since this seems to break mac-debug build.
""" Remove the Webkit thread in the PPAPI plugin process and perform the text and font operations on the PPAPI main thread. This thread is now registered as the Webkit thread. Fixes performance issues seen in Flapper with text and font operations. It appears that the perf issues occur due to context switching between the main thread and the webkit thread. As per comments from Brett moving the font forwarding code inline to ppb_font_shared.cc. This file has been moved to ppapi/shared_impl/private as it now brings in a dependency on WebKit. The font creation has been wired up to the ResourceCreationAPI as suggested. BUG=110190 R=brettw Review URL: https://chromiumcodereview.appspot.com/9133015 TBR=ananta@chromium.org Review URL: https://chromiumcodereview.appspot.com/9150055 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118399 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/ppapi_plugin')
-rw-r--r--content/ppapi_plugin/ppapi_thread.cc20
-rw-r--r--content/ppapi_plugin/ppapi_thread.h13
-rw-r--r--content/ppapi_plugin/ppapi_webkit_thread.cc44
-rw-r--r--content/ppapi_plugin/ppapi_webkit_thread.h50
4 files changed, 118 insertions, 9 deletions
diff --git a/content/ppapi_plugin/ppapi_thread.cc b/content/ppapi_plugin/ppapi_thread.cc
index 3277f1b..e989785 100644
--- a/content/ppapi_plugin/ppapi_thread.cc
+++ b/content/ppapi_plugin/ppapi_thread.cc
@@ -14,7 +14,7 @@
#include "content/common/child_process_messages.h"
#include "content/ppapi_plugin/broker_process_dispatcher.h"
#include "content/ppapi_plugin/plugin_process_dispatcher.h"
-#include "content/ppapi_plugin/ppapi_webkitplatformsupport_impl.h"
+#include "content/ppapi_plugin/ppapi_webkit_thread.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/sandbox_init.h"
#include "ipc/ipc_channel_handle.h"
@@ -25,7 +25,7 @@
#include "ppapi/proxy/plugin_globals.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/proxy/interface_list.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
+#include "webkit/plugins/ppapi/webkit_forwarding_impl.h"
#if defined(OS_WIN)
#include "sandbox/src/sandbox.h"
@@ -50,8 +50,6 @@ PpapiThread::PpapiThread(bool is_broker)
base::RandInt(0, std::numeric_limits<PP_Module>::max())),
next_plugin_dispatcher_id_(1) {
ppapi::proxy::PluginGlobals::Get()->set_plugin_proxy_delegate(this);
- webkit_platform_support_.reset(new PpapiWebKitPlatformSupportImpl);
- WebKit::initialize(webkit_platform_support_.get());
}
PpapiThread::~PpapiThread() {
@@ -69,7 +67,6 @@ PpapiThread::~PpapiThread() {
library_.GetFunctionPointer("PPP_ShutdownModule"));
if (shutdown_function)
shutdown_function();
- WebKit::shutdown();
}
// The "regular" ChildThread implements this function and does some standard
@@ -114,6 +111,19 @@ std::set<PP_Instance>* PpapiThread::GetGloballySeenInstanceIDSet() {
return &globally_seen_instance_ids_;
}
+ppapi::WebKitForwarding* PpapiThread::GetWebKitForwarding() {
+ if (!webkit_forwarding_.get())
+ webkit_forwarding_.reset(new webkit::ppapi::WebKitForwardingImpl);
+ return webkit_forwarding_.get();
+}
+
+void PpapiThread::PostToWebKitThread(const tracked_objects::Location& from_here,
+ const base::Closure& task) {
+ if (!webkit_thread_.get())
+ webkit_thread_.reset(new PpapiWebKitThread);
+ webkit_thread_->PostTask(from_here, task);
+}
+
bool PpapiThread::SendToBrowser(IPC::Message* msg) {
return Send(msg);
}
diff --git a/content/ppapi_plugin/ppapi_thread.h b/content/ppapi_plugin/ppapi_thread.h
index bff66db..56e12c5 100644
--- a/content/ppapi_plugin/ppapi_thread.h
+++ b/content/ppapi_plugin/ppapi_thread.h
@@ -22,7 +22,7 @@
#include "ppapi/proxy/plugin_proxy_delegate.h"
class FilePath;
-class PpapiWebKitPlatformSupportImpl;
+class PpapiWebKitThread;
namespace IPC {
struct ChannelHandle;
@@ -48,6 +48,9 @@ class PpapiThread : public ChildThread,
virtual void Unregister(uint32 plugin_dispatcher_id) OVERRIDE;
// PluginProxyDelegate.
+ virtual ppapi::WebKitForwarding* GetWebKitForwarding() OVERRIDE;
+ virtual void PostToWebKitThread(const tracked_objects::Location& from_here,
+ const base::Closure& task) OVERRIDE;
virtual bool SendToBrowser(IPC::Message* msg) OVERRIDE;
virtual void PreCacheFont(const void* logfontw) OVERRIDE;
@@ -89,13 +92,15 @@ class PpapiThread : public ChildThread,
// See Dispatcher::Delegate::GetGloballySeenInstanceIDSet.
std::set<PP_Instance> globally_seen_instance_ids_;
+ // Lazily created by GetWebKitForwarding.
+ scoped_ptr<ppapi::WebKitForwarding> webkit_forwarding_;
+
+ scoped_ptr<PpapiWebKitThread> webkit_thread_;
+
// The PluginDispatcher instances contained in the map are not owned by it.
std::map<uint32, ppapi::proxy::PluginDispatcher*> plugin_dispatchers_;
uint32 next_plugin_dispatcher_id_;
- // The WebKitPlatformSupport implementation.
- scoped_ptr<PpapiWebKitPlatformSupportImpl> webkit_platform_support_;
-
DISALLOW_IMPLICIT_CONSTRUCTORS(PpapiThread);
};
diff --git a/content/ppapi_plugin/ppapi_webkit_thread.cc b/content/ppapi_plugin/ppapi_webkit_thread.cc
new file mode 100644
index 0000000..cb3d482
--- /dev/null
+++ b/content/ppapi_plugin/ppapi_webkit_thread.cc
@@ -0,0 +1,44 @@
+// Copyright (c) 2011 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 "content/ppapi_plugin/ppapi_webkit_thread.h"
+
+#include "base/logging.h"
+#include "content/ppapi_plugin/ppapi_webkitplatformsupport_impl.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
+
+PpapiWebKitThread::PpapiWebKitThread() {
+ DCHECK(!webkit_thread_.get());
+
+ webkit_thread_.reset(new InternalWebKitThread);
+ bool started = webkit_thread_->Start();
+ DCHECK(started);
+}
+
+PpapiWebKitThread::~PpapiWebKitThread() {
+}
+
+void PpapiWebKitThread::PostTask(const tracked_objects::Location& from_here,
+ const base::Closure& task) {
+ webkit_thread_->message_loop()->PostTask(from_here, task);
+}
+
+PpapiWebKitThread::InternalWebKitThread::InternalWebKitThread()
+ : base::Thread("PPAPIWebKit") {
+}
+
+PpapiWebKitThread::InternalWebKitThread::~InternalWebKitThread() {
+ Stop();
+}
+
+void PpapiWebKitThread::InternalWebKitThread::Init() {
+ DCHECK(!webkit_platform_support_.get());
+ webkit_platform_support_.reset(new PpapiWebKitPlatformSupportImpl);
+ WebKit::initialize(webkit_platform_support_.get());
+}
+
+void PpapiWebKitThread::InternalWebKitThread::CleanUp() {
+ DCHECK(webkit_platform_support_.get());
+ WebKit::shutdown();
+}
diff --git a/content/ppapi_plugin/ppapi_webkit_thread.h b/content/ppapi_plugin/ppapi_webkit_thread.h
new file mode 100644
index 0000000..a7606f6
--- /dev/null
+++ b/content/ppapi_plugin/ppapi_webkit_thread.h
@@ -0,0 +1,50 @@
+// Copyright (c) 2011 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 CONTENT_PPAPI_PLUGIN_PPAPI_WEBKIT_THREAD_H_
+#define CONTENT_PPAPI_PLUGIN_PPAPI_WEBKIT_THREAD_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/threading/thread.h"
+
+class PpapiWebKitPlatformSupportImpl;
+
+// This creates a WebKit main thread on instantiation on construction and kills
+// it on deletion. See also content/browser/in_process_webkit for the
+// corresponding concept in the browser process.
+class PpapiWebKitThread {
+ public:
+ PpapiWebKitThread();
+ ~PpapiWebKitThread();
+
+ // Posts the given task to the thread, see MessageLoop::PostTask.
+ void PostTask(
+ const tracked_objects::Location& from_here,
+ const base::Closure& task);
+
+ private:
+ // Must be private so that we can carefully control its lifetime.
+ class InternalWebKitThread : public base::Thread {
+ public:
+ InternalWebKitThread();
+ virtual ~InternalWebKitThread();
+ // Does the actual initialization and shutdown of WebKit. Called at the
+ // beginning and end of the thread's lifetime.
+ virtual void Init() OVERRIDE;
+ virtual void CleanUp() OVERRIDE;
+
+ private:
+ // The WebKitPlatformSupport implementation. Only access on WebKit thread.
+ scoped_ptr<PpapiWebKitPlatformSupportImpl> webkit_platform_support_;
+ };
+
+ // Pointer to the actual WebKitThread.
+ scoped_ptr<InternalWebKitThread> webkit_thread_;
+
+ DISALLOW_COPY_AND_ASSIGN(PpapiWebKitThread);
+};
+
+#endif // CONTENT_PPAPI_PLUGIN_PPAPI_WEBKIT_THREAD_H_