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

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

Issue 18572014: Implement Android shared memory data fetcher for Device Motion. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@renderer-sync-12June-tryASYNC-2-bis-tryRebase-6
Patch Set: fixed some includes 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
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 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 "base/logging.h" 5 #include "base/logging.h"
6 #include "content/browser/device_orientation/data_fetcher_shared_memory.h"
6 #include "content/browser/device_orientation/device_motion_provider.h" 7 #include "content/browser/device_orientation/device_motion_provider.h"
7 #include "content/common/device_motion_hardware_buffer.h" 8 #include "content/common/device_motion_hardware_buffer.h"
8 9
9 namespace content { 10 namespace content {
10 11
11 DeviceMotionProvider::DeviceMotionProvider() 12 DeviceMotionProvider::DeviceMotionProvider()
12 : is_started_(false) { 13 : is_started_(false) {
13 size_t data_size = sizeof(DeviceMotionHardwareBuffer); 14 size_t data_size = sizeof(DeviceMotionHardwareBuffer);
14 bool res = device_motion_shared_memory_.CreateAndMapAnonymous(data_size); 15 bool res = device_motion_shared_memory_.CreateAndMapAnonymous(data_size);
15 CHECK(res); 16 CHECK(res);
16 DeviceMotionHardwareBuffer* hwbuf = SharedMemoryAsHardwareBuffer(); 17 DeviceMotionHardwareBuffer* hwbuf = SharedMemoryAsHardwareBuffer();
17 memset(hwbuf, 0, sizeof(DeviceMotionHardwareBuffer)); 18 memset(hwbuf, 0, sizeof(DeviceMotionHardwareBuffer));
18 } 19 }
19 20
20 DeviceMotionProvider::~DeviceMotionProvider() { 21 DeviceMotionProvider::~DeviceMotionProvider() {
21 } 22 }
22 23
23 base::SharedMemoryHandle DeviceMotionProvider::GetSharedMemoryHandleForProcess( 24 base::SharedMemoryHandle DeviceMotionProvider::GetSharedMemoryHandleForProcess(
24 base::ProcessHandle process) { 25 base::ProcessHandle process) {
25 base::SharedMemoryHandle renderer_handle; 26 base::SharedMemoryHandle renderer_handle;
26 device_motion_shared_memory_.ShareToProcess(process, &renderer_handle); 27 device_motion_shared_memory_.ShareToProcess(process, &renderer_handle);
27 return renderer_handle; 28 return renderer_handle;
28 } 29 }
29 30
30 void DeviceMotionProvider::StartFetchingDeviceMotionData() { 31 void DeviceMotionProvider::StartFetchingDeviceMotionData() {
31 if (is_started_) 32 if (is_started_)
32 return; 33 return;
33 // FIXME: call data_fetcher_->StartFetchingDeviceMotionData( 34 DataFetcherSharedMemory::instance()->StartFetchingDeviceMotionData(
34 // SharedMemoryAsHardwareBuffer()); 35 SharedMemoryAsHardwareBuffer());
35 is_started_ = true; 36 is_started_ = true;
36 } 37 }
37 38
38 void DeviceMotionProvider::StopFetchingDeviceMotionData() { 39 void DeviceMotionProvider::StopFetchingDeviceMotionData() {
39 // FIXME: call data_fetcher_->StopFetchingDeviceMotionData(); 40 DataFetcherSharedMemory::instance()->StopFetchingDeviceMotionData();
40 is_started_ = false; 41 is_started_ = false;
41 } 42 }
42 43
43 DeviceMotionHardwareBuffer* DeviceMotionProvider:: 44 DeviceMotionHardwareBuffer* DeviceMotionProvider::
44 SharedMemoryAsHardwareBuffer() { 45 SharedMemoryAsHardwareBuffer() {
45 void* mem = device_motion_shared_memory_.memory(); 46 void* mem = device_motion_shared_memory_.memory();
46 CHECK(mem); 47 CHECK(mem);
47 return static_cast<DeviceMotionHardwareBuffer*>(mem); 48 return static_cast<DeviceMotionHardwareBuffer*>(mem);
48 } 49 }
49 50
50 } // namespace content 51 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698