Commit bee6a64b authored by ke.he's avatar ke.he Committed by Commit bot

Move gamepad_service out of content/ and into device/

This patch is a subtask of "Decoupling Gamepad from //content".

In this patch the GamepadService, GamepadServiceUnittest, GamepadMonitor and
GamepadSharedBuffer are moved out of content/browser/gamepad or render_host,
and into device/gamepad/.

The file //content/common/gamepad_hardware_buffer.h is removed, we move the
definition of GamepadHardwareBuffer into gamepad_shared_memory.h, and change
its definition by using generic SharedMemorySeqLockBuffer<blink::WebGamepads>.

In the unittest of GamepadProvider, we don't pass a MockSharedMemoryBuffer
(which has no seqlock controls) anymore. GamepadProvider will create a
SharedMemoryBuffer by default in its constructor, so we add the seqlock-read
accordingly in its unittest.

Based on a patch by bajones@chromium.org.

BUG = 612330

Review-Url: https://codereview.chromium.org/2563483006
Cr-Commit-Position: refs/heads/master@{#437716}
parent 2fd35165
...@@ -70,7 +70,6 @@ source_set("browser") { ...@@ -70,7 +70,6 @@ source_set("browser") {
"//device/battery:mojo_bindings", "//device/battery:mojo_bindings",
"//device/bluetooth", "//device/bluetooth",
"//device/gamepad", "//device/gamepad",
"//device/gamepad/public/interfaces",
"//device/generic_sensor", "//device/generic_sensor",
"//device/geolocation", "//device/geolocation",
"//device/geolocation/public/interfaces", "//device/geolocation/public/interfaces",
...@@ -641,10 +640,6 @@ source_set("browser") { ...@@ -641,10 +640,6 @@ source_set("browser") {
"frame_host/render_widget_host_view_child_frame.h", "frame_host/render_widget_host_view_child_frame.h",
"frame_host/render_widget_host_view_guest.cc", "frame_host/render_widget_host_view_guest.cc",
"frame_host/render_widget_host_view_guest.h", "frame_host/render_widget_host_view_guest.h",
"gamepad/gamepad_service.cc",
"gamepad/gamepad_service.h",
"gamepad/gamepad_shared_buffer_impl.cc",
"gamepad/gamepad_shared_buffer_impl.h",
"gpu/browser_gpu_channel_host_factory.cc", "gpu/browser_gpu_channel_host_factory.cc",
"gpu/browser_gpu_channel_host_factory.h", "gpu/browser_gpu_channel_host_factory.h",
"gpu/browser_gpu_memory_buffer_manager.cc", "gpu/browser_gpu_memory_buffer_manager.cc",
...@@ -1003,8 +998,6 @@ source_set("browser") { ...@@ -1003,8 +998,6 @@ source_set("browser") {
"renderer_host/font_utils_linux.h", "renderer_host/font_utils_linux.h",
"renderer_host/frame_metadata_util.cc", "renderer_host/frame_metadata_util.cc",
"renderer_host/frame_metadata_util.h", "renderer_host/frame_metadata_util.h",
"renderer_host/gamepad_monitor.cc",
"renderer_host/gamepad_monitor.h",
"renderer_host/input/gesture_event_queue.cc", "renderer_host/input/gesture_event_queue.cc",
"renderer_host/input/gesture_event_queue.h", "renderer_host/input/gesture_event_queue.h",
"renderer_host/input/input_ack_handler.h", "renderer_host/input/input_ack_handler.h",
......
...@@ -54,7 +54,6 @@ ...@@ -54,7 +54,6 @@
#include "content/browser/dom_storage/dom_storage_area.h" #include "content/browser/dom_storage/dom_storage_area.h"
#include "content/browser/download/download_resource_handler.h" #include "content/browser/download/download_resource_handler.h"
#include "content/browser/download/save_file_manager.h" #include "content/browser/download/save_file_manager.h"
#include "content/browser/gamepad/gamepad_service.h"
#include "content/browser/gpu/browser_gpu_channel_host_factory.h" #include "content/browser/gpu/browser_gpu_channel_host_factory.h"
#include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h"
#include "content/browser/gpu/compositor_util.h" #include "content/browser/gpu/compositor_util.h"
...@@ -90,6 +89,7 @@ ...@@ -90,6 +89,7 @@
#include "content/public/common/main_function_params.h" #include "content/public/common/main_function_params.h"
#include "content/public/common/result_codes.h" #include "content/public/common/result_codes.h"
#include "device/battery/battery_status_service.h" #include "device/battery/battery_status_service.h"
#include "device/gamepad/gamepad_service.h"
#include "device/time_zone_monitor/time_zone_monitor.h" #include "device/time_zone_monitor/time_zone_monitor.h"
#include "media/base/media.h" #include "media/base/media.h"
#include "media/base/user_input_monitor.h" #include "media/base/user_input_monitor.h"
...@@ -1272,7 +1272,7 @@ void BrowserMainLoop::ShutdownThreadsAndCleanUp() { ...@@ -1272,7 +1272,7 @@ void BrowserMainLoop::ShutdownThreadsAndCleanUp() {
// I/O thread and isn't threadsafe. // I/O thread and isn't threadsafe.
{ {
TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:GamepadService"); TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:GamepadService");
GamepadService::GetInstance()->Terminate(); device::GamepadService::GetInstance()->Terminate();
} }
{ {
TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:SensorService"); TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:SensorService");
......
scottmg@chromium.org
bajones@chromium.org
// Copyright (c) 2012 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/browser/gamepad/gamepad_service_test_helpers.h"
#include "content/browser/gamepad/gamepad_service.h"
namespace content {
GamepadServiceTestConstructor::GamepadServiceTestConstructor(
const blink::WebGamepads& test_data) {
data_fetcher_ = new device::MockGamepadDataFetcher(test_data);
gamepad_service_ = new GamepadService(
std::unique_ptr<device::GamepadDataFetcher>(data_fetcher_));
}
GamepadServiceTestConstructor::~GamepadServiceTestConstructor() {
delete gamepad_service_;
}
} // namespace content
// Copyright (c) 2012 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_BROWSER_GAMEPAD_GAMEPAD_SERVICE_TEST_HELPERS_H_
#define CONTENT_BROWSER_GAMEPAD_GAMEPAD_SERVICE_TEST_HELPERS_H_
#include "base/macros.h"
#include "device/gamepad/gamepad_test_helpers.h"
#include "third_party/WebKit/public/platform/WebGamepads.h"
namespace content {
class GamepadService;
// Constructs a GamepadService with a mock data source. This bypasses the
// global singleton for the gamepad service.
class GamepadServiceTestConstructor : public device::GamepadTestHelper {
public:
explicit GamepadServiceTestConstructor(const blink::WebGamepads& test_data);
~GamepadServiceTestConstructor() override;
GamepadService* gamepad_service() { return gamepad_service_; }
device::MockGamepadDataFetcher* data_fetcher() { return data_fetcher_; }
private:
// Owning pointer (can't be a scoped_ptr due to private destructor).
GamepadService* gamepad_service_;
// Pointer owned by the provider (which is owned by the gamepad service).
device::MockGamepadDataFetcher* data_fetcher_;
DISALLOW_COPY_AND_ASSIGN(GamepadServiceTestConstructor);
};
} // namespace content
#endif // CONTENT_BROWSER_GAMEPAD_GAMEPAD_SERVICE_TEST_HELPERS_H_
// Copyright (c) 2016 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_BROWSER_GAMEPAD_GAMEPAD_SHARED_BUFFER_IMPL_H_
#define CONTENT_BROWSER_GAMEPAD_GAMEPAD_SHARED_BUFFER_IMPL_H_
#include "device/gamepad/gamepad_shared_buffer.h"
#include "third_party/WebKit/public/platform/WebGamepads.h"
namespace content {
struct GamepadHardwareBuffer;
class GamepadSharedBufferImpl : public device::GamepadSharedBuffer {
public:
GamepadSharedBufferImpl();
~GamepadSharedBufferImpl() override;
base::SharedMemory* shared_memory() override;
blink::WebGamepads* buffer() override;
GamepadHardwareBuffer* hardware_buffer();
void WriteBegin() override;
void WriteEnd() override;
private:
base::SharedMemory shared_memory_;
DISALLOW_COPY_AND_ASSIGN(GamepadSharedBufferImpl);
};
} // namespace content
#endif // CONTENT_BROWSER_GAMEPAD_GAMEPAD_SHARED_BUFFER_IMPL_H_
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
#include "content/browser/renderer_host/pepper/pepper_gamepad_host.h" #include "content/browser/renderer_host/pepper/pepper_gamepad_host.h"
#include "base/bind.h" #include "base/bind.h"
#include "content/browser/gamepad/gamepad_service.h"
#include "content/public/browser/browser_ppapi_host.h" #include "content/public/browser/browser_ppapi_host.h"
#include "device/gamepad/gamepad_service.h"
#include "ppapi/c/pp_errors.h" #include "ppapi/c/pp_errors.h"
#include "ppapi/host/dispatch_host_message.h" #include "ppapi/host/dispatch_host_message.h"
#include "ppapi/host/host_message_context.h" #include "ppapi/host/host_message_context.h"
...@@ -21,11 +21,11 @@ PepperGamepadHost::PepperGamepadHost(BrowserPpapiHost* host, ...@@ -21,11 +21,11 @@ PepperGamepadHost::PepperGamepadHost(BrowserPpapiHost* host,
PP_Resource resource) PP_Resource resource)
: ResourceHost(host->GetPpapiHost(), instance, resource), : ResourceHost(host->GetPpapiHost(), instance, resource),
browser_ppapi_host_(host), browser_ppapi_host_(host),
gamepad_service_(GamepadService::GetInstance()), gamepad_service_(device::GamepadService::GetInstance()),
is_started_(false), is_started_(false),
weak_factory_(this) {} weak_factory_(this) {}
PepperGamepadHost::PepperGamepadHost(GamepadService* gamepad_service, PepperGamepadHost::PepperGamepadHost(device::GamepadService* gamepad_service,
BrowserPpapiHost* host, BrowserPpapiHost* host,
PP_Instance instance, PP_Instance instance,
PP_Resource resource) PP_Resource resource)
......
...@@ -14,6 +14,10 @@ ...@@ -14,6 +14,10 @@
#include "device/gamepad/gamepad_consumer.h" #include "device/gamepad/gamepad_consumer.h"
#include "ppapi/host/resource_host.h" #include "ppapi/host/resource_host.h"
namespace device {
class GamepadService;
}
namespace ppapi { namespace ppapi {
namespace host { namespace host {
struct ReplyMessageContext; struct ReplyMessageContext;
...@@ -23,7 +27,6 @@ struct ReplyMessageContext; ...@@ -23,7 +27,6 @@ struct ReplyMessageContext;
namespace content { namespace content {
class BrowserPpapiHost; class BrowserPpapiHost;
class GamepadService;
class CONTENT_EXPORT PepperGamepadHost : class CONTENT_EXPORT PepperGamepadHost :
public ppapi::host::ResourceHost, public ppapi::host::ResourceHost,
...@@ -35,7 +38,7 @@ class CONTENT_EXPORT PepperGamepadHost : ...@@ -35,7 +38,7 @@ class CONTENT_EXPORT PepperGamepadHost :
// Allows tests to specify a gamepad service to use rather than the global // Allows tests to specify a gamepad service to use rather than the global
// singleton. The caller owns the gamepad_service pointer. // singleton. The caller owns the gamepad_service pointer.
PepperGamepadHost(GamepadService* gamepad_service, PepperGamepadHost(device::GamepadService* gamepad_service,
BrowserPpapiHost* host, BrowserPpapiHost* host,
PP_Instance instance, PP_Instance instance,
PP_Resource resource); PP_Resource resource);
...@@ -59,7 +62,7 @@ class CONTENT_EXPORT PepperGamepadHost : ...@@ -59,7 +62,7 @@ class CONTENT_EXPORT PepperGamepadHost :
BrowserPpapiHost* browser_ppapi_host_; BrowserPpapiHost* browser_ppapi_host_;
GamepadService* gamepad_service_; device::GamepadService* gamepad_service_;
bool is_started_; bool is_started_;
......
...@@ -13,9 +13,8 @@ ...@@ -13,9 +13,8 @@
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "content/browser/gamepad/gamepad_service_test_helpers.h"
#include "content/browser/renderer_host/pepper/browser_ppapi_host_test.h" #include "content/browser/renderer_host/pepper/browser_ppapi_host_test.h"
#include "content/common/gamepad_hardware_buffer.h" #include "device/gamepad/gamepad_shared_buffer.h"
#include "device/gamepad/gamepad_test_helpers.h" #include "device/gamepad/gamepad_test_helpers.h"
#include "ppapi/c/pp_errors.h" #include "ppapi/c/pp_errors.h"
#include "ppapi/host/host_message_context.h" #include "ppapi/host/host_message_context.h"
...@@ -36,13 +35,15 @@ class PepperGamepadHostTest : public testing::Test, ...@@ -36,13 +35,15 @@ class PepperGamepadHostTest : public testing::Test,
~PepperGamepadHostTest() override {} ~PepperGamepadHostTest() override {}
void ConstructService(const blink::WebGamepads& test_data) { void ConstructService(const blink::WebGamepads& test_data) {
service_.reset(new GamepadServiceTestConstructor(test_data)); service_.reset(new device::GamepadServiceTestConstructor(test_data));
} }
GamepadService* gamepad_service() { return service_->gamepad_service(); } device::GamepadService* gamepad_service() {
return service_->gamepad_service();
}
protected: protected:
std::unique_ptr<GamepadServiceTestConstructor> service_; std::unique_ptr<device::GamepadServiceTestConstructor> service_;
DISALLOW_COPY_AND_ASSIGN(PepperGamepadHostTest); DISALLOW_COPY_AND_ASSIGN(PepperGamepadHostTest);
}; };
...@@ -59,13 +60,13 @@ inline ptrdiff_t AddressDiff(const void* a, const void* b) { ...@@ -59,13 +60,13 @@ inline ptrdiff_t AddressDiff(const void* a, const void* b) {
TEST_F(PepperGamepadHostTest, ValidateHardwareBuffersMatch) { TEST_F(PepperGamepadHostTest, ValidateHardwareBuffersMatch) {
// Hardware buffer. // Hardware buffer.
static_assert(sizeof(ppapi::ContentGamepadHardwareBuffer) == static_assert(sizeof(ppapi::ContentGamepadHardwareBuffer) ==
sizeof(GamepadHardwareBuffer), sizeof(device::GamepadHardwareBuffer),
"gamepad hardware buffers must match"); "gamepad hardware buffers must match");
ppapi::ContentGamepadHardwareBuffer ppapi_buf; ppapi::ContentGamepadHardwareBuffer ppapi_buf;
GamepadHardwareBuffer content_buf; device::GamepadHardwareBuffer content_buf;
EXPECT_EQ(AddressDiff(&content_buf.sequence, &content_buf), EXPECT_EQ(AddressDiff(&content_buf.seqlock, &content_buf),
AddressDiff(&ppapi_buf.sequence, &ppapi_buf)); AddressDiff(&ppapi_buf.sequence, &ppapi_buf));
EXPECT_EQ(AddressDiff(&content_buf.buffer, &content_buf), EXPECT_EQ(AddressDiff(&content_buf.data, &content_buf),
AddressDiff(&ppapi_buf.buffer, &ppapi_buf)); AddressDiff(&ppapi_buf.buffer, &ppapi_buf));
} }
......
...@@ -99,7 +99,6 @@ ...@@ -99,7 +99,6 @@
#include "content/browser/renderer_host/clipboard_message_filter.h" #include "content/browser/renderer_host/clipboard_message_filter.h"
#include "content/browser/renderer_host/database_message_filter.h" #include "content/browser/renderer_host/database_message_filter.h"
#include "content/browser/renderer_host/file_utilities_message_filter.h" #include "content/browser/renderer_host/file_utilities_message_filter.h"
#include "content/browser/renderer_host/gamepad_monitor.h"
#include "content/browser/renderer_host/media/audio_input_renderer_host.h" #include "content/browser/renderer_host/media/audio_input_renderer_host.h"
#include "content/browser/renderer_host/media/audio_renderer_host.h" #include "content/browser/renderer_host/media/audio_renderer_host.h"
#include "content/browser/renderer_host/media/media_stream_dispatcher_host.h" #include "content/browser/renderer_host/media/media_stream_dispatcher_host.h"
...@@ -164,6 +163,7 @@ ...@@ -164,6 +163,7 @@
#include "content/public/common/service_names.mojom.h" #include "content/public/common/service_names.mojom.h"
#include "content/public/common/url_constants.h" #include "content/public/common/url_constants.h"
#include "device/battery/battery_monitor_impl.h" #include "device/battery/battery_monitor_impl.h"
#include "device/gamepad/gamepad_monitor.h"
#include "device/power_monitor/power_monitor_message_broadcaster.h" #include "device/power_monitor/power_monitor_message_broadcaster.h"
#include "device/time_zone_monitor/time_zone_monitor.h" #include "device/time_zone_monitor/time_zone_monitor.h"
#include "gpu/GLES2/gl2extchromium.h" #include "gpu/GLES2/gl2extchromium.h"
...@@ -1284,7 +1284,7 @@ void RenderProcessHostImpl::RegisterMojoInterfaces() { ...@@ -1284,7 +1284,7 @@ void RenderProcessHostImpl::RegisterMojoInterfaces() {
registry->AddInterface(base::Bind(&DeviceOrientationAbsoluteHost::Create)); registry->AddInterface(base::Bind(&DeviceOrientationAbsoluteHost::Create));
#endif // defined(OS_ANDROID) #endif // defined(OS_ANDROID)
registry->AddInterface(base::Bind(&GamepadMonitor::Create)); registry->AddInterface(base::Bind(&device::GamepadMonitor::Create));
registry->AddInterface( registry->AddInterface(
base::Bind(&VideoCaptureHost::Create, base::Bind(&VideoCaptureHost::Create,
......
...@@ -125,7 +125,6 @@ source_set("common") { ...@@ -125,7 +125,6 @@ source_set("common") {
"frame_owner_properties.h", "frame_owner_properties.h",
"frame_replication_state.cc", "frame_replication_state.cc",
"frame_replication_state.h", "frame_replication_state.h",
"gamepad_hardware_buffer.h",
"generic_shared_memory_id_generator.cc", "generic_shared_memory_id_generator.cc",
"generic_shared_memory_id_generator.h", "generic_shared_memory_id_generator.h",
"gin_java_bridge_messages.h", "gin_java_bridge_messages.h",
......
// 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_COMMON_GAMEPAD_HARDWARE_BUFFER_H_
#define CONTENT_COMMON_GAMEPAD_HARDWARE_BUFFER_H_
#include "device/base/synchronization/one_writer_seqlock.h"
#include "third_party/WebKit/public/platform/WebGamepads.h"
namespace content {
/*
This structure is stored in shared memory that's shared between the browser
which does the hardware polling, and the various consumers of the gamepad
state (renderers and NaCl plugins). The performance characteristics are that
we want low latency (so would like to avoid explicit communication via IPC
between producer and consumer) and relatively large data size.
Writer and reader operate on the same buffer assuming contention is low, and
contention is detected by using the associated SeqLock.
*/
struct GamepadHardwareBuffer {
// FIXME: Use the generic SharedMemorySeqLockBuffer<blink::WebGamepads>.
device::OneWriterSeqLock sequence;
blink::WebGamepads buffer;
};
} // namespace content
#endif // CONTENT_COMMON_GAMEPAD_HARDWARE_BUFFER_H_
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/trace_event/trace_event.h" #include "base/trace_event/trace_event.h"
#include "content/common/gamepad_hardware_buffer.h"
#include "content/public/renderer/render_thread.h" #include "content/public/renderer/render_thread.h"
#include "content/renderer/renderer_blink_platform_impl.h" #include "content/renderer/renderer_blink_platform_impl.h"
#include "ipc/ipc_sync_message_filter.h" #include "ipc/ipc_sync_message_filter.h"
...@@ -92,12 +91,12 @@ void GamepadSharedMemoryReader::SampleGamepads(blink::WebGamepads& gamepads) { ...@@ -92,12 +91,12 @@ void GamepadSharedMemoryReader::SampleGamepads(blink::WebGamepads& gamepads) {
int contention_count = -1; int contention_count = -1;
base::subtle::Atomic32 version; base::subtle::Atomic32 version;
do { do {
version = gamepad_hardware_buffer_->sequence.ReadBegin(); version = gamepad_hardware_buffer_->seqlock.ReadBegin();
memcpy(&read_into, &gamepad_hardware_buffer_->buffer, sizeof(read_into)); memcpy(&read_into, &gamepad_hardware_buffer_->data, sizeof(read_into));
++contention_count; ++contention_count;
if (contention_count == kMaximumContentionCount) if (contention_count == kMaximumContentionCount)
break; break;
} while (gamepad_hardware_buffer_->sequence.ReadRetry(version)); } while (gamepad_hardware_buffer_->seqlock.ReadRetry(version));
UMA_HISTOGRAM_COUNTS("Gamepad.ReadContentionCount", contention_count); UMA_HISTOGRAM_COUNTS("Gamepad.ReadContentionCount", contention_count);
if (contention_count >= kMaximumContentionCount) { if (contention_count >= kMaximumContentionCount) {
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/shared_memory.h" #include "base/memory/shared_memory.h"
#include "content/public/renderer/renderer_gamepad_provider.h" #include "content/public/renderer/renderer_gamepad_provider.h"
#include "device/base/synchronization/shared_memory_seqlock_buffer.h"
#include "device/gamepad/public/interfaces/gamepad.mojom.h" #include "device/gamepad/public/interfaces/gamepad.mojom.h"
#include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/system/platform_handle.h" #include "mojo/public/cpp/system/platform_handle.h"
...@@ -17,7 +18,8 @@ ...@@ -17,7 +18,8 @@
namespace content { namespace content {
struct GamepadHardwareBuffer; typedef device::SharedMemorySeqLockBuffer<blink::WebGamepads>
GamepadHardwareBuffer;
class GamepadSharedMemoryReader : public RendererGamepadProvider, class GamepadSharedMemoryReader : public RendererGamepadProvider,
public device::mojom::GamepadObserver { public device::mojom::GamepadObserver {
......
...@@ -1072,9 +1072,6 @@ test("content_unittests") { ...@@ -1072,9 +1072,6 @@ test("content_unittests") {
"../browser/frame_host/render_frame_host_manager_unittest.cc", "../browser/frame_host/render_frame_host_manager_unittest.cc",
"../browser/frame_host/render_widget_host_view_child_frame_unittest.cc", "../browser/frame_host/render_widget_host_view_child_frame_unittest.cc",
"../browser/frame_host/render_widget_host_view_guest_unittest.cc", "../browser/frame_host/render_widget_host_view_guest_unittest.cc",
"../browser/gamepad/gamepad_service_test_helpers.cc",
"../browser/gamepad/gamepad_service_test_helpers.h",
"../browser/gamepad/gamepad_service_unittest.cc",
"../browser/gpu/gpu_data_manager_impl_private_unittest.cc", "../browser/gpu/gpu_data_manager_impl_private_unittest.cc",
"../browser/gpu/shader_disk_cache_unittest.cc", "../browser/gpu/shader_disk_cache_unittest.cc",
"../browser/host_zoom_map_impl_unittest.cc", "../browser/host_zoom_map_impl_unittest.cc",
......
...@@ -62,6 +62,7 @@ test("device_unittests") { ...@@ -62,6 +62,7 @@ test("device_unittests") {
"bluetooth/test/test_bluetooth_local_gatt_service_delegate.cc", "bluetooth/test/test_bluetooth_local_gatt_service_delegate.cc",
"bluetooth/test/test_bluetooth_local_gatt_service_delegate.h", "bluetooth/test/test_bluetooth_local_gatt_service_delegate.h",
"gamepad/gamepad_provider_unittest.cc", "gamepad/gamepad_provider_unittest.cc",
"gamepad/gamepad_service_unittest.cc",
"gamepad/public/interfaces/gamepad_struct_traits_unittest.cc", "gamepad/public/interfaces/gamepad_struct_traits_unittest.cc",
"generic_sensor/platform_sensor_and_provider_unittest_win.cc", "generic_sensor/platform_sensor_and_provider_unittest_win.cc",
"generic_sensor/platform_sensor_provider_unittest.cc", "generic_sensor/platform_sensor_provider_unittest.cc",
......
...@@ -23,6 +23,8 @@ component("gamepad") { ...@@ -23,6 +23,8 @@ component("gamepad") {
"gamepad_data_fetcher.h", "gamepad_data_fetcher.h",
"gamepad_data_fetcher_manager.cc", "gamepad_data_fetcher_manager.cc",
"gamepad_data_fetcher_manager.h", "gamepad_data_fetcher_manager.h",
"gamepad_monitor.cc",
"gamepad_monitor.h",
"gamepad_pad_state_provider.cc", "gamepad_pad_state_provider.cc",
"gamepad_pad_state_provider.h", "gamepad_pad_state_provider.h",
"gamepad_platform_data_fetcher.h", "gamepad_platform_data_fetcher.h",
...@@ -36,6 +38,10 @@ component("gamepad") { ...@@ -36,6 +38,10 @@ component("gamepad") {
"gamepad_platform_data_fetcher_win.h", "gamepad_platform_data_fetcher_win.h",
"gamepad_provider.cc", "gamepad_provider.cc",
"gamepad_provider.h", "gamepad_provider.h",
"gamepad_service.cc",
"gamepad_service.h",
"gamepad_shared_buffer.cc",
"gamepad_shared_buffer.h",
"gamepad_standard_mappings.cc", "gamepad_standard_mappings.cc",
"gamepad_standard_mappings.h", "gamepad_standard_mappings.h",
"gamepad_standard_mappings_linux.cc", "gamepad_standard_mappings_linux.cc",
...@@ -52,6 +58,9 @@ component("gamepad") { ...@@ -52,6 +58,9 @@ component("gamepad") {
deps = [ deps = [
"//base", "//base",
"//base/third_party/dynamic_annotations", "//base/third_party/dynamic_annotations",
"//device/base/synchronization",
"//device/gamepad/public/interfaces",
"//mojo/public/cpp/system",
"//third_party/WebKit/public:blink_headers", "//third_party/WebKit/public:blink_headers",
] ]
......
...@@ -2,26 +2,24 @@ ...@@ -2,26 +2,24 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "content/browser/renderer_host/gamepad_monitor.h" #include "device/gamepad/gamepad_monitor.h"
#include "base/memory/shared_memory.h" #include "base/memory/shared_memory.h"
#include "content/browser/gamepad/gamepad_service.h" #include "device/gamepad/gamepad_service.h"
#include "content/common/gamepad_hardware_buffer.h" #include "device/gamepad/gamepad_shared_buffer.h"
#include "content/public/browser/browser_thread.h"
#include "mojo/public/cpp/bindings/strong_binding.h" #include "mojo/public/cpp/bindings/strong_binding.h"
namespace content { namespace device {
GamepadMonitor::GamepadMonitor() : is_started_(false) {} GamepadMonitor::GamepadMonitor() : is_started_(false) {}
GamepadMonitor::~GamepadMonitor() { GamepadMonitor::~GamepadMonitor() {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (is_started_) if (is_started_)
GamepadService::GetInstance()->RemoveConsumer(this); GamepadService::GetInstance()->RemoveConsumer(this);
} }
// static // static
void GamepadMonitor::Create(device::mojom::GamepadMonitorRequest request) { void GamepadMonitor::Create(mojom::GamepadMonitorRequest request) {
mojo::MakeStrongBinding(base::MakeUnique<GamepadMonitor>(), mojo::MakeStrongBinding(base::MakeUnique<GamepadMonitor>(),
std::move(request)); std::move(request));
} }
...@@ -57,9 +55,8 @@ void GamepadMonitor::GamepadStopPolling( ...@@ -57,9 +55,8 @@ void GamepadMonitor::GamepadStopPolling(
callback.Run(); callback.Run();
} }
void GamepadMonitor::SetObserver( void GamepadMonitor::SetObserver(mojom::GamepadObserverPtr gamepad_observer) {
device::mojom::GamepadObserverPtr gamepad_observer) {
gamepad_observer_ = std::move(gamepad_observer); gamepad_observer_ = std::move(gamepad_observer);
} }
} // namespace content } // namespace device
...@@ -2,23 +2,25 @@ ...@@ -2,23 +2,25 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CONTENT_BROWSER_RENDERER_HOST_GAMEPAD_MONITOR_H_ #ifndef DEVICE_GAMEPAD_GAMEPAD_MONITOR_H_
#define CONTENT_BROWSER_RENDERER_HOST_GAMEPAD_MONITOR_H_ #define DEVICE_GAMEPAD_GAMEPAD_MONITOR_H_
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/macros.h" #include "base/macros.h"
#include "device/gamepad/gamepad_consumer.h" #include "device/gamepad/gamepad_consumer.h"
#include "device/gamepad/gamepad_export.h"
#include "device/gamepad/public/interfaces/gamepad.mojom.h" #include "device/gamepad/public/interfaces/gamepad.mojom.h"
namespace content { namespace device {
class GamepadMonitor : public device::GamepadConsumer, class DEVICE_GAMEPAD_EXPORT GamepadMonitor
public device::mojom::GamepadMonitor { : public GamepadConsumer,
NON_EXPORTED_BASE(public mojom::GamepadMonitor) {
public: public:
GamepadMonitor(); GamepadMonitor();
~GamepadMonitor() override; ~GamepadMonitor() override;
static void Create(device::mojom::GamepadMonitorRequest request); static void Create(mojom::GamepadMonitorRequest request);
// GamepadConsumer implementation. // GamepadConsumer implementation.
void OnGamepadConnected(unsigned index, void OnGamepadConnected(unsigned index,
...@@ -26,19 +28,19 @@ class GamepadMonitor : public device::GamepadConsumer, ...@@ -26,19 +28,19 @@ class GamepadMonitor : public device::GamepadConsumer,
void OnGamepadDisconnected(unsigned index, void OnGamepadDisconnected(unsigned index,
const blink::WebGamepad& gamepad) override; const blink::WebGamepad& gamepad) override;
// device::mojom::GamepadMonitor implementation. // mojom::GamepadMonitor implementation.
void GamepadStartPolling( void GamepadStartPolling(
const GamepadStartPollingCallback& callback) override; const GamepadStartPollingCallback& callback) override;
void GamepadStopPolling(const GamepadStopPollingCallback& callback) override; void GamepadStopPolling(const GamepadStopPollingCallback& callback) override;
void SetObserver(device::mojom::GamepadObserverPtr gamepad_observer) override; void SetObserver(mojom::GamepadObserverPtr gamepad_observer) override;
private: private:
device::mojom::GamepadObserverPtr gamepad_observer_; mojom::GamepadObserverPtr gamepad_observer_;
bool is_started_; bool is_started_;
DISALLOW_COPY_AND_ASSIGN(GamepadMonitor); DISALLOW_COPY_AND_ASSIGN(GamepadMonitor);
}; };
} // namespace content } // namespace device
#endif // CONTENT_BROWSER_RENDERER_HOST_GAMEPAD_MONITOR_H_ #endif // DEVICE_GAMEPAD_GAMEPAD_MONITOR_H_
...@@ -39,20 +39,18 @@ GamepadProvider::ClosureAndThread::ClosureAndThread( ...@@ -39,20 +39,18 @@ GamepadProvider::ClosureAndThread::ClosureAndThread(
GamepadProvider::ClosureAndThread::~ClosureAndThread() {} GamepadProvider::ClosureAndThread::~ClosureAndThread() {}
GamepadProvider::GamepadProvider( GamepadProvider::GamepadProvider(
std::unique_ptr<GamepadSharedBuffer> buffer,
GamepadConnectionChangeClient* connection_change_client) GamepadConnectionChangeClient* connection_change_client)
: is_paused_(true), : is_paused_(true),
have_scheduled_do_poll_(false), have_scheduled_do_poll_(false),
devices_changed_(true), devices_changed_(true),
ever_had_user_gesture_(false), ever_had_user_gesture_(false),
sanitize_(true), sanitize_(true),
gamepad_shared_buffer_(std::move(buffer)), gamepad_shared_buffer_(new GamepadSharedBuffer()),
connection_change_client_(connection_change_client) { connection_change_client_(connection_change_client) {
Initialize(std::unique_ptr<GamepadDataFetcher>()); Initialize(std::unique_ptr<GamepadDataFetcher>());
} }
GamepadProvider::GamepadProvider( GamepadProvider::GamepadProvider(
std::unique_ptr<GamepadSharedBuffer> buffer,
GamepadConnectionChangeClient* connection_change_client, GamepadConnectionChangeClient* connection_change_client,
std::unique_ptr<GamepadDataFetcher> fetcher) std::unique_ptr<GamepadDataFetcher> fetcher)
: is_paused_(true), : is_paused_(true),
...@@ -60,7 +58,7 @@ GamepadProvider::GamepadProvider( ...@@ -60,7 +58,7 @@ GamepadProvider::GamepadProvider(
devices_changed_(true), devices_changed_(true),
ever_had_user_gesture_(false), ever_had_user_gesture_(false),
sanitize_(true), sanitize_(true),
gamepad_shared_buffer_(std::move(buffer)), gamepad_shared_buffer_(new GamepadSharedBuffer()),
connection_change_client_(connection_change_client) { connection_change_client_(connection_change_client) {
Initialize(std::move(fetcher)); Initialize(std::move(fetcher));
} }
...@@ -260,7 +258,7 @@ void GamepadProvider::DoPoll() { ...@@ -260,7 +258,7 @@ void GamepadProvider::DoPoll() {
base::AutoLock lock(shared_memory_lock_); base::AutoLock lock(shared_memory_lock_);
// Acquire the SeqLock. There is only ever one writer to this data. // Acquire the SeqLock. There is only ever one writer to this data.
// See gamepad_hardware_buffer.h. // See gamepad_shared_buffer.h.
gamepad_shared_buffer_->WriteBegin(); gamepad_shared_buffer_->WriteBegin();
buffer->length = 0; buffer->length = 0;
for (unsigned i = 0; i < WebGamepads::itemsLengthCap; ++i) { for (unsigned i = 0; i < WebGamepads::itemsLengthCap; ++i) {
......
...@@ -42,12 +42,10 @@ class DEVICE_GAMEPAD_EXPORT GamepadProvider ...@@ -42,12 +42,10 @@ class DEVICE_GAMEPAD_EXPORT GamepadProvider
public base::SystemMonitor::DevicesChangedObserver { public base::SystemMonitor::DevicesChangedObserver {
public: public:
explicit GamepadProvider( explicit GamepadProvider(
std::unique_ptr<GamepadSharedBuffer> buffer,
GamepadConnectionChangeClient* connection_change_client); GamepadConnectionChangeClient* connection_change_client);
// Manually specifies the data fetcher. Used for testing. // Manually specifies the data fetcher. Used for testing.
explicit GamepadProvider( explicit GamepadProvider(
std::unique_ptr<GamepadSharedBuffer> buffer,
GamepadConnectionChangeClient* connection_change_client, GamepadConnectionChangeClient* connection_change_client,
std::unique_ptr<GamepadDataFetcher> fetcher); std::unique_ptr<GamepadDataFetcher> fetcher);
......
...@@ -45,11 +45,20 @@ class GamepadProviderTest : public testing::Test, public GamepadTestHelper { ...@@ -45,11 +45,20 @@ class GamepadProviderTest : public testing::Test, public GamepadTestHelper {
GamepadProvider* CreateProvider(const WebGamepads& test_data) { GamepadProvider* CreateProvider(const WebGamepads& test_data) {
mock_data_fetcher_ = new MockGamepadDataFetcher(test_data); mock_data_fetcher_ = new MockGamepadDataFetcher(test_data);
provider_.reset(new GamepadProvider( provider_.reset(new GamepadProvider(
std::unique_ptr<GamepadSharedBuffer>(new MockGamepadSharedBuffer()),
nullptr, std::unique_ptr<GamepadDataFetcher>(mock_data_fetcher_))); nullptr, std::unique_ptr<GamepadDataFetcher>(mock_data_fetcher_)));
return provider_.get(); return provider_.get();
} }
void ReadGamepadHardwareBuffer(GamepadHardwareBuffer* buffer,
WebGamepads* output) {
memset(output, 0, sizeof(WebGamepads));
base::subtle::Atomic32 version;
do {
version = buffer->seqlock.ReadBegin();
memcpy(output, &buffer->data, sizeof(WebGamepads));
} while (buffer->seqlock.ReadRetry(version));
}
protected: protected:
GamepadProviderTest() {} GamepadProviderTest() {}
...@@ -70,6 +79,7 @@ class GamepadProviderTest : public testing::Test, public GamepadTestHelper { ...@@ -70,6 +79,7 @@ class GamepadProviderTest : public testing::Test, public GamepadTestHelper {
#endif #endif
TEST_F(GamepadProviderTest, MAYBE_PollingAccess) { TEST_F(GamepadProviderTest, MAYBE_PollingAccess) {
WebGamepads test_data; WebGamepads test_data;
memset(&test_data, 0, sizeof(WebGamepads));
test_data.length = 1; test_data.length = 1;
test_data.items[0].connected = true; test_data.items[0].connected = true;
test_data.items[0].timestamp = 0; test_data.items[0].timestamp = 0;
...@@ -93,18 +103,20 @@ TEST_F(GamepadProviderTest, MAYBE_PollingAccess) { ...@@ -93,18 +103,20 @@ TEST_F(GamepadProviderTest, MAYBE_PollingAccess) {
base::GetCurrentProcessHandle()); base::GetCurrentProcessHandle());
std::unique_ptr<base::SharedMemory> shared_memory( std::unique_ptr<base::SharedMemory> shared_memory(
new base::SharedMemory(handle, true)); new base::SharedMemory(handle, true));
EXPECT_TRUE(shared_memory->Map(sizeof(WebGamepads))); EXPECT_TRUE(shared_memory->Map(sizeof(GamepadHardwareBuffer)));
void* mem = shared_memory->memory();
GamepadHardwareBuffer* buffer =
WebGamepads* output = static_cast<WebGamepads*>(mem); static_cast<GamepadHardwareBuffer*>(shared_memory->memory());
WebGamepads output;
EXPECT_EQ(1u, output->length); ReadGamepadHardwareBuffer(buffer, &output);
EXPECT_EQ(1u, output->items[0].buttonsLength);
EXPECT_EQ(1.f, output->items[0].buttons[0].value); EXPECT_EQ(1u, output.length);
EXPECT_EQ(true, output->items[0].buttons[0].pressed); EXPECT_EQ(1u, output.items[0].buttonsLength);
EXPECT_EQ(2u, output->items[0].axesLength); EXPECT_EQ(1.f, output.items[0].buttons[0].value);
EXPECT_EQ(-1.f, output->items[0].axes[0]); EXPECT_EQ(true, output.items[0].buttons[0].pressed);
EXPECT_EQ(0.5f, output->items[0].axes[1]); EXPECT_EQ(2u, output.items[0].axesLength);
EXPECT_EQ(-1.f, output.items[0].axes[0]);
EXPECT_EQ(0.5f, output.items[0].axes[1]);
} }
// Tests that waiting for a user gesture works properly. // Tests that waiting for a user gesture works properly.
...@@ -191,43 +203,51 @@ TEST_F(GamepadProviderTest, MAYBE_Sanitization) { ...@@ -191,43 +203,51 @@ TEST_F(GamepadProviderTest, MAYBE_Sanitization) {
base::GetCurrentProcessHandle()); base::GetCurrentProcessHandle());
std::unique_ptr<base::SharedMemory> shared_memory( std::unique_ptr<base::SharedMemory> shared_memory(
new base::SharedMemory(handle, true)); new base::SharedMemory(handle, true));
EXPECT_TRUE(shared_memory->Map(sizeof(WebGamepads))); EXPECT_TRUE(shared_memory->Map(sizeof(GamepadHardwareBuffer)));
void* mem = shared_memory->memory();
WebGamepads* output = static_cast<WebGamepads*>(mem); GamepadHardwareBuffer* buffer =
static_cast<GamepadHardwareBuffer*>(shared_memory->memory());
WebGamepads output;
ReadGamepadHardwareBuffer(buffer, &output);
// Initial data should all be zeroed out due to sanitization, even though the // Initial data should all be zeroed out due to sanitization, even though the
// gamepad reported input // gamepad reported input
EXPECT_EQ(1u, output->length); EXPECT_EQ(1u, output.length);
EXPECT_EQ(1u, output->items[0].buttonsLength); EXPECT_EQ(1u, output.items[0].buttonsLength);
EXPECT_EQ(0.f, output->items[0].buttons[0].value); EXPECT_EQ(0.f, output.items[0].buttons[0].value);
EXPECT_FALSE(output->items[0].buttons[0].pressed); EXPECT_FALSE(output.items[0].buttons[0].pressed);
EXPECT_EQ(1u, output->items[0].axesLength); EXPECT_EQ(1u, output.items[0].axesLength);
EXPECT_EQ(0.f, output->items[0].axes[0]); EXPECT_EQ(0.f, output.items[0].axes[0]);
// Zero out the inputs // Zero out the inputs
mock_data_fetcher_->SetTestData(zero_data); mock_data_fetcher_->SetTestData(zero_data);
mock_data_fetcher_->WaitForDataReadAndCallbacksIssued(); mock_data_fetcher_->WaitForDataReadAndCallbacksIssued();
// Read updated data from shared memory
ReadGamepadHardwareBuffer(buffer, &output);
// Should still read zero, which is now an accurate reflection of the data // Should still read zero, which is now an accurate reflection of the data
EXPECT_EQ(1u, output->length); EXPECT_EQ(1u, output.length);
EXPECT_EQ(1u, output->items[0].buttonsLength); EXPECT_EQ(1u, output.items[0].buttonsLength);
EXPECT_EQ(0.f, output->items[0].buttons[0].value); EXPECT_EQ(0.f, output.items[0].buttons[0].value);
EXPECT_FALSE(output->items[0].buttons[0].pressed); EXPECT_FALSE(output.items[0].buttons[0].pressed);
EXPECT_EQ(1u, output->items[0].axesLength); EXPECT_EQ(1u, output.items[0].axesLength);
EXPECT_EQ(0.f, output->items[0].axes[0]); EXPECT_EQ(0.f, output.items[0].axes[0]);
// Re-set the active inputs // Re-set the active inputs
mock_data_fetcher_->SetTestData(active_data); mock_data_fetcher_->SetTestData(active_data);
mock_data_fetcher_->WaitForDataReadAndCallbacksIssued(); mock_data_fetcher_->WaitForDataReadAndCallbacksIssued();
// Read updated data from shared memory
ReadGamepadHardwareBuffer(buffer, &output);
// Should now accurately reflect the reported data. // Should now accurately reflect the reported data.
EXPECT_EQ(1u, output->length); EXPECT_EQ(1u, output.length);
EXPECT_EQ(1u, output->items[0].buttonsLength); EXPECT_EQ(1u, output.items[0].buttonsLength);
EXPECT_EQ(1.f, output->items[0].buttons[0].value); EXPECT_EQ(1.f, output.items[0].buttons[0].value);
EXPECT_TRUE(output->items[0].buttons[0].pressed); EXPECT_TRUE(output.items[0].buttons[0].pressed);
EXPECT_EQ(1u, output->items[0].axesLength); EXPECT_EQ(1u, output.items[0].axesLength);
EXPECT_EQ(-1.f, output->items[0].axes[0]); EXPECT_EQ(-1.f, output.items[0].axes[0]);
} }
} // namespace } // namespace
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "content/browser/gamepad/gamepad_service.h" #include "device/gamepad/gamepad_service.h"
#include <utility> #include <utility>
...@@ -10,35 +10,33 @@ ...@@ -10,35 +10,33 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/memory/singleton.h" #include "base/memory/singleton.h"
#include "content/browser/gamepad/gamepad_shared_buffer_impl.h" #include "base/single_thread_task_runner.h"
#include "content/common/gamepad_hardware_buffer.h" #include "base/threading/thread_task_runner_handle.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
#include "device/gamepad/gamepad_consumer.h" #include "device/gamepad/gamepad_consumer.h"
#include "device/gamepad/gamepad_data_fetcher.h" #include "device/gamepad/gamepad_data_fetcher.h"
#include "device/gamepad/gamepad_provider.h" #include "device/gamepad/gamepad_provider.h"
#include "mojo/public/cpp/system/platform_handle.h" #include "mojo/public/cpp/system/platform_handle.h"
namespace content { namespace device {
namespace { namespace {
GamepadService* g_gamepad_service = 0; GamepadService* g_gamepad_service = 0;
} }
GamepadService::GamepadService() GamepadService::GamepadService()
: num_active_consumers_(0), : main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()),
num_active_consumers_(0),
gesture_callback_pending_(false) { gesture_callback_pending_(false) {
SetInstance(this); SetInstance(this);
} }
GamepadService::GamepadService( GamepadService::GamepadService(
std::unique_ptr<device::GamepadDataFetcher> fetcher) std::unique_ptr<device::GamepadDataFetcher> fetcher)
: provider_(new device::GamepadProvider( : provider_(new device::GamepadProvider(this, std::move(fetcher))),
base::MakeUnique<GamepadSharedBufferImpl>(), this, std::move(fetcher))), main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()),
num_active_consumers_(0), num_active_consumers_(0),
gesture_callback_pending_(false) { gesture_callback_pending_(false) {
SetInstance(this); SetInstance(this);
thread_checker_.DetachFromThread();
} }
GamepadService::~GamepadService() { GamepadService::~GamepadService() {
...@@ -60,11 +58,10 @@ GamepadService* GamepadService::GetInstance() { ...@@ -60,11 +58,10 @@ GamepadService* GamepadService::GetInstance() {
} }
void GamepadService::ConsumerBecameActive(device::GamepadConsumer* consumer) { void GamepadService::ConsumerBecameActive(device::GamepadConsumer* consumer) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(main_thread_task_runner_->BelongsToCurrentThread());
if (!provider_) if (!provider_)
provider_.reset(new device::GamepadProvider( provider_.reset(new device::GamepadProvider(this));
base::MakeUnique<GamepadSharedBufferImpl>(), this));
std::pair<ConsumerSet::iterator, bool> insert_result = std::pair<ConsumerSet::iterator, bool> insert_result =
consumers_.insert(consumer); consumers_.insert(consumer);
...@@ -73,8 +70,7 @@ void GamepadService::ConsumerBecameActive(device::GamepadConsumer* consumer) { ...@@ -73,8 +70,7 @@ void GamepadService::ConsumerBecameActive(device::GamepadConsumer* consumer) {
!gesture_callback_pending_) { !gesture_callback_pending_) {
gesture_callback_pending_ = true; gesture_callback_pending_ = true;
provider_->RegisterForUserGesture( provider_->RegisterForUserGesture(
base::Bind(&GamepadService::OnUserGesture, base::Bind(&GamepadService::OnUserGesture, base::Unretained(this)));
base::Unretained(this)));
} }
if (num_active_consumers_++ == 0) if (num_active_consumers_++ == 0)
...@@ -93,7 +89,7 @@ void GamepadService::ConsumerBecameInactive(device::GamepadConsumer* consumer) { ...@@ -93,7 +89,7 @@ void GamepadService::ConsumerBecameInactive(device::GamepadConsumer* consumer) {
} }
void GamepadService::RemoveConsumer(device::GamepadConsumer* consumer) { void GamepadService::RemoveConsumer(device::GamepadConsumer* consumer) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(main_thread_task_runner_->BelongsToCurrentThread());
ConsumerSet::iterator it = consumers_.find(consumer); ConsumerSet::iterator it = consumers_.find(consumer);
if (it->is_active && --num_active_consumers_ == 0) if (it->is_active && --num_active_consumers_ == 0)
...@@ -103,7 +99,7 @@ void GamepadService::RemoveConsumer(device::GamepadConsumer* consumer) { ...@@ -103,7 +99,7 @@ void GamepadService::RemoveConsumer(device::GamepadConsumer* consumer) {
void GamepadService::RegisterForUserGesture(const base::Closure& closure) { void GamepadService::RegisterForUserGesture(const base::Closure& closure) {
DCHECK(consumers_.size() > 0); DCHECK(consumers_.size() > 0);
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(main_thread_task_runner_->BelongsToCurrentThread());
provider_->RegisterForUserGesture(closure); provider_->RegisterForUserGesture(closure);
} }
...@@ -115,35 +111,33 @@ void GamepadService::OnGamepadConnectionChange(bool connected, ...@@ -115,35 +111,33 @@ void GamepadService::OnGamepadConnectionChange(bool connected,
int index, int index,
const blink::WebGamepad& pad) { const blink::WebGamepad& pad) {
if (connected) { if (connected) {
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, main_thread_task_runner_->PostTask(
base::Bind(&GamepadService::OnGamepadConnected, FROM_HERE, base::Bind(&GamepadService::OnGamepadConnected,
base::Unretained(this), index, pad)); base::Unretained(this), index, pad));
} else { } else {
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, main_thread_task_runner_->PostTask(
base::Bind(&GamepadService::OnGamepadDisconnected, FROM_HERE, base::Bind(&GamepadService::OnGamepadDisconnected,
base::Unretained(this), index, pad)); base::Unretained(this), index, pad));
} }
} }
void GamepadService::OnGamepadConnected( void GamepadService::OnGamepadConnected(int index,
int index, const blink::WebGamepad& pad) {
const blink::WebGamepad& pad) { DCHECK(main_thread_task_runner_->BelongsToCurrentThread());
DCHECK(thread_checker_.CalledOnValidThread());
for (ConsumerSet::iterator it = consumers_.begin(); for (ConsumerSet::iterator it = consumers_.begin(); it != consumers_.end();
it != consumers_.end(); ++it) { ++it) {
if (it->did_observe_user_gesture && it->is_active) if (it->did_observe_user_gesture && it->is_active)
it->consumer->OnGamepadConnected(index, pad); it->consumer->OnGamepadConnected(index, pad);
} }
} }
void GamepadService::OnGamepadDisconnected( void GamepadService::OnGamepadDisconnected(int index,
int index, const blink::WebGamepad& pad) {
const blink::WebGamepad& pad) { DCHECK(main_thread_task_runner_->BelongsToCurrentThread());
DCHECK(thread_checker_.CalledOnValidThread());
for (ConsumerSet::iterator it = consumers_.begin(); for (ConsumerSet::iterator it = consumers_.begin(); it != consumers_.end();
it != consumers_.end(); ++it) { ++it) {
if (it->did_observe_user_gesture && it->is_active) if (it->did_observe_user_gesture && it->is_active)
it->consumer->OnGamepadDisconnected(index, pad); it->consumer->OnGamepadDisconnected(index, pad);
} }
...@@ -151,12 +145,12 @@ void GamepadService::OnGamepadDisconnected( ...@@ -151,12 +145,12 @@ void GamepadService::OnGamepadDisconnected(
base::SharedMemoryHandle GamepadService::GetSharedMemoryHandleForProcess( base::SharedMemoryHandle GamepadService::GetSharedMemoryHandleForProcess(
base::ProcessHandle handle) { base::ProcessHandle handle) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(main_thread_task_runner_->BelongsToCurrentThread());
return provider_->GetSharedMemoryHandleForProcess(handle); return provider_->GetSharedMemoryHandleForProcess(handle);
} }
mojo::ScopedSharedBufferHandle GamepadService::GetSharedBufferHandle() { mojo::ScopedSharedBufferHandle GamepadService::GetSharedBufferHandle() {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(main_thread_task_runner_->BelongsToCurrentThread());
// TODO(heke): Use mojo::SharedBuffer rather than base::SharedMemory in // TODO(heke): Use mojo::SharedBuffer rather than base::SharedMemory in
// GamepadSharedBuffer. See crbug.com/670655 for details. // GamepadSharedBuffer. See crbug.com/670655 for details.
...@@ -166,16 +160,15 @@ mojo::ScopedSharedBufferHandle GamepadService::GetSharedBufferHandle() { ...@@ -166,16 +160,15 @@ mojo::ScopedSharedBufferHandle GamepadService::GetSharedBufferHandle() {
} }
void GamepadService::OnUserGesture() { void GamepadService::OnUserGesture() {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(main_thread_task_runner_->BelongsToCurrentThread());
gesture_callback_pending_ = false; gesture_callback_pending_ = false;
if (!provider_ || if (!provider_ || num_active_consumers_ == 0)
num_active_consumers_ == 0)
return; return;
for (ConsumerSet::iterator it = consumers_.begin(); for (ConsumerSet::iterator it = consumers_.begin(); it != consumers_.end();
it != consumers_.end(); ++it) { ++it) {
if (!it->did_observe_user_gesture && it->is_active) { if (!it->did_observe_user_gesture && it->is_active) {
const ConsumerInfo& info = *it; const ConsumerInfo& info = *it;
info.did_observe_user_gesture = true; info.did_observe_user_gesture = true;
...@@ -194,4 +187,4 @@ void GamepadService::SetSanitizationEnabled(bool sanitize) { ...@@ -194,4 +187,4 @@ void GamepadService::SetSanitizationEnabled(bool sanitize) {
provider_->SetSanitizationEnabled(sanitize); provider_->SetSanitizationEnabled(sanitize);
} }
} // namespace content } // namespace device
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CONTENT_BROWSER_GAMEPAD_GAMEPAD_SERVICE_H_ #ifndef DEVICE_GAMEPAD_GAMEPAD_SERVICE_H_
#define CONTENT_BROWSER_GAMEPAD_GAMEPAD_SERVICE_H_ #define DEVICE_GAMEPAD_GAMEPAD_SERVICE_H_
#include <memory> #include <memory>
#include <set> #include <set>
...@@ -12,29 +12,31 @@ ...@@ -12,29 +12,31 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/shared_memory.h" #include "base/memory/shared_memory.h"
#include "base/memory/singleton.h" #include "base/memory/singleton.h"
#include "base/threading/thread_checker.h" #include "device/gamepad/gamepad_export.h"
#include "content/common/content_export.h"
#include "device/gamepad/gamepad_provider.h" #include "device/gamepad/gamepad_provider.h"
#include "mojo/public/cpp/system/buffer.h" #include "mojo/public/cpp/system/buffer.h"
namespace {
class SingleThreadTaskRunner;
}
namespace blink { namespace blink {
class WebGamepad; class WebGamepad;
} }
namespace content {
class GamepadServiceTestConstructor;
}
namespace device { namespace device {
class GamepadConsumer; class GamepadConsumer;
class GamepadDataFetcher; class GamepadDataFetcher;
class GamepadProvider; class GamepadProvider;
}
namespace content {
class GamepadServiceTestConstructor;
// Owns the GamepadProvider (the background polling thread) and keeps track of // Owns the GamepadProvider (the background polling thread) and keeps track of
// the number of consumers currently using the data (and pausing the provider // the number of consumers currently using the data (and pausing the provider
// when not in use). // when not in use).
class CONTENT_EXPORT GamepadService class DEVICE_GAMEPAD_EXPORT GamepadService
: public device::GamepadConnectionChangeClient { : public device::GamepadConnectionChangeClient {
public: public:
// Returns the GamepadService singleton. // Returns the GamepadService singleton.
...@@ -96,8 +98,7 @@ class CONTENT_EXPORT GamepadService ...@@ -96,8 +98,7 @@ class CONTENT_EXPORT GamepadService
// Constructor for testing. This specifies the data fetcher to use for a // Constructor for testing. This specifies the data fetcher to use for a
// provider, bypassing the default platform one. // provider, bypassing the default platform one.
GamepadService( GamepadService(std::unique_ptr<device::GamepadDataFetcher> fetcher);
std::unique_ptr<device::GamepadDataFetcher> fetcher);
virtual ~GamepadService(); virtual ~GamepadService();
...@@ -126,7 +127,7 @@ class CONTENT_EXPORT GamepadService ...@@ -126,7 +127,7 @@ class CONTENT_EXPORT GamepadService
std::unique_ptr<device::GamepadProvider> provider_; std::unique_ptr<device::GamepadProvider> provider_;
base::ThreadChecker thread_checker_; scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
typedef std::set<ConsumerInfo> ConsumerSet; typedef std::set<ConsumerInfo> ConsumerSet;
ConsumerSet consumers_; ConsumerSet consumers_;
...@@ -140,4 +141,4 @@ class CONTENT_EXPORT GamepadService ...@@ -140,4 +141,4 @@ class CONTENT_EXPORT GamepadService
} // namespace content } // namespace content
#endif // CONTENT_BROWSER_GAMEPAD_GAMEPAD_SERVICE_H_ #endif // DEVICE_GAMEPAD_GAMEPAD_SERVICE_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "content/browser/gamepad/gamepad_service.h" #include "device/gamepad/gamepad_service.h"
#include <string.h> #include <string.h>
...@@ -10,12 +10,11 @@ ...@@ -10,12 +10,11 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "device/gamepad/gamepad_consumer.h" #include "device/gamepad/gamepad_consumer.h"
#include "device/gamepad/gamepad_test_helpers.h" #include "device/gamepad/gamepad_test_helpers.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace content { namespace device {
namespace { namespace {
static const int kNumberOfGamepads = blink::WebGamepads::itemsLengthCap; static const int kNumberOfGamepads = blink::WebGamepads::itemsLengthCap;
...@@ -25,9 +24,7 @@ using blink::WebGamepads; ...@@ -25,9 +24,7 @@ using blink::WebGamepads;
class ConnectionListener : public device::GamepadConsumer { class ConnectionListener : public device::GamepadConsumer {
public: public:
ConnectionListener() { ConnectionListener() { ClearCounters(); }
ClearCounters();
}
void OnGamepadConnected(unsigned index, void OnGamepadConnected(unsigned index,
const blink::WebGamepad& gamepad) override { const blink::WebGamepad& gamepad) override {
...@@ -69,17 +66,16 @@ class GamepadServiceTest : public testing::Test { ...@@ -69,17 +66,16 @@ class GamepadServiceTest : public testing::Test {
void SetUp() override; void SetUp() override;
private: private:
base::MessageLoop message_loop_;
device::MockGamepadDataFetcher* fetcher_; device::MockGamepadDataFetcher* fetcher_;
GamepadService* service_; GamepadService* service_;
std::unique_ptr<ConnectionListener> connection_listener_; std::unique_ptr<ConnectionListener> connection_listener_;
TestBrowserThreadBundle browser_thread_;
WebGamepads test_data_; WebGamepads test_data_;
DISALLOW_COPY_AND_ASSIGN(GamepadServiceTest); DISALLOW_COPY_AND_ASSIGN(GamepadServiceTest);
}; };
GamepadServiceTest::GamepadServiceTest() GamepadServiceTest::GamepadServiceTest() {
: browser_thread_(TestBrowserThreadBundle::IO_MAINLOOP) {
memset(&test_data_, 0, sizeof(test_data_)); memset(&test_data_, 0, sizeof(test_data_));
// Set it so that we have user gesture. // Set it so that we have user gesture.
...@@ -94,8 +90,8 @@ GamepadServiceTest::~GamepadServiceTest() { ...@@ -94,8 +90,8 @@ GamepadServiceTest::~GamepadServiceTest() {
void GamepadServiceTest::SetUp() { void GamepadServiceTest::SetUp() {
fetcher_ = new device::MockGamepadDataFetcher(test_data_); fetcher_ = new device::MockGamepadDataFetcher(test_data_);
service_ = new GamepadService( service_ =
std::unique_ptr<device::GamepadDataFetcher>(fetcher_)); new GamepadService(std::unique_ptr<device::GamepadDataFetcher>(fetcher_));
connection_listener_.reset((new ConnectionListener)); connection_listener_.reset((new ConnectionListener));
service_->SetSanitizationEnabled(false); service_->SetSanitizationEnabled(false);
service_->ConsumerBecameActive(connection_listener_.get()); service_->ConsumerBecameActive(connection_listener_.get());
...@@ -134,4 +130,4 @@ TEST_F(GamepadServiceTest, ConnectionsTest) { ...@@ -134,4 +130,4 @@ TEST_F(GamepadServiceTest, ConnectionsTest) {
EXPECT_EQ(0, GetDisconnectedCounter()); EXPECT_EQ(0, GetDisconnectedCounter());
} }
} // namespace content } // namespace device
...@@ -2,45 +2,41 @@ ...@@ -2,45 +2,41 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "content/browser/gamepad/gamepad_shared_buffer_impl.h" #include "device/gamepad/gamepad_shared_buffer.h"
#include "content/common/gamepad_hardware_buffer.h" namespace device {
namespace content { GamepadSharedBuffer::GamepadSharedBuffer() {
GamepadSharedBufferImpl::GamepadSharedBufferImpl() {
size_t data_size = sizeof(GamepadHardwareBuffer); size_t data_size = sizeof(GamepadHardwareBuffer);
bool res = shared_memory_.CreateAndMapAnonymous(data_size); bool res = shared_memory_.CreateAndMapAnonymous(data_size);
CHECK(res); CHECK(res);
void* mem = shared_memory_.memory(); void* mem = shared_memory_.memory();
DCHECK(mem); DCHECK(mem);
new (mem) GamepadHardwareBuffer(); hardware_buffer_ = new (mem) GamepadHardwareBuffer();
memset(&(hardware_buffer_->data), 0, sizeof(blink::WebGamepads));
} }
GamepadSharedBufferImpl::~GamepadSharedBufferImpl() { GamepadSharedBuffer::~GamepadSharedBuffer() {}
}
base::SharedMemory* GamepadSharedBufferImpl::shared_memory() { base::SharedMemory* GamepadSharedBuffer::shared_memory() {
return &shared_memory_; return &shared_memory_;
} }
blink::WebGamepads* GamepadSharedBufferImpl::buffer() { blink::WebGamepads* GamepadSharedBuffer::buffer() {
return &(hardware_buffer()->buffer); return &(hardware_buffer()->data);
} }
GamepadHardwareBuffer* GamepadSharedBufferImpl::hardware_buffer() { GamepadHardwareBuffer* GamepadSharedBuffer::hardware_buffer() {
void* mem = shared_memory_.memory(); return hardware_buffer_;
DCHECK(mem);
return static_cast<GamepadHardwareBuffer*>(mem);
} }
void GamepadSharedBufferImpl::WriteBegin() { void GamepadSharedBuffer::WriteBegin() {
hardware_buffer()->sequence.WriteBegin(); hardware_buffer_->seqlock.WriteBegin();
} }
void GamepadSharedBufferImpl::WriteEnd() { void GamepadSharedBuffer::WriteEnd() {
hardware_buffer()->sequence.WriteEnd(); hardware_buffer_->seqlock.WriteEnd();
} }
} // namespace content } // namespace device
...@@ -6,20 +6,42 @@ ...@@ -6,20 +6,42 @@
#define DEVICE_GAMEPAD_SHARED_BUFFER_H_ #define DEVICE_GAMEPAD_SHARED_BUFFER_H_
#include "base/memory/shared_memory.h" #include "base/memory/shared_memory.h"
#include "device/base/synchronization/shared_memory_seqlock_buffer.h"
#include "device/gamepad/gamepad_export.h" #include "device/gamepad/gamepad_export.h"
#include "third_party/WebKit/public/platform/WebGamepads.h" #include "third_party/WebKit/public/platform/WebGamepads.h"
namespace device { namespace device {
/*
GamepadHardwareBuffer is stored in shared memory that's shared between the
browser which does the hardware polling, and the various consumers of the
gamepad state (renderers and NaCl plugins). The performance characteristics are
that we want low latency (so would like to avoid explicit communication via IPC
between producer and consumer) and relatively large data size.
Writer and reader operate on the same buffer assuming contention is low, and
contention is detected by using the associated SeqLock.
*/
typedef SharedMemorySeqLockBuffer<blink::WebGamepads> GamepadHardwareBuffer;
class DEVICE_GAMEPAD_EXPORT GamepadSharedBuffer { class DEVICE_GAMEPAD_EXPORT GamepadSharedBuffer {
public: public:
virtual ~GamepadSharedBuffer() {} GamepadSharedBuffer();
~GamepadSharedBuffer();
base::SharedMemory* shared_memory();
blink::WebGamepads* buffer();
GamepadHardwareBuffer* hardware_buffer();
virtual base::SharedMemory* shared_memory() = 0; void WriteBegin();
virtual blink::WebGamepads* buffer() = 0; void WriteEnd();
virtual void WriteBegin() = 0; private:
virtual void WriteEnd() = 0; base::SharedMemory shared_memory_;
GamepadHardwareBuffer* hardware_buffer_;
}; };
} // namespace device } // namespace device
......
...@@ -51,30 +51,19 @@ void MockGamepadDataFetcher::SetTestData(const blink::WebGamepads& new_data) { ...@@ -51,30 +51,19 @@ void MockGamepadDataFetcher::SetTestData(const blink::WebGamepads& new_data) {
test_data_ = new_data; test_data_ = new_data;
} }
MockGamepadSharedBuffer::MockGamepadSharedBuffer() { GamepadTestHelper::GamepadTestHelper() {}
size_t data_size = sizeof(blink::WebGamepads);
bool res = shared_memory_.CreateAndMapAnonymous(data_size);
CHECK(res);
blink::WebGamepads* buf = buffer();
memset(buf, 0, sizeof(blink::WebGamepads));
}
base::SharedMemory* MockGamepadSharedBuffer::shared_memory() { GamepadTestHelper::~GamepadTestHelper() {}
return &shared_memory_;
}
blink::WebGamepads* MockGamepadSharedBuffer::buffer() { GamepadServiceTestConstructor::GamepadServiceTestConstructor(
void* mem = shared_memory_.memory(); const blink::WebGamepads& test_data) {
CHECK(mem); data_fetcher_ = new MockGamepadDataFetcher(test_data);
return static_cast<blink::WebGamepads*>(mem); gamepad_service_ =
new GamepadService(std::unique_ptr<GamepadDataFetcher>(data_fetcher_));
} }
void MockGamepadSharedBuffer::WriteBegin() {} GamepadServiceTestConstructor::~GamepadServiceTestConstructor() {
delete gamepad_service_;
void MockGamepadSharedBuffer::WriteEnd() {} }
GamepadTestHelper::GamepadTestHelper() {}
GamepadTestHelper::~GamepadTestHelper() {}
} // namespace device } // namespace device
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/synchronization/lock.h" #include "base/synchronization/lock.h"
#include "base/synchronization/waitable_event.h" #include "base/synchronization/waitable_event.h"
#include "device/gamepad/gamepad_data_fetcher.h" #include "device/gamepad/gamepad_data_fetcher.h"
#include "device/gamepad/gamepad_service.h"
#include "device/gamepad/gamepad_shared_buffer.h" #include "device/gamepad/gamepad_shared_buffer.h"
#include "third_party/WebKit/public/platform/WebGamepads.h" #include "third_party/WebKit/public/platform/WebGamepads.h"
...@@ -51,22 +52,6 @@ class MockGamepadDataFetcher : public GamepadDataFetcher { ...@@ -51,22 +52,6 @@ class MockGamepadDataFetcher : public GamepadDataFetcher {
DISALLOW_COPY_AND_ASSIGN(MockGamepadDataFetcher); DISALLOW_COPY_AND_ASSIGN(MockGamepadDataFetcher);
}; };
class MockGamepadSharedBuffer : public GamepadSharedBuffer {
public:
MockGamepadSharedBuffer();
base::SharedMemory* shared_memory() override;
blink::WebGamepads* buffer() override;
void WriteBegin() override;
void WriteEnd() override;
private:
base::SharedMemory shared_memory_;
DISALLOW_COPY_AND_ASSIGN(MockGamepadSharedBuffer);
};
// Base class for the other test helpers. This just sets up the system monitor. // Base class for the other test helpers. This just sets up the system monitor.
class GamepadTestHelper { class GamepadTestHelper {
public: public:
...@@ -82,6 +67,26 @@ class GamepadTestHelper { ...@@ -82,6 +67,26 @@ class GamepadTestHelper {
DISALLOW_COPY_AND_ASSIGN(GamepadTestHelper); DISALLOW_COPY_AND_ASSIGN(GamepadTestHelper);
}; };
// Constructs a GamepadService with a mock data source. This bypasses the
// global singleton for the gamepad service.
class GamepadServiceTestConstructor : public GamepadTestHelper {
public:
explicit GamepadServiceTestConstructor(const blink::WebGamepads& test_data);
~GamepadServiceTestConstructor() override;
GamepadService* gamepad_service() { return gamepad_service_; }
MockGamepadDataFetcher* data_fetcher() { return data_fetcher_; }
private:
// Owning pointer (can't be a scoped_ptr due to private destructor).
GamepadService* gamepad_service_;
// Pointer owned by the provider (which is owned by the gamepad service).
MockGamepadDataFetcher* data_fetcher_;
DISALLOW_COPY_AND_ASSIGN(GamepadServiceTestConstructor);
};
} // namespace device } // namespace device
#endif // DEVICE_GAMEPAD_GAMEPAD_TEST_HELPERS_H_ #endif // DEVICE_GAMEPAD_GAMEPAD_TEST_HELPERS_H_
...@@ -57,7 +57,7 @@ interface GamepadObserver { ...@@ -57,7 +57,7 @@ interface GamepadObserver {
// Asks the browser process to start polling, and return a shared memory // Asks the browser process to start polling, and return a shared memory
// handle that will hold the data from the hardware. See // handle that will hold the data from the hardware. See
// gamepad_hardware_buffer.h for a description of how synchronization is // gamepad_shared_buffer.h for a description of how synchronization is
// handled. The number of Starts should match the number of Stops. // handled. The number of Starts should match the number of Stops.
interface GamepadMonitor { interface GamepadMonitor {
[Sync] [Sync]
......
...@@ -109,7 +109,7 @@ struct WebKitGamepads { ...@@ -109,7 +109,7 @@ struct WebKitGamepads {
}; };
// This is the structure store in shared memory. It must match // This is the structure store in shared memory. It must match
// content/common/gamepad_hardware_buffer.h. The GamepadHost unit test has // device::GamepadHardwareBuffer. The GamepadHost unit test has
// some compile asserts to validate this. // some compile asserts to validate this.
struct ContentGamepadHardwareBuffer { struct ContentGamepadHardwareBuffer {
base::subtle::Atomic32 sequence; base::subtle::Atomic32 sequence;
......
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