| 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> io_task_runner) | 21 SystemUIImpl(scoped_refptr<base::TaskRunner> file_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(io_task_runner); | 24 orientation_controller_->InitWith(file_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_->StopWatchingSocketPath(); |
| 28 } | 31 } |
| 29 | 32 |
| 30 private: | 33 private: |
| 31 scoped_refptr<OrientationController> orientation_controller_; | 34 scoped_refptr<OrientationController> orientation_controller_; |
| 32 scoped_ptr<PowerButtonController> power_button_controller_; | 35 scoped_ptr<PowerButtonController> power_button_controller_; |
| 33 | 36 |
| 34 DISALLOW_COPY_AND_ASSIGN(SystemUIImpl); | 37 DISALLOW_COPY_AND_ASSIGN(SystemUIImpl); |
| 35 }; | 38 }; |
| 36 | 39 |
| 37 } // namespace | 40 } // namespace |
| 38 | 41 |
| 39 // static | 42 // static |
| 40 SystemUI* SystemUI::Create( | 43 SystemUI* SystemUI::Create(scoped_refptr<base::TaskRunner> file_task_runner) { |
| 41 scoped_refptr<base::TaskRunner> io_task_runner) { | 44 DeviceSocketListener::CreateSocketManager(file_task_runner); |
| 42 DeviceSocketListener::CreateSocketManager(io_task_runner); | 45 instance = new SystemUIImpl(file_task_runner); |
| 43 instance = new SystemUIImpl(io_task_runner); | |
| 44 return instance; | 46 return instance; |
| 45 } | 47 } |
| 46 | 48 |
| 47 // static | 49 // static |
| 48 void SystemUI::Shutdown() { | 50 void SystemUI::Shutdown() { |
| 49 CHECK(instance); | 51 CHECK(instance); |
| 50 delete instance; | 52 delete instance; |
| 51 instance = NULL; | 53 instance = NULL; |
| 52 DeviceSocketListener::ShutdownSocketManager(); | 54 DeviceSocketListener::ShutdownSocketManager(); |
| 53 } | 55 } |
| 54 | 56 |
| 55 } // namespace athena | 57 } // namespace athena |
| OLD | NEW |