Android: remove device_data.h from browser/device_orientation/

After refactoring there is no need for a separate DeviceData class
anymore, so removing it.

BUG=261165

Review URL: https://codereview.chromium.org/59403004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@244239 0039d316-1c4b-4281-b951-d872f2087c98
parent fe9521dd
...@@ -135,7 +135,7 @@ void DataFetcherImplAndroid::GotRotationRate( ...@@ -135,7 +135,7 @@ void DataFetcherImplAndroid::GotRotationRate(
} }
} }
bool DataFetcherImplAndroid::Start(DeviceData::Type event_type) { bool DataFetcherImplAndroid::Start(EventType event_type) {
DCHECK(!device_orientation_.is_null()); DCHECK(!device_orientation_.is_null());
return Java_DeviceMotionAndOrientation_start( return Java_DeviceMotionAndOrientation_start(
AttachCurrentThread(), device_orientation_.obj(), AttachCurrentThread(), device_orientation_.obj(),
...@@ -143,7 +143,7 @@ bool DataFetcherImplAndroid::Start(DeviceData::Type event_type) { ...@@ -143,7 +143,7 @@ bool DataFetcherImplAndroid::Start(DeviceData::Type event_type) {
kInertialSensorIntervalMillis); kInertialSensorIntervalMillis);
} }
void DataFetcherImplAndroid::Stop(DeviceData::Type event_type) { void DataFetcherImplAndroid::Stop(EventType event_type) {
DCHECK(!device_orientation_.is_null()); DCHECK(!device_orientation_.is_null());
Java_DeviceMotionAndOrientation_stop( Java_DeviceMotionAndOrientation_stop(
AttachCurrentThread(), device_orientation_.obj(), AttachCurrentThread(), device_orientation_.obj(),
...@@ -169,7 +169,7 @@ bool DataFetcherImplAndroid::StartFetchingDeviceMotionData( ...@@ -169,7 +169,7 @@ bool DataFetcherImplAndroid::StartFetchingDeviceMotionData(
device_motion_buffer_ = buffer; device_motion_buffer_ = buffer;
ClearInternalMotionBuffers(); ClearInternalMotionBuffers();
} }
bool success = Start(DeviceData::kTypeMotion); bool success = Start(kTypeMotion);
// If no motion data can ever be provided, the number of active device motion // If no motion data can ever be provided, the number of active device motion
// sensors will be zero. In that case flag the shared memory buffer // sensors will be zero. In that case flag the shared memory buffer
...@@ -183,7 +183,7 @@ bool DataFetcherImplAndroid::StartFetchingDeviceMotionData( ...@@ -183,7 +183,7 @@ bool DataFetcherImplAndroid::StartFetchingDeviceMotionData(
} }
void DataFetcherImplAndroid::StopFetchingDeviceMotionData() { void DataFetcherImplAndroid::StopFetchingDeviceMotionData() {
Stop(DeviceData::kTypeMotion); Stop(kTypeMotion);
{ {
base::AutoLock autolock(motion_buffer_lock_); base::AutoLock autolock(motion_buffer_lock_);
if (device_motion_buffer_) { if (device_motion_buffer_) {
...@@ -245,7 +245,7 @@ bool DataFetcherImplAndroid::StartFetchingDeviceOrientationData( ...@@ -245,7 +245,7 @@ bool DataFetcherImplAndroid::StartFetchingDeviceOrientationData(
base::AutoLock autolock(orientation_buffer_lock_); base::AutoLock autolock(orientation_buffer_lock_);
device_orientation_buffer_ = buffer; device_orientation_buffer_ = buffer;
} }
bool success = Start(DeviceData::kTypeOrientation); bool success = Start(kTypeOrientation);
{ {
base::AutoLock autolock(orientation_buffer_lock_); base::AutoLock autolock(orientation_buffer_lock_);
...@@ -261,7 +261,7 @@ bool DataFetcherImplAndroid::StartFetchingDeviceOrientationData( ...@@ -261,7 +261,7 @@ bool DataFetcherImplAndroid::StartFetchingDeviceOrientationData(
} }
void DataFetcherImplAndroid::StopFetchingDeviceOrientationData() { void DataFetcherImplAndroid::StopFetchingDeviceOrientationData() {
Stop(DeviceData::kTypeOrientation); Stop(kTypeOrientation);
{ {
base::AutoLock autolock(orientation_buffer_lock_); base::AutoLock autolock(orientation_buffer_lock_);
if (device_orientation_buffer_) { if (device_orientation_buffer_) {
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "base/android/scoped_java_ref.h" #include "base/android/scoped_java_ref.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/synchronization/lock.h" #include "base/synchronization/lock.h"
#include "content/browser/device_orientation/device_data.h"
#include "content/common/content_export.h" #include "content/common/content_export.h"
#include "content/common/device_orientation/device_motion_hardware_buffer.h" #include "content/common/device_orientation/device_motion_hardware_buffer.h"
#include "content/common/device_orientation/device_orientation_hardware_buffer.h" #include "content/common/device_orientation/device_orientation_hardware_buffer.h"
...@@ -43,9 +42,6 @@ class CONTENT_EXPORT DataFetcherImplAndroid { ...@@ -43,9 +42,6 @@ class CONTENT_EXPORT DataFetcherImplAndroid {
void GotRotationRate(JNIEnv*, jobject, void GotRotationRate(JNIEnv*, jobject,
double alpha, double beta, double gamma); double alpha, double beta, double gamma);
virtual bool Start(DeviceData::Type event_type);
virtual void Stop(DeviceData::Type event_type);
// Shared memory related methods. // Shared memory related methods.
bool StartFetchingDeviceMotionData(DeviceMotionHardwareBuffer* buffer); bool StartFetchingDeviceMotionData(DeviceMotionHardwareBuffer* buffer);
void StopFetchingDeviceMotionData(); void StopFetchingDeviceMotionData();
...@@ -55,20 +51,24 @@ class CONTENT_EXPORT DataFetcherImplAndroid { ...@@ -55,20 +51,24 @@ class CONTENT_EXPORT DataFetcherImplAndroid {
void StopFetchingDeviceOrientationData(); void StopFetchingDeviceOrientationData();
protected: protected:
enum EventType {
// These constants should match DEVICE_ORIENTATION and DEVICE_MOTION
// constants in content/public/android/java/src/org/chromium/content/
// browser/DeviceMotionAndOrientation.java
kTypeOrientation = 0,
kTypeMotion = 1
};
DataFetcherImplAndroid(); DataFetcherImplAndroid();
virtual ~DataFetcherImplAndroid(); virtual ~DataFetcherImplAndroid();
virtual bool Start(EventType event_type);
virtual void Stop(EventType event_type);
virtual int GetNumberActiveDeviceMotionSensors(); virtual int GetNumberActiveDeviceMotionSensors();
private: private:
friend struct DefaultSingletonTraits<DataFetcherImplAndroid>; friend struct DefaultSingletonTraits<DataFetcherImplAndroid>;
void CheckMotionBufferReadyToRead();
void SetMotionBufferReadyStatus(bool ready);
void ClearInternalMotionBuffers();
void SetOrientationBufferReadyStatus(bool ready);
enum { enum {
RECEIVED_MOTION_DATA_ACCELERATION = 0, RECEIVED_MOTION_DATA_ACCELERATION = 0,
RECEIVED_MOTION_DATA_ACCELERATION_INCL_GRAVITY = 1, RECEIVED_MOTION_DATA_ACCELERATION_INCL_GRAVITY = 1,
...@@ -76,6 +76,12 @@ class CONTENT_EXPORT DataFetcherImplAndroid { ...@@ -76,6 +76,12 @@ class CONTENT_EXPORT DataFetcherImplAndroid {
RECEIVED_MOTION_DATA_MAX = 3, RECEIVED_MOTION_DATA_MAX = 3,
}; };
void CheckMotionBufferReadyToRead();
void SetMotionBufferReadyStatus(bool ready);
void ClearInternalMotionBuffers();
void SetOrientationBufferReadyStatus(bool ready);
// The Java provider of orientation info. // The Java provider of orientation info.
base::android::ScopedJavaGlobalRef<jobject> device_orientation_; base::android::ScopedJavaGlobalRef<jobject> device_orientation_;
int number_active_device_motion_sensors_; int number_active_device_motion_sensors_;
......
...@@ -19,13 +19,6 @@ class FakeDataFetcherImplAndroid : public DataFetcherImplAndroid { ...@@ -19,13 +19,6 @@ class FakeDataFetcherImplAndroid : public DataFetcherImplAndroid {
FakeDataFetcherImplAndroid() { } FakeDataFetcherImplAndroid() { }
virtual ~FakeDataFetcherImplAndroid() { } virtual ~FakeDataFetcherImplAndroid() { }
virtual bool Start(DeviceData::Type event_type) OVERRIDE {
return true;
}
virtual void Stop(DeviceData::Type event_type) OVERRIDE {
}
virtual int GetNumberActiveDeviceMotionSensors() OVERRIDE { virtual int GetNumberActiveDeviceMotionSensors() OVERRIDE {
return number_active_sensors_; return number_active_sensors_;
} }
...@@ -34,6 +27,14 @@ class FakeDataFetcherImplAndroid : public DataFetcherImplAndroid { ...@@ -34,6 +27,14 @@ class FakeDataFetcherImplAndroid : public DataFetcherImplAndroid {
number_active_sensors_ = number_active_sensors; number_active_sensors_ = number_active_sensors;
} }
protected:
virtual bool Start(EventType event_type) OVERRIDE {
return true;
}
virtual void Stop(EventType event_type) OVERRIDE {
}
private: private:
int number_active_sensors_; int number_active_sensors_;
}; };
......
// Copyright (c) 2012 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.
#ifndef CONTENT_BROWSER_DEVICE_ORIENTATION_DEVICE_DATA_H_
#define CONTENT_BROWSER_DEVICE_ORIENTATION_DEVICE_DATA_H_
#include "base/memory/ref_counted.h"
#include "content/common/content_export.h"
namespace IPC {
class Message;
}
namespace content {
class CONTENT_EXPORT DeviceData :
public base::RefCountedThreadSafe<DeviceData> {
public:
// TODO(timvolodine): move the DeviceData::Type enum to the service class
// once it is implemented.
enum Type {
kTypeOrientation = 0,
kTypeMotion = 1,
kTypeTest = 100
};
virtual IPC::Message* CreateIPCMessage(int render_view_id) const = 0;
virtual bool ShouldFireEvent(const DeviceData* other) const = 0;
protected:
DeviceData() {}
virtual ~DeviceData() {}
private:
friend class base::RefCountedThreadSafe<DeviceData>;
DISALLOW_COPY_AND_ASSIGN(DeviceData);
};
} // namespace content
#endif // CONTENT_BROWSER_DEVICE_ORIENTATION_DEVICE_DATA_H_
...@@ -410,7 +410,6 @@ ...@@ -410,7 +410,6 @@
'browser/device_orientation/data_fetcher_shared_memory_default.cc', 'browser/device_orientation/data_fetcher_shared_memory_default.cc',
'browser/device_orientation/data_fetcher_shared_memory_mac.cc', 'browser/device_orientation/data_fetcher_shared_memory_mac.cc',
'browser/device_orientation/data_fetcher_shared_memory_win.cc', 'browser/device_orientation/data_fetcher_shared_memory_win.cc',
'browser/device_orientation/device_data.h',
'browser/device_orientation/device_inertial_sensor_service.cc', 'browser/device_orientation/device_inertial_sensor_service.cc',
'browser/device_orientation/device_inertial_sensor_service.h', 'browser/device_orientation/device_inertial_sensor_service.h',
'browser/device_orientation/device_motion_message_filter.cc', 'browser/device_orientation/device_motion_message_filter.cc',
......
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