Chromium Code Reviews| Index: content/browser/device_orientation/device_motion_provider.cc |
| diff --git a/content/browser/device_orientation/device_motion_provider.cc b/content/browser/device_orientation/device_motion_provider.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..218ee58d8ac30a9e3299f12e62acc49a0e9153fa |
| --- /dev/null |
| +++ b/content/browser/device_orientation/device_motion_provider.cc |
| @@ -0,0 +1,50 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "base/logging.h" |
| +#include "content/browser/device_orientation/device_motion_provider.h" |
| +#include "content/common/device_motion_hardware_buffer.h" |
| + |
| +namespace content { |
| + |
| +DeviceMotionProvider::DeviceMotionProvider() |
| + : is_started_(false) { |
| + size_t data_size = sizeof(DeviceMotionHardwareBuffer); |
| + bool res = device_motion_shared_memory_.CreateAndMapAnonymous(data_size); |
| + CHECK(res); |
|
palmer
2013/07/10 18:23:48
Should the browser really crash in this case? I su
timvolodine
2013/07/10 21:17:50
hmm, yes it will die in this case. I've added a co
|
| + DeviceMotionHardwareBuffer* hwbuf = SharedMemoryAsHardwareBuffer(); |
| + memset(hwbuf, 0, sizeof(DeviceMotionHardwareBuffer)); |
| +} |
| + |
| +DeviceMotionProvider::~DeviceMotionProvider() { |
| +} |
| + |
| +base::SharedMemoryHandle DeviceMotionProvider::GetSharedMemoryHandleForProcess( |
| + base::ProcessHandle process) { |
| + base::SharedMemoryHandle renderer_handle; |
| + device_motion_shared_memory_.ShareToProcess(process, &renderer_handle); |
| + return renderer_handle; |
| +} |
| + |
| +void DeviceMotionProvider::StartFetchingDeviceMotionData() { |
| + if (is_started_) |
| + return; |
| + // FIXME: call data_fetcher_->StartFetchingDeviceMotionData( |
| + // SharedMemoryAsHardwareBuffer()); |
| + is_started_ = true; |
| +} |
| + |
| +void DeviceMotionProvider::StopFetchingDeviceMotionData() { |
| + // FIXME: call data_fetcher_->StopFetchingDeviceMotionData(); |
| + is_started_ = false; |
| +} |
| + |
| +DeviceMotionHardwareBuffer* DeviceMotionProvider:: |
| + SharedMemoryAsHardwareBuffer() { |
| + void* mem = device_motion_shared_memory_.memory(); |
| + CHECK(mem); |
| + return static_cast<DeviceMotionHardwareBuffer*>(mem); |
| +} |
| + |
| +} // namespace content |