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

Unified Diff: athena/system/orientation_controller.cc

Issue 490033003: Fixes three crashes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add file thread 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « athena/system/orientation_controller.h ('k') | athena/system/system_ui_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: athena/system/orientation_controller.cc
diff --git a/athena/system/orientation_controller.cc b/athena/system/orientation_controller.cc
index 8996d7db1e7b601ca4b9449cc6d61c0d22b2fd33..511e0cac06fe1eca3cfae142800dd30a4945c58e 100644
--- a/athena/system/orientation_controller.cc
+++ b/athena/system/orientation_controller.cc
@@ -58,21 +58,37 @@ struct DeviceSensorEvent {
OrientationController::OrientationController()
: DeviceSocketListener(kSocketPath, sizeof(DeviceSensorEvent)),
- last_orientation_change_time_(0) {
+ last_orientation_change_time_(0),
+ shutdown_(false) {
CHECK(base::MessageLoopForUI::current());
ui_task_runner_ = base::MessageLoopForUI::current()->task_runner();
}
void OrientationController::InitWith(
- scoped_refptr<base::TaskRunner> io_task_runner) {
- io_task_runner->PostTask(FROM_HERE, base::Bind(
- &OrientationController::WatchForSocketPathOnIO, this));
+ scoped_refptr<base::TaskRunner> file_task_runner) {
+ file_task_runner_ = file_task_runner;
+ file_task_runner->PostTask(
+ FROM_HERE,
+ base::Bind(&OrientationController::WatchForSocketPathOnFILE, this));
}
OrientationController::~OrientationController() {
}
-void OrientationController::WatchForSocketPathOnIO() {
+void OrientationController::Shutdown() {
+ CHECK(file_task_runner_);
+ StopListening();
+ file_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&OrientationController::ShutdownOnFILE, this));
+}
+
+void OrientationController::ShutdownOnFILE() {
+ shutdown_ = true;
+ watcher_.reset();
+}
+
+void OrientationController::WatchForSocketPathOnFILE() {
CHECK(base::MessageLoopForIO::current());
if (base::PathExists(base::FilePath(kSocketPath))) {
ui_task_runner_->PostTask(FROM_HERE,
@@ -80,22 +96,23 @@ void OrientationController::WatchForSocketPathOnIO() {
} else {
watcher_.reset(new base::FilePathWatcher);
watcher_->Watch(
- base::FilePath(kSocketPath), false,
- base::Bind(&OrientationController::OnFilePathChangedOnIO, this));
+ base::FilePath(kSocketPath),
+ false,
+ base::Bind(&OrientationController::OnFilePathChangedOnFILE, this));
}
}
-void OrientationController::OnFilePathChangedOnIO(const base::FilePath& path,
- bool error) {
+void OrientationController::OnFilePathChangedOnFILE(const base::FilePath& path,
+ bool error) {
watcher_.reset();
- if (error)
+ if (error || shutdown_)
return;
ui_task_runner_->PostTask(FROM_HERE,
base::Bind(&OrientationController::StartListening, this));
}
-void OrientationController::OnDataAvailableOnIO(const void* data) {
+void OrientationController::OnDataAvailableOnFILE(const void* data) {
const DeviceSensorEvent* event =
static_cast<const DeviceSensorEvent*>(data);
if (event->type != SENSOR_ACCELEROMETER)
@@ -131,7 +148,7 @@ void OrientationController::OnDataAvailableOnIO(const void* data) {
void OrientationController::RotateOnUI(gfx::Display::Rotation rotation) {
ScreenManager* screen_manager = ScreenManager::Get();
- // Since this is called from the IO thread, the screen manager may no longer
+ // Since this is called from the FILE thread, the screen manager may no longer
// exist.
if (screen_manager)
screen_manager->SetRotation(rotation);
« no previous file with comments | « athena/system/orientation_controller.h ('k') | athena/system/system_ui_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698