Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1744)

Unified Diff: device/gamepad/gamepad_shared_buffer.cc

Issue 2563483006: Move gamepad_service out of content/ and into device/ (Closed)
Patch Set: addressed Blundell's review comments Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/gamepad/gamepad_shared_buffer.h ('k') | device/gamepad/gamepad_test_helpers.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/gamepad/gamepad_shared_buffer.cc
diff --git a/device/gamepad/gamepad_shared_buffer.cc b/device/gamepad/gamepad_shared_buffer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..66ada779f1ed0e214efa2cd301ecb897860bec92
--- /dev/null
+++ b/device/gamepad/gamepad_shared_buffer.cc
@@ -0,0 +1,42 @@
+// Copyright 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.
+
+#include "device/gamepad/gamepad_shared_buffer.h"
+
+namespace device {
+
+GamepadSharedBuffer::GamepadSharedBuffer() {
+ size_t data_size = sizeof(GamepadHardwareBuffer);
+ bool res = shared_memory_.CreateAndMapAnonymous(data_size);
+ CHECK(res);
+
+ void* mem = shared_memory_.memory();
+ DCHECK(mem);
+ hardware_buffer_ = new (mem) GamepadHardwareBuffer();
+ memset(&(hardware_buffer_->data), 0, sizeof(blink::WebGamepads));
+}
+
+GamepadSharedBuffer::~GamepadSharedBuffer() {}
+
+base::SharedMemory* GamepadSharedBuffer::shared_memory() {
+ return &shared_memory_;
+}
+
+blink::WebGamepads* GamepadSharedBuffer::buffer() {
+ return &(hardware_buffer()->data);
+}
+
+GamepadHardwareBuffer* GamepadSharedBuffer::hardware_buffer() {
+ return hardware_buffer_;
+}
+
+void GamepadSharedBuffer::WriteBegin() {
+ hardware_buffer_->seqlock.WriteBegin();
+}
+
+void GamepadSharedBuffer::WriteEnd() {
+ hardware_buffer_->seqlock.WriteEnd();
+}
+
+} // namespace device
« no previous file with comments | « device/gamepad/gamepad_shared_buffer.h ('k') | device/gamepad/gamepad_test_helpers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698