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

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

Issue 14678012: Implement the content/renderer and content/browser part of the Device Motion API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 7 years, 5 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
OLDNEW
(Empty)
1 // Copyright (c) 2013 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 #include "base/logging.h"
6 #include "content/browser/device_orientation/device_motion_provider.h"
7 #include "content/common/device_motion_hardware_buffer.h"
8
9 namespace content {
10
11 DeviceMotionProvider::DeviceMotionProvider()
12 : is_started_(false) {
13 size_t data_size = sizeof(DeviceMotionHardwareBuffer);
14 bool res = device_motion_shared_memory_.CreateAndMapAnonymous(data_size);
15 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
16 DeviceMotionHardwareBuffer* hwbuf = SharedMemoryAsHardwareBuffer();
17 memset(hwbuf, 0, sizeof(DeviceMotionHardwareBuffer));
18 }
19
20 DeviceMotionProvider::~DeviceMotionProvider() {
21 }
22
23 base::SharedMemoryHandle DeviceMotionProvider::GetSharedMemoryHandleForProcess(
24 base::ProcessHandle process) {
25 base::SharedMemoryHandle renderer_handle;
26 device_motion_shared_memory_.ShareToProcess(process, &renderer_handle);
27 return renderer_handle;
28 }
29
30 void DeviceMotionProvider::StartFetchingDeviceMotionData() {
31 if (is_started_)
32 return;
33 // FIXME: call data_fetcher_->StartFetchingDeviceMotionData(
34 // SharedMemoryAsHardwareBuffer());
35 is_started_ = true;
36 }
37
38 void DeviceMotionProvider::StopFetchingDeviceMotionData() {
39 // FIXME: call data_fetcher_->StopFetchingDeviceMotionData();
40 is_started_ = false;
41 }
42
43 DeviceMotionHardwareBuffer* DeviceMotionProvider::
44 SharedMemoryAsHardwareBuffer() {
45 void* mem = device_motion_shared_memory_.memory();
46 CHECK(mem);
47 return static_cast<DeviceMotionHardwareBuffer*>(mem);
48 }
49
50 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698