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