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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/browser/gamepad/gamepad_shared_buffer_impl.h"
6
7 #include "content/common/gamepad_hardware_buffer.h"
8
9 namespace content {
10
11 GamepadSharedBufferImpl::GamepadSharedBufferImpl() {
12 size_t data_size = sizeof(GamepadHardwareBuffer);
13 bool res = shared_memory_.CreateAndMapAnonymous(data_size);
14 CHECK(res);
15 GamepadHardwareBuffer* hwbuf = hardware_buffer();
16 memset(hwbuf, 0, sizeof(GamepadHardwareBuffer));
piman 2016/06/22 22:52:59 nit: use placement new? GamepadHardwareBuffer is n
17 }
18
19 GamepadSharedBufferImpl::~GamepadSharedBufferImpl() {
20
21 }
22
23 base::SharedMemory* GamepadSharedBufferImpl::shared_memory() {
24 return &shared_memory_;
25 }
26
27 blink::WebGamepads* GamepadSharedBufferImpl::buffer() {
28 return &(hardware_buffer()->buffer);
29 }
30
31 GamepadHardwareBuffer* GamepadSharedBufferImpl::hardware_buffer() {
32 void* mem = shared_memory_.memory();
33 CHECK(mem);
piman 2016/06/22 22:52:59 nit: DCHECK
34 return static_cast<GamepadHardwareBuffer*>(mem);
35 }
36
37 void GamepadSharedBufferImpl::WriteBegin() {
38 hardware_buffer()->sequence.WriteBegin();
39 }
40
41 void GamepadSharedBufferImpl::WriteEnd() {
42 hardware_buffer()->sequence.WriteEnd();
43 }
44
45 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698