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

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: Add dependencies on ipc and content. 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/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "ui/gfx/display.h"
14
15 namespace base {
16 class FilePath;
17 class FilePathWatcher;
18 class TaskRunner;
19 }
20
21 namespace athena {
22
23 // Monitors accelerometers, detecting orientation changes. When a change is
24 // detected rotates the root window to match.
25 class OrientationController
26 : public DeviceSocketListener,
27 public base::RefCountedThreadSafe<OrientationController> {
28 public:
29 OrientationController(scoped_refptr<base::TaskRunner> io_task_runner);
30
31 private:
32 friend class base::RefCountedThreadSafe<OrientationController>;
33
34 virtual ~OrientationController();
35
36 // Watch for the socket path to be created, called on the IO thread.
37 void WatchForSocketPathOnIO();
38 void OnFilePathChangedOnIO(const base::FilePath& path, bool error);
39
40 // Overridden from device::DeviceSocketListener:
41 virtual void OnDataAvailableOnIO(const void* data) OVERRIDE;
42
43 // Rotates the display to |rotation|, called on the UI thread.
44 void RotateOnUI(gfx::Display::Rotation rotation);
45
46 // The last configured rotation.
47 gfx::Display::Rotation current_rotation_;
48
49 // The timestamp of the last applied orientation change.
50 int64_t last_orientation_change_time_;
51
52 // A task runner for the UI thread.
53 scoped_refptr<base::TaskRunner> ui_task_runner_;
54
55 // File path watcher used to detect when sensors are present.
56 scoped_ptr<base::FilePathWatcher> watcher_;
57
58 base::WeakPtrFactory<OrientationController> weak_factory_;
59
60 DISALLOW_COPY_AND_ASSIGN(OrientationController);
61 };
62
63 } // namespace athena
64
65 #endif // ATHENA_SYSTEM_ORIENTATION_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698