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

Side by Side Diff: content/common/gamepad_hardware_buffer.h

Issue 8570018: Define/update structure and gamepad messages between renderer and browser. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 9 years, 1 month 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
« no previous file with comments | « no previous file | content/common/gamepad_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 #ifndef CONTENT_COMMON_GAMEPAD_HARDWARE_BUFFER_H_
6 #define CONTENT_COMMON_GAMEPAD_HARDWARE_BUFFER_H_
7
8 #include "base/atomicops.h"
9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebGamepads.h"
10
11 namespace gamepad {
12
13 /*
14
15 This structure is stored in shared memory that's shared between the browser
16 which does the hardware polling, and the various consumers of the gamepad
17 state (renderers and NaCl plugins). The performance characteristics are that
18 we want low latency (so would like to avoid explicit communication via IPC
19 between producer and consumer) and relatively large data size.
20
21 Writer and reader operate on the same buffer assuming contention is low, and
22 start_marker and end_marker are used to detect inconsistent reads.
23
24 The writer atomically increments the start_marker counter before starting,
25 then fills in the gamepad data, then increments end_marker to the same value
26 as start_marker. The readers first reads end_marker, then the the data and
27 then start_marker, and if the reader finds that the start and end markers were
28 different, then it must retry as the buffer was updated while being read.
29
30 There is a requirement for memory barriers between the accesses to the markers
31 and the main data to ensure that both the reader and write see a consistent
32 view of those values. In the current implementation, the writer uses an
33 Barrier_AtomicIncrement for the counter, and the reader uses an Acquire_Load.
34
35 */
36
37 struct GamepadHardwareBuffer {
38 base::subtle::Atomic32 start_marker;
39 WebKit::WebGamepads buffer;
40 base::subtle::Atomic32 end_marker;
41 };
42
43 }
44
45 #endif // CONTENT_COMMON_GAMEPAD_HARDWARE_BUFFER_H_
OLDNEW
« no previous file with comments | « no previous file | content/common/gamepad_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698