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 @@
#include "content/public/common/referrer.h"
#include "content/public/common/webplugininfo.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/p2p/socket_dispatcher.h"
#include "content/renderer/pepper/content_renderer_pepper_host_factory.h"
......@@ -631,12 +630,6 @@ void PepperHelperImpl::DidReceiveMouseEvent(
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 handled = true;
IPC_BEGIN_MESSAGE_MAP(PepperHelperImpl, message)
......
......@@ -31,7 +31,6 @@ struct URLResponseInfoData;
}
namespace WebKit {
class WebGamepads;
class WebURLResponse;
struct WebCompositionUnderline;
struct WebCursorInfo;
......@@ -39,7 +38,6 @@ struct WebCursorInfo;
namespace content {
class ContextProviderCommandBuffer;
class GamepadSharedMemoryReader;
class PepperBroker;
class PluginModule;
class PPB_Broker_Impl;
......@@ -96,9 +94,6 @@ class PepperHelperImpl : public PepperHelper,
// from this call.
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
// module. Returns the renderer host, or NULL if it couldn't be created.
RendererPpapiHost* CreateExternalPluginModule(
......@@ -200,8 +195,6 @@ class PepperHelperImpl : public PepperHelper,
// when it is destroyed via InstanceDeleted().
PepperPluginInstanceImpl* last_mouse_event_target_;
scoped_ptr<GamepadSharedMemoryReader> gamepad_shared_memory_reader_;
scoped_refptr<ContextProviderCommandBuffer> offscreen_context3d_;
DISALLOW_COPY_AND_ASSIGN(PepperHelperImpl);
......
......@@ -419,9 +419,8 @@ void PepperPluginInstanceImpl::NaClDocumentLoader::didFail(
error_.reset(new WebURLError(error));
}
PepperPluginInstanceImpl::GamepadImpl::GamepadImpl(PepperHelperImpl* helper)
: Resource(::ppapi::Resource::Untracked()),
helper_(helper) {
PepperPluginInstanceImpl::GamepadImpl::GamepadImpl()
: Resource(::ppapi::Resource::Untracked()) {
}
PepperPluginInstanceImpl::GamepadImpl::~GamepadImpl() {
......@@ -435,7 +434,7 @@ void PepperPluginInstanceImpl::GamepadImpl::Sample(
PP_Instance instance,
PP_GamepadsSampleData* data) {
WebKit::WebGamepads webkit_data;
helper_->SampleGamepads(&webkit_data);
RenderThreadImpl::current()->SampleGamepads(&webkit_data);
ConvertWebKitGamepadData(
*reinterpret_cast<const ::ppapi::WebKitGamepads*>(&webkit_data), data);
}
......@@ -474,7 +473,7 @@ PepperPluginInstanceImpl::PepperPluginInstanceImpl(
checked_for_plugin_input_event_interface_(false),
checked_for_plugin_messaging_interface_(false),
checked_for_plugin_pdf_interface_(false),
gamepad_impl_(new GamepadImpl(helper)),
gamepad_impl_(new GamepadImpl()),
plugin_print_interface_(NULL),
plugin_graphics_3d_interface_(NULL),
always_on_top_(false),
......
......@@ -536,14 +536,13 @@ class CONTENT_EXPORT PepperPluginInstanceImpl
class GamepadImpl : public ::ppapi::thunk::PPB_Gamepad_API,
public ::ppapi::Resource {
public:
explicit GamepadImpl(PepperHelperImpl* helper);
GamepadImpl();
// Resource implementation.
virtual ::ppapi::thunk::PPB_Gamepad_API* AsPPB_Gamepad_API() OVERRIDE;
virtual void Sample(PP_Instance instance,
PP_GamepadsSampleData* data) OVERRIDE;
private:
virtual ~GamepadImpl();
PepperHelperImpl* helper_;
};
// See the static Create functions above for creating PepperPluginInstanceImpl
......
......@@ -58,6 +58,7 @@
#include "content/renderer/dom_storage/dom_storage_dispatcher.h"
#include "content/renderer/dom_storage/webstoragearea_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/gpu_benchmarking_extension.h"
#include "content/renderer/gpu/input_event_filter.h"
......@@ -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
......@@ -28,6 +28,7 @@ class SkBitmap;
struct ViewMsg_New_Params;
namespace WebKit {
class WebGamepads;
class WebGraphicsContext3D;
class WebMediaStreamCenter;
class WebMediaStreamCenterClient;
......@@ -77,6 +78,7 @@ class ContextProviderCommandBuffer;
class DBMessageFilter;
class DevToolsAgentFilter;
class DomStorageDispatcher;
class GamepadSharedMemoryReader;
class GpuChannelHost;
class IndexedDBDispatcher;
class InputEventFilter;
......@@ -345,6 +347,9 @@ class CONTENT_EXPORT RenderThreadImpl : public RenderThread,
void SetFlingCurveParameters(const std::vector<float>& new_touchpad,
const std::vector<float>& new_touchscreen);
// Retrieve current gamepad data.
void SampleGamepads(WebKit::WebGamepads* data);
private:
// ChildThread
virtual bool OnControlMessageReceived(const IPC::Message& msg) OVERRIDE;
......@@ -486,6 +491,8 @@ class CONTENT_EXPORT RenderThreadImpl : public RenderThread,
scoped_ptr<WebRTCIdentityService> webrtc_identity_service_;
scoped_ptr<GamepadSharedMemoryReader> gamepad_shared_memory_reader_;
DISALLOW_COPY_AND_ASSIGN(RenderThreadImpl);
};
......
......@@ -877,12 +877,9 @@ WebBlobRegistry* RendererWebKitPlatformSupportImpl::blobRegistry() {
void RendererWebKitPlatformSupportImpl::sampleGamepads(WebGamepads& gamepads) {
if (g_test_gamepads == 0) {
if (!gamepad_shared_memory_reader_)
gamepad_shared_memory_reader_.reset(new GamepadSharedMemoryReader);
gamepad_shared_memory_reader_->SampleGamepads(gamepads);
RenderThreadImpl::current()->SampleGamepads(&gamepads);
} else {
gamepads = g_test_gamepads.Get();
return;
}
}
......
......@@ -35,7 +35,6 @@ class WebGraphicsContext3DProvider;
namespace content {
class DeviceMotionEventPump;
class DeviceOrientationEventPump;
class GamepadSharedMemoryReader;
class QuotaMessageFilter;
class RendererClipboardClient;
class ThreadSafeSender;
......@@ -202,8 +201,6 @@ class CONTENT_EXPORT RendererWebKitPlatformSupportImpl
scoped_ptr<WebKit::WebBlobRegistry> blob_registry_;
scoped_ptr<GamepadSharedMemoryReader> gamepad_shared_memory_reader_;
scoped_ptr<DeviceMotionEventPump> device_motion_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