| OLD | NEW |
| 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 #include "athena/system/public/system_ui.h" | 5 #include "athena/system/public/system_ui.h" |
| 6 | 6 |
| 7 #include "athena/system/device_socket_listener.h" | 7 #include "athena/system/device_socket_listener.h" |
| 8 #include "athena/system/orientation_controller.h" | 8 #include "athena/system/orientation_controller.h" |
| 9 #include "athena/system/power_button_controller.h" | 9 #include "athena/system/power_button_controller.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 | 13 |
| 14 namespace athena { | 14 namespace athena { |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 SystemUI* instance = NULL; | 17 SystemUI* instance = NULL; |
| 18 | 18 |
| 19 class SystemUIImpl : public SystemUI { | 19 class SystemUIImpl : public SystemUI { |
| 20 public: | 20 public: |
| 21 SystemUIImpl(scoped_refptr<base::TaskRunner> file_task_runner) | 21 SystemUIImpl(scoped_refptr<base::TaskRunner> io_task_runner) |
| 22 : orientation_controller_(new OrientationController()), | 22 : orientation_controller_(new OrientationController()), |
| 23 power_button_controller_(new PowerButtonController) { | 23 power_button_controller_(new PowerButtonController) { |
| 24 orientation_controller_->InitWith(file_task_runner); | 24 orientation_controller_->InitWith(io_task_runner); |
| 25 } | 25 } |
| 26 | 26 |
| 27 virtual ~SystemUIImpl() { | 27 virtual ~SystemUIImpl() { |
| 28 // Stops file watching now if exists. Waiting until message loop shutdon | |
| 29 // leads to FilePathWatcher crash. | |
| 30 orientation_controller_->Shutdown(); | |
| 31 } | 28 } |
| 32 | 29 |
| 33 private: | 30 private: |
| 34 scoped_refptr<OrientationController> orientation_controller_; | 31 scoped_refptr<OrientationController> orientation_controller_; |
| 35 scoped_ptr<PowerButtonController> power_button_controller_; | 32 scoped_ptr<PowerButtonController> power_button_controller_; |
| 36 | 33 |
| 37 DISALLOW_COPY_AND_ASSIGN(SystemUIImpl); | 34 DISALLOW_COPY_AND_ASSIGN(SystemUIImpl); |
| 38 }; | 35 }; |
| 39 | 36 |
| 40 } // namespace | 37 } // namespace |
| 41 | 38 |
| 42 // static | 39 // static |
| 43 SystemUI* SystemUI::Create(scoped_refptr<base::TaskRunner> file_task_runner) { | 40 SystemUI* SystemUI::Create( |
| 44 DeviceSocketListener::CreateSocketManager(file_task_runner); | 41 scoped_refptr<base::TaskRunner> io_task_runner) { |
| 45 instance = new SystemUIImpl(file_task_runner); | 42 DeviceSocketListener::CreateSocketManager(io_task_runner); |
| 43 instance = new SystemUIImpl(io_task_runner); |
| 46 return instance; | 44 return instance; |
| 47 } | 45 } |
| 48 | 46 |
| 49 // static | 47 // static |
| 50 void SystemUI::Shutdown() { | 48 void SystemUI::Shutdown() { |
| 51 CHECK(instance); | 49 CHECK(instance); |
| 52 delete instance; | 50 delete instance; |
| 53 instance = NULL; | 51 instance = NULL; |
| 54 DeviceSocketListener::ShutdownSocketManager(); | 52 DeviceSocketListener::ShutdownSocketManager(); |
| 55 } | 53 } |
| 56 | 54 |
| 57 } // namespace athena | 55 } // namespace athena |
| OLD | NEW |