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

Side by Side Diff: athena/system/orientation_controller.h

Issue 431183003: Rotate screen in response to accelerator or device orientation sensors. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef ATHENA_SYSTEM_ORIENTATION_CONTROLLER_H_
6 #define ATHENA_SYSTEM_ORIENTATION_CONTROLLER_H_
7
8 #include "athena/system/device_socket_listener.h"
9 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "ui/gfx/display.h"
13
14 namespace base {
15 class FilePath;
16 class FilePathWatcher;
17 }
18
19 namespace athena {
20
21 // Monitors accelerometers, detecting orientation changes. When a change is
22 // detected rotates the root window to match.
23 class OrientationController : public DeviceSocketListener {
24 public:
25 OrientationController();
26 virtual ~OrientationController();
27
28 private:
29 // Overridden from device::DeviceSocketListener:
30 virtual void OnDataAvailableOnIO(const void* data) OVERRIDE;
31
32 // Rotates the display to |rotation|, called on the UI thread.
33 void RotateOnUI(gfx::Display::Rotation rotation);
34
35 // Dispatched when the socket path is created. This is used at startup when
36 // the socket file has not yet been created.
37 void OnFilePathChanged(const base::FilePath& path, bool error);
38
39 // The last configured rotation.
40 gfx::Display::Rotation current_rotation_;
41
42 // The timestamp of the last applied orientation change.
43 int64_t last_orientation_change_time_;
44
45 // The file watcher which detects when the orientation socket file created.
46 scoped_ptr<base::FilePathWatcher> watcher_;
47
48 base::WeakPtrFactory<OrientationController> weak_factory_;
49
50 DISALLOW_COPY_AND_ASSIGN(OrientationController);
51 };
52
53 } // namespace athena
54
55 #endif // ATHENA_SYSTEM_ORIENTATION_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698