Add default orientation data fetcher.

Add support for Device Orientation in the default data fetcher.
The default data fetcher is only compiled for platforms where we
don't have proper fetchers available, i.e. platforms other than
Android, Windows or Mac.

BUG=261165

Review URL: https://chromiumcodereview.appspot.com/23542018

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@223518 0039d316-1c4b-4281-b951-d872f2087c98
parent d74eabc8
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
#include "data_fetcher_shared_memory.h" #include "data_fetcher_shared_memory.h"
#include "base/logging.h" #include "base/logging.h"
#include "content/common/device_motion_hardware_buffer.h"
#include "content/common/device_orientation/device_orientation_hardware_buffer.h"
namespace { namespace {
...@@ -20,11 +18,22 @@ static bool SetMotionBuffer(content::DeviceMotionHardwareBuffer* buffer, ...@@ -20,11 +18,22 @@ static bool SetMotionBuffer(content::DeviceMotionHardwareBuffer* buffer,
return true; return true;
} }
static bool SetOrientationBuffer(
content::DeviceOrientationHardwareBuffer* buffer, bool enabled) {
if (!buffer)
return false;
buffer->seqlock.WriteBegin();
buffer->data.allAvailableSensorsAreActive = enabled;
buffer->seqlock.WriteEnd();
return true;
}
} }
namespace content { namespace content {
DataFetcherSharedMemory::DataFetcherSharedMemory() { DataFetcherSharedMemory::DataFetcherSharedMemory()
: motion_buffer_(NULL), orientation_buffer_(NULL) {
} }
DataFetcherSharedMemory::~DataFetcherSharedMemory() { DataFetcherSharedMemory::~DataFetcherSharedMemory() {
...@@ -38,8 +47,9 @@ bool DataFetcherSharedMemory::Start(ConsumerType consumer_type, void* buffer) { ...@@ -38,8 +47,9 @@ bool DataFetcherSharedMemory::Start(ConsumerType consumer_type, void* buffer) {
motion_buffer_ = static_cast<DeviceMotionHardwareBuffer*>(buffer); motion_buffer_ = static_cast<DeviceMotionHardwareBuffer*>(buffer);
return SetMotionBuffer(motion_buffer_, true); return SetMotionBuffer(motion_buffer_, true);
case CONSUMER_TYPE_ORIENTATION: case CONSUMER_TYPE_ORIENTATION:
NOTIMPLEMENTED(); orientation_buffer_ =
break; static_cast<DeviceOrientationHardwareBuffer*>(buffer);
return SetOrientationBuffer(orientation_buffer_, true);
default: default:
NOTREACHED(); NOTREACHED();
} }
...@@ -52,8 +62,7 @@ bool DataFetcherSharedMemory::Stop(ConsumerType consumer_type) { ...@@ -52,8 +62,7 @@ bool DataFetcherSharedMemory::Stop(ConsumerType consumer_type) {
case CONSUMER_TYPE_MOTION: case CONSUMER_TYPE_MOTION:
return SetMotionBuffer(motion_buffer_, false); return SetMotionBuffer(motion_buffer_, false);
case CONSUMER_TYPE_ORIENTATION: case CONSUMER_TYPE_ORIENTATION:
NOTIMPLEMENTED(); return SetOrientationBuffer(orientation_buffer_, false);
break;
default: default:
NOTREACHED(); NOTREACHED();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment