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

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

Issue 571283006: Revert of Use chromeos accelerometer reader and support only lid accelerometer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « athena/system/device_socket_listener.cc ('k') | athena/system/orientation_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef ATHENA_SYSTEM_ORIENTATION_CONTROLLER_H_ 5 #ifndef ATHENA_SYSTEM_ORIENTATION_CONTROLLER_H_
6 #define ATHENA_SYSTEM_ORIENTATION_CONTROLLER_H_ 6 #define ATHENA_SYSTEM_ORIENTATION_CONTROLLER_H_
7 7
8 #include "athena/system/device_socket_listener.h"
8 #include "base/macros.h" 9 #include "base/macros.h"
9 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
12 #include "chromeos/accelerometer/accelerometer_reader.h"
13 #include "ui/gfx/display.h" 13 #include "ui/gfx/display.h"
14 14
15 namespace base { 15 namespace base {
16 class FilePath;
17 class FilePathWatcher;
16 class TaskRunner; 18 class TaskRunner;
17 } 19 }
18 20
19 namespace athena { 21 namespace athena {
20 22
21 // Monitors accelerometers, detecting orientation changes. When a change is 23 // Monitors accelerometers, detecting orientation changes. When a change is
22 // detected rotates the root window to match. 24 // detected rotates the root window to match.
23 class OrientationController 25 class OrientationController
24 : public chromeos::AccelerometerReader::Delegate { 26 : public DeviceSocketListener,
27 public base::RefCountedThreadSafe<OrientationController> {
25 public: 28 public:
26 OrientationController(); 29 OrientationController();
30
31 void InitWith(scoped_refptr<base::TaskRunner> file_task_runner);
32
33 void Shutdown();
34
35 private:
36 friend class base::RefCountedThreadSafe<OrientationController>;
37
27 virtual ~OrientationController(); 38 virtual ~OrientationController();
28 39
29 void InitWith(scoped_refptr<base::TaskRunner> blocking_task_runner); 40 void ShutdownOnFILE();
30 void Shutdown(); 41 // Watch for the socket path to be created, called on the FILE thread.
42 void WatchForSocketPathOnFILE();
43 void OnFilePathChangedOnFILE(const base::FilePath& path, bool error);
31 44
32 // chromeos::AccelerometerReader::Delegate 45 // Overridden from device::DeviceSocketListener:
33 virtual void HandleAccelerometerUpdate( 46 virtual void OnDataAvailableOnFILE(const void* data) OVERRIDE;
34 const ui::AccelerometerUpdate& update) OVERRIDE;
35 47
36 private: 48 // Rotates the display to |rotation|, called on the UI thread.
49 void RotateOnUI(gfx::Display::Rotation rotation);
50
37 // The last configured rotation. 51 // The last configured rotation.
38 gfx::Display::Rotation current_rotation_; 52 gfx::Display::Rotation current_rotation_;
39 53
40 scoped_ptr<chromeos::AccelerometerReader> accelerometer_reader_; 54 // The timestamp of the last applied orientation change.
55 int64_t last_orientation_change_time_;
56
57 // True if the OrientaionController has already been shutdown.
58 // This is initialized on UI thread, but must be accessed / modified
59 // only on FILE thread.
60 bool shutdown_;
61
62 // A task runner for the UI thread.
63 scoped_refptr<base::TaskRunner> ui_task_runner_;
64
65 // A task runner for the FILE thread.
66 scoped_refptr<base::TaskRunner> file_task_runner_;
67
68 // File path watcher used to detect when sensors are present.
69 scoped_ptr<base::FilePathWatcher> watcher_;
41 70
42 DISALLOW_COPY_AND_ASSIGN(OrientationController); 71 DISALLOW_COPY_AND_ASSIGN(OrientationController);
43 }; 72 };
44 73
45 } // namespace athena 74 } // namespace athena
46 75
47 #endif // ATHENA_SYSTEM_ORIENTATION_CONTROLLER_H_ 76 #endif // ATHENA_SYSTEM_ORIENTATION_CONTROLLER_H_
OLDNEW
« no previous file with comments | « athena/system/device_socket_listener.cc ('k') | athena/system/orientation_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698