| Index: athena/system/orientation_controller.h
|
| diff --git a/athena/system/orientation_controller.h b/athena/system/orientation_controller.h
|
| index c02a5b0fb7f8c688507e6520482288de3fef55cc..93887889e50bdb22cdb66237d79c385e8336150d 100644
|
| --- a/athena/system/orientation_controller.h
|
| +++ b/athena/system/orientation_controller.h
|
| @@ -5,14 +5,16 @@
|
| #ifndef ATHENA_SYSTEM_ORIENTATION_CONTROLLER_H_
|
| #define ATHENA_SYSTEM_ORIENTATION_CONTROLLER_H_
|
|
|
| +#include "athena/system/device_socket_listener.h"
|
| #include "base/macros.h"
|
| #include "base/memory/ref_counted.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/memory/weak_ptr.h"
|
| -#include "chromeos/accelerometer/accelerometer_reader.h"
|
| #include "ui/gfx/display.h"
|
|
|
| namespace base {
|
| +class FilePath;
|
| +class FilePathWatcher;
|
| class TaskRunner;
|
| }
|
|
|
| @@ -21,23 +23,50 @@
|
| // Monitors accelerometers, detecting orientation changes. When a change is
|
| // detected rotates the root window to match.
|
| class OrientationController
|
| - : public chromeos::AccelerometerReader::Delegate {
|
| + : public DeviceSocketListener,
|
| + public base::RefCountedThreadSafe<OrientationController> {
|
| public:
|
| OrientationController();
|
| +
|
| + void InitWith(scoped_refptr<base::TaskRunner> file_task_runner);
|
| +
|
| + void Shutdown();
|
| +
|
| + private:
|
| + friend class base::RefCountedThreadSafe<OrientationController>;
|
| +
|
| virtual ~OrientationController();
|
|
|
| - void InitWith(scoped_refptr<base::TaskRunner> blocking_task_runner);
|
| - void Shutdown();
|
| + void ShutdownOnFILE();
|
| + // Watch for the socket path to be created, called on the FILE thread.
|
| + void WatchForSocketPathOnFILE();
|
| + void OnFilePathChangedOnFILE(const base::FilePath& path, bool error);
|
|
|
| - // chromeos::AccelerometerReader::Delegate
|
| - virtual void HandleAccelerometerUpdate(
|
| - const ui::AccelerometerUpdate& update) OVERRIDE;
|
| + // Overridden from device::DeviceSocketListener:
|
| + virtual void OnDataAvailableOnFILE(const void* data) OVERRIDE;
|
|
|
| - private:
|
| + // Rotates the display to |rotation|, called on the UI thread.
|
| + void RotateOnUI(gfx::Display::Rotation rotation);
|
| +
|
| // The last configured rotation.
|
| gfx::Display::Rotation current_rotation_;
|
|
|
| - scoped_ptr<chromeos::AccelerometerReader> accelerometer_reader_;
|
| + // The timestamp of the last applied orientation change.
|
| + int64_t last_orientation_change_time_;
|
| +
|
| + // True if the OrientaionController has already been shutdown.
|
| + // This is initialized on UI thread, but must be accessed / modified
|
| + // only on FILE thread.
|
| + bool shutdown_;
|
| +
|
| + // A task runner for the UI thread.
|
| + scoped_refptr<base::TaskRunner> ui_task_runner_;
|
| +
|
| + // A task runner for the FILE thread.
|
| + scoped_refptr<base::TaskRunner> file_task_runner_;
|
| +
|
| + // File path watcher used to detect when sensors are present.
|
| + scoped_ptr<base::FilePathWatcher> watcher_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(OrientationController);
|
| };
|
|
|