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

Side by Side Diff: content/browser/device_orientation/data_fetcher_shared_memory_default.cc

Issue 23542018: Add default orientation data fetcher. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed unnecessary includes Created 7 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "data_fetcher_shared_memory.h" 5 #include "data_fetcher_shared_memory.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "content/common/device_motion_hardware_buffer.h"
9 #include "content/common/device_orientation/device_orientation_hardware_buffer.h "
10 8
11 namespace { 9 namespace {
12 10
13 static bool SetMotionBuffer(content::DeviceMotionHardwareBuffer* buffer, 11 static bool SetMotionBuffer(content::DeviceMotionHardwareBuffer* buffer,
14 bool enabled) { 12 bool enabled) {
15 if (!buffer) 13 if (!buffer)
16 return false; 14 return false;
17 buffer->seqlock.WriteBegin(); 15 buffer->seqlock.WriteBegin();
18 buffer->data.allAvailableSensorsAreActive = enabled; 16 buffer->data.allAvailableSensorsAreActive = enabled;
19 buffer->seqlock.WriteEnd(); 17 buffer->seqlock.WriteEnd();
20 return true; 18 return true;
21 } 19 }
22 20
21 static bool SetOrientationBuffer(
22 content::DeviceOrientationHardwareBuffer* buffer, bool enabled) {
23 if (!buffer)
24 return false;
25 buffer->seqlock.WriteBegin();
26 buffer->data.allAvailableSensorsAreActive = enabled;
27 buffer->seqlock.WriteEnd();
28 return true;
29 }
30
23 } 31 }
24 32
25 namespace content { 33 namespace content {
26 34
27 DataFetcherSharedMemory::DataFetcherSharedMemory() { 35 DataFetcherSharedMemory::DataFetcherSharedMemory()
36 : motion_buffer_(NULL), orientation_buffer_(NULL) {
28 } 37 }
29 38
30 DataFetcherSharedMemory::~DataFetcherSharedMemory() { 39 DataFetcherSharedMemory::~DataFetcherSharedMemory() {
31 } 40 }
32 41
33 bool DataFetcherSharedMemory::Start(ConsumerType consumer_type, void* buffer) { 42 bool DataFetcherSharedMemory::Start(ConsumerType consumer_type, void* buffer) {
34 DCHECK(buffer); 43 DCHECK(buffer);
35 44
36 switch (consumer_type) { 45 switch (consumer_type) {
37 case CONSUMER_TYPE_MOTION: 46 case CONSUMER_TYPE_MOTION:
38 motion_buffer_ = static_cast<DeviceMotionHardwareBuffer*>(buffer); 47 motion_buffer_ = static_cast<DeviceMotionHardwareBuffer*>(buffer);
39 return SetMotionBuffer(motion_buffer_, true); 48 return SetMotionBuffer(motion_buffer_, true);
40 case CONSUMER_TYPE_ORIENTATION: 49 case CONSUMER_TYPE_ORIENTATION:
41 NOTIMPLEMENTED(); 50 orientation_buffer_ =
42 break; 51 static_cast<DeviceOrientationHardwareBuffer*>(buffer);
52 return SetOrientationBuffer(orientation_buffer_, true);
43 default: 53 default:
44 NOTREACHED(); 54 NOTREACHED();
45 } 55 }
46 return false; 56 return false;
47 } 57 }
48 58
49 bool DataFetcherSharedMemory::Stop(ConsumerType consumer_type) { 59 bool DataFetcherSharedMemory::Stop(ConsumerType consumer_type) {
50 60
51 switch (consumer_type) { 61 switch (consumer_type) {
52 case CONSUMER_TYPE_MOTION: 62 case CONSUMER_TYPE_MOTION:
53 return SetMotionBuffer(motion_buffer_, false); 63 return SetMotionBuffer(motion_buffer_, false);
54 case CONSUMER_TYPE_ORIENTATION: 64 case CONSUMER_TYPE_ORIENTATION:
55 NOTIMPLEMENTED(); 65 return SetOrientationBuffer(orientation_buffer_, false);
56 break;
57 default: 66 default:
58 NOTREACHED(); 67 NOTREACHED();
59 } 68 }
60 return false; 69 return false;
61 } 70 }
62 71
63 } // namespace content 72 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698