OLD | NEW |
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 | 8 |
9 namespace content { | 9 namespace content { |
10 | 10 |
11 DataFetcherSharedMemory::~DataFetcherSharedMemory() { | 11 DataFetcherSharedMemory::~DataFetcherSharedMemory() { |
12 StopFetchingDeviceMotionData(); | 12 if (started_) |
| 13 StopFetchingDeviceMotionData(); |
13 } | 14 } |
14 | 15 |
15 bool DataFetcherSharedMemory::NeedsPolling() { | 16 bool DataFetcherSharedMemory::NeedsPolling() { |
16 return false; | 17 return false; |
17 } | 18 } |
18 | 19 |
19 bool DataFetcherSharedMemory::FetchDeviceMotionDataIntoBuffer() { | 20 bool DataFetcherSharedMemory::FetchDeviceMotionDataIntoBuffer() { |
20 NOTREACHED(); | 21 NOTREACHED(); |
21 return false; | 22 return false; |
22 } | 23 } |
23 | 24 |
24 bool DataFetcherSharedMemory::StartFetchingDeviceMotionData( | 25 bool DataFetcherSharedMemory::StartFetchingDeviceMotionData( |
25 DeviceMotionHardwareBuffer* buffer) { | 26 DeviceMotionHardwareBuffer* buffer) { |
26 DCHECK(buffer); | 27 DCHECK(buffer); |
| 28 device_motion_buffer_ = buffer; |
27 device_motion_buffer_->seqlock.WriteBegin(); | 29 device_motion_buffer_->seqlock.WriteBegin(); |
28 device_motion_buffer_->data.allAvailableSensorsAreActive = true; | 30 device_motion_buffer_->data.allAvailableSensorsAreActive = true; |
29 device_motion_buffer_->seqlock.WriteEnd(); | 31 device_motion_buffer_->seqlock.WriteEnd(); |
| 32 started_ = true; |
30 return true; | 33 return true; |
31 } | 34 } |
32 | 35 |
33 void DataFetcherSharedMemory::StopFetchingDeviceMotionData() { | 36 void DataFetcherSharedMemory::StopFetchingDeviceMotionData() { |
34 device_motion_buffer_->seqlock.WriteBegin(); | 37 device_motion_buffer_->seqlock.WriteBegin(); |
35 device_motion_buffer_->data.allAvailableSensorsAreActive = false; | 38 device_motion_buffer_->data.allAvailableSensorsAreActive = false; |
36 device_motion_buffer_->seqlock.WriteEnd(); | 39 device_motion_buffer_->seqlock.WriteEnd(); |
| 40 started_ = false; |
37 } | 41 } |
38 | 42 |
39 } // namespace content | 43 } // namespace content |
OLD | NEW |