OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/chromeos/cros/power_library.h" | 5 #include "chrome/browser/chromeos/cros/power_library.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 // Called when the screen preference is changed, which should always | 58 // Called when the screen preference is changed, which should always |
59 // run on UI thread. | 59 // run on UI thread. |
60 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 60 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
61 // Post the task to FILE thread as chromeos::EnableScreenLock | 61 // Post the task to FILE thread as chromeos::EnableScreenLock |
62 // would write power manager config file to disk. | 62 // would write power manager config file to disk. |
63 BrowserThread::PostTask( | 63 BrowserThread::PostTask( |
64 BrowserThread::FILE, FROM_HERE, | 64 BrowserThread::FILE, FROM_HERE, |
65 base::Bind(&PowerLibraryImpl::DoEnableScreenLock, enable)); | 65 base::Bind(&PowerLibraryImpl::DoEnableScreenLock, enable)); |
66 } | 66 } |
67 | 67 |
68 virtual void RequestRestart() OVERRIDE { | |
69 chromeos::RequestRestart(); | |
70 } | |
71 | |
72 virtual void RequestShutdown() OVERRIDE { | |
73 chromeos::RequestShutdown(); | |
74 } | |
75 | |
76 // End PowerLibrary implementation. | 68 // End PowerLibrary implementation. |
77 | 69 |
78 private: | 70 private: |
79 static void DoEnableScreenLock(bool enable) { | 71 static void DoEnableScreenLock(bool enable) { |
80 chromeos::EnableScreenLock(enable); | 72 chromeos::EnableScreenLock(enable); |
81 } | 73 } |
82 | 74 |
83 static void GetIdleTimeCallback(void* object, | 75 static void GetIdleTimeCallback(void* object, |
84 int64_t time_idle_ms, | 76 int64_t time_idle_ms, |
85 bool success) { | 77 bool success) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 observers_.RemoveObserver(observer); | 126 observers_.RemoveObserver(observer); |
135 } | 127 } |
136 | 128 |
137 virtual void CalculateIdleTime(CalculateIdleTimeCallback* callback) OVERRIDE { | 129 virtual void CalculateIdleTime(CalculateIdleTimeCallback* callback) OVERRIDE { |
138 callback->Run(0); | 130 callback->Run(0); |
139 delete callback; | 131 delete callback; |
140 } | 132 } |
141 | 133 |
142 virtual void EnableScreenLock(bool enable) OVERRIDE {} | 134 virtual void EnableScreenLock(bool enable) OVERRIDE {} |
143 | 135 |
144 virtual void RequestRestart() OVERRIDE {} | |
145 | |
146 virtual void RequestShutdown() OVERRIDE {} | |
147 | |
148 // End PowerLibrary implementation. | 136 // End PowerLibrary implementation. |
149 private: | 137 private: |
150 ObserverList<Observer> observers_; | 138 ObserverList<Observer> observers_; |
151 }; | 139 }; |
152 | 140 |
153 // static | 141 // static |
154 PowerLibrary* PowerLibrary::GetImpl(bool stub) { | 142 PowerLibrary* PowerLibrary::GetImpl(bool stub) { |
155 PowerLibrary* impl; | 143 PowerLibrary* impl; |
156 if (stub) | 144 if (stub) |
157 impl = new PowerLibraryStubImpl(); | 145 impl = new PowerLibraryStubImpl(); |
158 else | 146 else |
159 impl = new PowerLibraryImpl(); | 147 impl = new PowerLibraryImpl(); |
160 impl->Init(); | 148 impl->Init(); |
161 return impl; | 149 return impl; |
162 } | 150 } |
163 | 151 |
164 } // namespace chromeos | 152 } // namespace chromeos |
OLD | NEW |