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