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

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: Pass in task runner to avoid new dependency on content/public/browser/browser_thread.h. 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 class TaskRunner;
18 }
19
20 namespace athena {
21
22 // Monitors accelerometers, detecting orientation changes. When a change is
23 // detected rotates the root window to match.
24 class OrientationController : public DeviceSocketListener {
25 public:
26 OrientationController();
27 virtual ~OrientationController();
28
29 private:
30 // Overridden from device::DeviceSocketListener:
31 virtual void OnDataAvailableOnIO(const void* data) OVERRIDE;
32
33 // Rotates the display to |rotation|, called on the UI thread.
34 void RotateOnUI(gfx::Display::Rotation rotation);
35
36 // Dispatched when the socket path is created. This is used at startup when
37 // the socket file has not yet been created.
38 void OnFilePathChanged(const base::FilePath& path, bool error);
39
40 // The last configured rotation.
41 gfx::Display::Rotation current_rotation_;
42
43 // The timestamp of the last applied orientation change.
44 int64_t last_orientation_change_time_;
45
46 // The file watcher which detects when the orientation socket file created.
47 scoped_ptr<base::FilePathWatcher> watcher_;
48
49 // A task runner for the UI thread.
50 scoped_refptr<base::TaskRunner> ui_task_runner_;
51
52 base::WeakPtrFactory<OrientationController> weak_factory_;
53
54 DISALLOW_COPY_AND_ASSIGN(OrientationController);
55 };
56
57 } // namespace athena
58
59 #endif // ATHENA_SYSTEM_ORIENTATION_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698