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