Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / athena / system / system_ui_impl.cc
blobb3bacb5f77b98c3eb9697891e96d120941afbd7d
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.
5 #include "athena/system/public/system_ui.h"
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"
14 namespace athena {
15 namespace {
17 SystemUI* instance = NULL;
19 class SystemUIImpl : public SystemUI {
20 public:
21 SystemUIImpl(scoped_refptr<base::TaskRunner> file_task_runner)
22 : orientation_controller_(new OrientationController()),
23 power_button_controller_(new PowerButtonController) {
24 orientation_controller_->InitWith(file_task_runner);
27 virtual ~SystemUIImpl() {
28 // Stops file watching now if exists. Waiting until message loop shutdon
29 // leads to FilePathWatcher crash.
30 orientation_controller_->Shutdown();
33 private:
34 scoped_refptr<OrientationController> orientation_controller_;
35 scoped_ptr<PowerButtonController> power_button_controller_;
37 DISALLOW_COPY_AND_ASSIGN(SystemUIImpl);
40 } // namespace
42 // static
43 SystemUI* SystemUI::Create(scoped_refptr<base::TaskRunner> file_task_runner) {
44 DeviceSocketListener::CreateSocketManager(file_task_runner);
45 instance = new SystemUIImpl(file_task_runner);
46 return instance;
49 // static
50 void SystemUI::Shutdown() {
51 CHECK(instance);
52 delete instance;
53 instance = NULL;
54 DeviceSocketListener::ShutdownSocketManager();
57 } // namespace athena