| Index: athena/system/orientation_controller.h
|
| diff --git a/athena/system/orientation_controller.h b/athena/system/orientation_controller.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..d01ba10cd7d805e49292870c1b7c7849db637da9
|
| --- /dev/null
|
| +++ b/athena/system/orientation_controller.h
|
| @@ -0,0 +1,55 @@
|
| +// Copyright 2014 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 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/scoped_ptr.h"
|
| +#include "base/memory/weak_ptr.h"
|
| +#include "ui/gfx/display.h"
|
| +
|
| +namespace base {
|
| +class FilePath;
|
| +class FilePathWatcher;
|
| +}
|
| +
|
| +namespace athena {
|
| +
|
| +// Monitors accelerometers, detecting orientation changes. When a change is
|
| +// detected rotates the root window to match.
|
| +class OrientationController : public DeviceSocketListener {
|
| + public:
|
| + OrientationController();
|
| + virtual ~OrientationController();
|
| +
|
| + private:
|
| + // Overridden from device::DeviceSocketListener:
|
| + virtual void OnDataAvailableOnIO(const void* data) OVERRIDE;
|
| +
|
| + // Rotates the display to |rotation|, called on the UI thread.
|
| + void RotateOnUI(gfx::Display::Rotation rotation);
|
| +
|
| + // Dispatched when the socket path is created. This is used at startup when
|
| + // the socket file has not yet been created.
|
| + void OnFilePathChanged(const base::FilePath& path, bool error);
|
| +
|
| + // The last configured rotation.
|
| + gfx::Display::Rotation current_rotation_;
|
| +
|
| + // The timestamp of the last applied orientation change.
|
| + int64_t last_orientation_change_time_;
|
| +
|
| + // The file watcher which detects when the orientation socket file created.
|
| + scoped_ptr<base::FilePathWatcher> watcher_;
|
| +
|
| + base::WeakPtrFactory<OrientationController> weak_factory_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(OrientationController);
|
| +};
|
| +
|
| +} // namespace athena
|
| +
|
| +#endif // ATHENA_SYSTEM_ORIENTATION_CONTROLLER_H_
|
|
|