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

Unified Diff: content/browser/gamepad/gamepad_shared_buffer_impl.cc

Issue 2081583002: Migrating majority of gamepad from content/browser/ to device/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed Android and Unit tests Created 4 years, 6 months 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
Index: content/browser/gamepad/gamepad_shared_buffer_impl.cc
diff --git a/content/browser/gamepad/gamepad_shared_buffer_impl.cc b/content/browser/gamepad/gamepad_shared_buffer_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6b21b04402cdc2d2eda6c3cf3d1a8afad044708c
--- /dev/null
+++ b/content/browser/gamepad/gamepad_shared_buffer_impl.cc
@@ -0,0 +1,45 @@
+// 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 "content/browser/gamepad/gamepad_shared_buffer_impl.h"
+
+#include "content/common/gamepad_hardware_buffer.h"
+
+namespace content {
+
+GamepadSharedBufferImpl::GamepadSharedBufferImpl() {
+ size_t data_size = sizeof(GamepadHardwareBuffer);
+ bool res = shared_memory_.CreateAndMapAnonymous(data_size);
+ CHECK(res);
+ GamepadHardwareBuffer* hwbuf = hardware_buffer();
+ memset(hwbuf, 0, sizeof(GamepadHardwareBuffer));
piman 2016/06/22 22:52:59 nit: use placement new? GamepadHardwareBuffer is n
+}
+
+GamepadSharedBufferImpl::~GamepadSharedBufferImpl() {
+
+}
+
+base::SharedMemory* GamepadSharedBufferImpl::shared_memory() {
+ return &shared_memory_;
+}
+
+blink::WebGamepads* GamepadSharedBufferImpl::buffer() {
+ return &(hardware_buffer()->buffer);
+}
+
+GamepadHardwareBuffer* GamepadSharedBufferImpl::hardware_buffer() {
+ void* mem = shared_memory_.memory();
+ CHECK(mem);
piman 2016/06/22 22:52:59 nit: DCHECK
+ return static_cast<GamepadHardwareBuffer*>(mem);
+}
+
+void GamepadSharedBufferImpl::WriteBegin() {
+ hardware_buffer()->sequence.WriteBegin();
+}
+
+void GamepadSharedBufferImpl::WriteEnd() {
+ hardware_buffer()->sequence.WriteEnd();
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698