Commit ca998e5e authored by jam@chromium.org's avatar jam@chromium.org

Move gamepad reader code out of PepperHelperImpl in the effort to eliminate...

Move gamepad reader code out of PepperHelperImpl in the effort to eliminate PepperHelperImpl. I'm also making one instance per renderer instead of one per process for WebKit in RendererWebKitPlatformSupportImpl, and one per RenderView for Pepper.

BUG=263054
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/22320006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@215897 0039d316-1c4b-4281-b951-d872f2087c98
parent 1a22d622
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#include "content/public/common/referrer.h" #include "content/public/common/referrer.h"
#include "content/public/common/webplugininfo.h" #include "content/public/common/webplugininfo.h"
#include "content/public/renderer/content_renderer_client.h" #include "content/public/renderer/content_renderer_client.h"
#include "content/renderer/gamepad_shared_memory_reader.h"
#include "content/renderer/media/media_stream_dispatcher.h" #include "content/renderer/media/media_stream_dispatcher.h"
#include "content/renderer/p2p/socket_dispatcher.h" #include "content/renderer/p2p/socket_dispatcher.h"
#include "content/renderer/pepper/content_renderer_pepper_host_factory.h" #include "content/renderer/pepper/content_renderer_pepper_host_factory.h"
...@@ -631,12 +630,6 @@ void PepperHelperImpl::DidReceiveMouseEvent( ...@@ -631,12 +630,6 @@ void PepperHelperImpl::DidReceiveMouseEvent(
last_mouse_event_target_ = instance; last_mouse_event_target_ = instance;
} }
void PepperHelperImpl::SampleGamepads(WebKit::WebGamepads* data) {
if (!gamepad_shared_memory_reader_)
gamepad_shared_memory_reader_.reset(new GamepadSharedMemoryReader);
gamepad_shared_memory_reader_->SampleGamepads(*data);
}
bool PepperHelperImpl::OnMessageReceived(const IPC::Message& message) { bool PepperHelperImpl::OnMessageReceived(const IPC::Message& message) {
bool handled = true; bool handled = true;
IPC_BEGIN_MESSAGE_MAP(PepperHelperImpl, message) IPC_BEGIN_MESSAGE_MAP(PepperHelperImpl, message)
......
...@@ -31,7 +31,6 @@ struct URLResponseInfoData; ...@@ -31,7 +31,6 @@ struct URLResponseInfoData;
} }
namespace WebKit { namespace WebKit {
class WebGamepads;
class WebURLResponse; class WebURLResponse;
struct WebCompositionUnderline; struct WebCompositionUnderline;
struct WebCursorInfo; struct WebCursorInfo;
...@@ -39,7 +38,6 @@ struct WebCursorInfo; ...@@ -39,7 +38,6 @@ struct WebCursorInfo;
namespace content { namespace content {
class ContextProviderCommandBuffer; class ContextProviderCommandBuffer;
class GamepadSharedMemoryReader;
class PepperBroker; class PepperBroker;
class PluginModule; class PluginModule;
class PPB_Broker_Impl; class PPB_Broker_Impl;
...@@ -96,9 +94,6 @@ class PepperHelperImpl : public PepperHelper, ...@@ -96,9 +94,6 @@ class PepperHelperImpl : public PepperHelper,
// from this call. // from this call.
void InstanceDeleted(PepperPluginInstanceImpl* instance); void InstanceDeleted(PepperPluginInstanceImpl* instance);
// Retrieve current gamepad data.
void SampleGamepads(WebKit::WebGamepads* data);
// Sets up the renderer host and out-of-process proxy for an external plugin // Sets up the renderer host and out-of-process proxy for an external plugin
// module. Returns the renderer host, or NULL if it couldn't be created. // module. Returns the renderer host, or NULL if it couldn't be created.
RendererPpapiHost* CreateExternalPluginModule( RendererPpapiHost* CreateExternalPluginModule(
...@@ -200,8 +195,6 @@ class PepperHelperImpl : public PepperHelper, ...@@ -200,8 +195,6 @@ class PepperHelperImpl : public PepperHelper,
// when it is destroyed via InstanceDeleted(). // when it is destroyed via InstanceDeleted().
PepperPluginInstanceImpl* last_mouse_event_target_; PepperPluginInstanceImpl* last_mouse_event_target_;
scoped_ptr<GamepadSharedMemoryReader> gamepad_shared_memory_reader_;
scoped_refptr<ContextProviderCommandBuffer> offscreen_context3d_; scoped_refptr<ContextProviderCommandBuffer> offscreen_context3d_;
DISALLOW_COPY_AND_ASSIGN(PepperHelperImpl); DISALLOW_COPY_AND_ASSIGN(PepperHelperImpl);
......
...@@ -419,9 +419,8 @@ void PepperPluginInstanceImpl::NaClDocumentLoader::didFail( ...@@ -419,9 +419,8 @@ void PepperPluginInstanceImpl::NaClDocumentLoader::didFail(
error_.reset(new WebURLError(error)); error_.reset(new WebURLError(error));
} }
PepperPluginInstanceImpl::GamepadImpl::GamepadImpl(PepperHelperImpl* helper) PepperPluginInstanceImpl::GamepadImpl::GamepadImpl()
: Resource(::ppapi::Resource::Untracked()), : Resource(::ppapi::Resource::Untracked()) {
helper_(helper) {
} }
PepperPluginInstanceImpl::GamepadImpl::~GamepadImpl() { PepperPluginInstanceImpl::GamepadImpl::~GamepadImpl() {
...@@ -435,7 +434,7 @@ void PepperPluginInstanceImpl::GamepadImpl::Sample( ...@@ -435,7 +434,7 @@ void PepperPluginInstanceImpl::GamepadImpl::Sample(
PP_Instance instance, PP_Instance instance,
PP_GamepadsSampleData* data) { PP_GamepadsSampleData* data) {
WebKit::WebGamepads webkit_data; WebKit::WebGamepads webkit_data;
helper_->SampleGamepads(&webkit_data); RenderThreadImpl::current()->SampleGamepads(&webkit_data);
ConvertWebKitGamepadData( ConvertWebKitGamepadData(
*reinterpret_cast<const ::ppapi::WebKitGamepads*>(&webkit_data), data); *reinterpret_cast<const ::ppapi::WebKitGamepads*>(&webkit_data), data);
} }
...@@ -474,7 +473,7 @@ PepperPluginInstanceImpl::PepperPluginInstanceImpl( ...@@ -474,7 +473,7 @@ PepperPluginInstanceImpl::PepperPluginInstanceImpl(
checked_for_plugin_input_event_interface_(false), checked_for_plugin_input_event_interface_(false),
checked_for_plugin_messaging_interface_(false), checked_for_plugin_messaging_interface_(false),
checked_for_plugin_pdf_interface_(false), checked_for_plugin_pdf_interface_(false),
gamepad_impl_(new GamepadImpl(helper)), gamepad_impl_(new GamepadImpl()),
plugin_print_interface_(NULL), plugin_print_interface_(NULL),
plugin_graphics_3d_interface_(NULL), plugin_graphics_3d_interface_(NULL),
always_on_top_(false), always_on_top_(false),
......
...@@ -536,14 +536,13 @@ class CONTENT_EXPORT PepperPluginInstanceImpl ...@@ -536,14 +536,13 @@ class CONTENT_EXPORT PepperPluginInstanceImpl
class GamepadImpl : public ::ppapi::thunk::PPB_Gamepad_API, class GamepadImpl : public ::ppapi::thunk::PPB_Gamepad_API,
public ::ppapi::Resource { public ::ppapi::Resource {
public: public:
explicit GamepadImpl(PepperHelperImpl* helper); GamepadImpl();
// Resource implementation. // Resource implementation.
virtual ::ppapi::thunk::PPB_Gamepad_API* AsPPB_Gamepad_API() OVERRIDE; virtual ::ppapi::thunk::PPB_Gamepad_API* AsPPB_Gamepad_API() OVERRIDE;
virtual void Sample(PP_Instance instance, virtual void Sample(PP_Instance instance,
PP_GamepadsSampleData* data) OVERRIDE; PP_GamepadsSampleData* data) OVERRIDE;
private: private:
virtual ~GamepadImpl(); virtual ~GamepadImpl();
PepperHelperImpl* helper_;
}; };
// See the static Create functions above for creating PepperPluginInstanceImpl // See the static Create functions above for creating PepperPluginInstanceImpl
......
...@@ -58,6 +58,7 @@ ...@@ -58,6 +58,7 @@
#include "content/renderer/dom_storage/dom_storage_dispatcher.h" #include "content/renderer/dom_storage/dom_storage_dispatcher.h"
#include "content/renderer/dom_storage/webstoragearea_impl.h" #include "content/renderer/dom_storage/webstoragearea_impl.h"
#include "content/renderer/dom_storage/webstoragenamespace_impl.h" #include "content/renderer/dom_storage/webstoragenamespace_impl.h"
#include "content/renderer/gamepad_shared_memory_reader.h"
#include "content/renderer/gpu/compositor_output_surface.h" #include "content/renderer/gpu/compositor_output_surface.h"
#include "content/renderer/gpu/gpu_benchmarking_extension.h" #include "content/renderer/gpu/gpu_benchmarking_extension.h"
#include "content/renderer/gpu/input_event_filter.h" #include "content/renderer/gpu/input_event_filter.h"
...@@ -1303,4 +1304,10 @@ void RenderThreadImpl::SetFlingCurveParameters( ...@@ -1303,4 +1304,10 @@ void RenderThreadImpl::SetFlingCurveParameters(
} }
void RenderThreadImpl::SampleGamepads(WebKit::WebGamepads* data) {
if (!gamepad_shared_memory_reader_)
gamepad_shared_memory_reader_.reset(new GamepadSharedMemoryReader);
gamepad_shared_memory_reader_->SampleGamepads(*data);
}
} // namespace content } // namespace content
...@@ -28,6 +28,7 @@ class SkBitmap; ...@@ -28,6 +28,7 @@ class SkBitmap;
struct ViewMsg_New_Params; struct ViewMsg_New_Params;
namespace WebKit { namespace WebKit {
class WebGamepads;
class WebGraphicsContext3D; class WebGraphicsContext3D;
class WebMediaStreamCenter; class WebMediaStreamCenter;
class WebMediaStreamCenterClient; class WebMediaStreamCenterClient;
...@@ -77,6 +78,7 @@ class ContextProviderCommandBuffer; ...@@ -77,6 +78,7 @@ class ContextProviderCommandBuffer;
class DBMessageFilter; class DBMessageFilter;
class DevToolsAgentFilter; class DevToolsAgentFilter;
class DomStorageDispatcher; class DomStorageDispatcher;
class GamepadSharedMemoryReader;
class GpuChannelHost; class GpuChannelHost;
class IndexedDBDispatcher; class IndexedDBDispatcher;
class InputEventFilter; class InputEventFilter;
...@@ -345,6 +347,9 @@ class CONTENT_EXPORT RenderThreadImpl : public RenderThread, ...@@ -345,6 +347,9 @@ class CONTENT_EXPORT RenderThreadImpl : public RenderThread,
void SetFlingCurveParameters(const std::vector<float>& new_touchpad, void SetFlingCurveParameters(const std::vector<float>& new_touchpad,
const std::vector<float>& new_touchscreen); const std::vector<float>& new_touchscreen);
// Retrieve current gamepad data.
void SampleGamepads(WebKit::WebGamepads* data);
private: private:
// ChildThread // ChildThread
virtual bool OnControlMessageReceived(const IPC::Message& msg) OVERRIDE; virtual bool OnControlMessageReceived(const IPC::Message& msg) OVERRIDE;
...@@ -486,6 +491,8 @@ class CONTENT_EXPORT RenderThreadImpl : public RenderThread, ...@@ -486,6 +491,8 @@ class CONTENT_EXPORT RenderThreadImpl : public RenderThread,
scoped_ptr<WebRTCIdentityService> webrtc_identity_service_; scoped_ptr<WebRTCIdentityService> webrtc_identity_service_;
scoped_ptr<GamepadSharedMemoryReader> gamepad_shared_memory_reader_;
DISALLOW_COPY_AND_ASSIGN(RenderThreadImpl); DISALLOW_COPY_AND_ASSIGN(RenderThreadImpl);
}; };
......
...@@ -877,12 +877,9 @@ WebBlobRegistry* RendererWebKitPlatformSupportImpl::blobRegistry() { ...@@ -877,12 +877,9 @@ WebBlobRegistry* RendererWebKitPlatformSupportImpl::blobRegistry() {
void RendererWebKitPlatformSupportImpl::sampleGamepads(WebGamepads& gamepads) { void RendererWebKitPlatformSupportImpl::sampleGamepads(WebGamepads& gamepads) {
if (g_test_gamepads == 0) { if (g_test_gamepads == 0) {
if (!gamepad_shared_memory_reader_) RenderThreadImpl::current()->SampleGamepads(&gamepads);
gamepad_shared_memory_reader_.reset(new GamepadSharedMemoryReader);
gamepad_shared_memory_reader_->SampleGamepads(gamepads);
} else { } else {
gamepads = g_test_gamepads.Get(); gamepads = g_test_gamepads.Get();
return;
} }
} }
......
...@@ -35,7 +35,6 @@ class WebGraphicsContext3DProvider; ...@@ -35,7 +35,6 @@ class WebGraphicsContext3DProvider;
namespace content { namespace content {
class DeviceMotionEventPump; class DeviceMotionEventPump;
class DeviceOrientationEventPump; class DeviceOrientationEventPump;
class GamepadSharedMemoryReader;
class QuotaMessageFilter; class QuotaMessageFilter;
class RendererClipboardClient; class RendererClipboardClient;
class ThreadSafeSender; class ThreadSafeSender;
...@@ -202,8 +201,6 @@ class CONTENT_EXPORT RendererWebKitPlatformSupportImpl ...@@ -202,8 +201,6 @@ class CONTENT_EXPORT RendererWebKitPlatformSupportImpl
scoped_ptr<WebKit::WebBlobRegistry> blob_registry_; scoped_ptr<WebKit::WebBlobRegistry> blob_registry_;
scoped_ptr<GamepadSharedMemoryReader> gamepad_shared_memory_reader_;
scoped_ptr<DeviceMotionEventPump> device_motion_event_pump_; scoped_ptr<DeviceMotionEventPump> device_motion_event_pump_;
scoped_ptr<DeviceOrientationEventPump> device_orientation_event_pump_; scoped_ptr<DeviceOrientationEventPump> device_orientation_event_pump_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment