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

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: Attempts at remaining platform fixes Created 4 years, 5 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
16 void* mem = shared_memory_.memory();
17 DCHECK(mem);
18 // Placement new
scottmg 2016/07/01 22:25:39 This is a weird comment (unnecessary I think).
19 new (mem) GamepadHardwareBuffer();
20
21 //GamepadHardwareBuffer* hwbuf = hardware_buffer();
scottmg 2016/07/01 22:25:39 Remove these lines.
22 //memset(hwbuf, 0, sizeof(GamepadHardwareBuffer));
23 }
24
25 GamepadSharedBufferImpl::~GamepadSharedBufferImpl() {
26
scottmg 2016/07/01 22:25:39 nit; remove empty line
27 }
28
29 base::SharedMemory* GamepadSharedBufferImpl::shared_memory() {
30 return &shared_memory_;
31 }
32
33 blink::WebGamepads* GamepadSharedBufferImpl::buffer() {
34 return &(hardware_buffer()->buffer);
35 }
36
37 GamepadHardwareBuffer* GamepadSharedBufferImpl::hardware_buffer() {
38 void* mem = shared_memory_.memory();
39 DCHECK(mem);
40 return static_cast<GamepadHardwareBuffer*>(mem);
41 }
42
43 void GamepadSharedBufferImpl::WriteBegin() {
44 hardware_buffer()->sequence.WriteBegin();
45 }
46
47 void GamepadSharedBufferImpl::WriteEnd() {
48 hardware_buffer()->sequence.WriteEnd();
49 }
50
51 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698