| 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 "content/browser/battery_status/battery_status_manager_linux.h" | 5 #include "content/browser/battery_status/battery_status_manager_linux.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 class BatteryStatusManagerLinux : public BatteryStatusManager { | 270 class BatteryStatusManagerLinux : public BatteryStatusManager { |
| 271 public: | 271 public: |
| 272 explicit BatteryStatusManagerLinux( | 272 explicit BatteryStatusManagerLinux( |
| 273 const BatteryStatusService::BatteryUpdateCallback& callback) | 273 const BatteryStatusService::BatteryUpdateCallback& callback) |
| 274 : callback_(callback) {} | 274 : callback_(callback) {} |
| 275 | 275 |
| 276 virtual ~BatteryStatusManagerLinux() {} | 276 virtual ~BatteryStatusManagerLinux() {} |
| 277 | 277 |
| 278 private: | 278 private: |
| 279 // BatteryStatusManager: | 279 // BatteryStatusManager: |
| 280 virtual bool StartListeningBatteryChange() OVERRIDE { | 280 virtual bool StartListeningBatteryChange() override { |
| 281 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 281 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 282 | 282 |
| 283 if (!StartNotifierThreadIfNecessary()) | 283 if (!StartNotifierThreadIfNecessary()) |
| 284 return false; | 284 return false; |
| 285 | 285 |
| 286 notifier_thread_->message_loop()->PostTask( | 286 notifier_thread_->message_loop()->PostTask( |
| 287 FROM_HERE, | 287 FROM_HERE, |
| 288 base::Bind(&BatteryStatusNotificationThread::StartListening, | 288 base::Bind(&BatteryStatusNotificationThread::StartListening, |
| 289 base::Unretained(notifier_thread_.get()))); | 289 base::Unretained(notifier_thread_.get()))); |
| 290 return true; | 290 return true; |
| 291 } | 291 } |
| 292 | 292 |
| 293 virtual void StopListeningBatteryChange() OVERRIDE { | 293 virtual void StopListeningBatteryChange() override { |
| 294 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 294 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 295 | 295 |
| 296 if (!notifier_thread_) | 296 if (!notifier_thread_) |
| 297 return; | 297 return; |
| 298 | 298 |
| 299 notifier_thread_->message_loop()->PostTask( | 299 notifier_thread_->message_loop()->PostTask( |
| 300 FROM_HERE, | 300 FROM_HERE, |
| 301 base::Bind(&BatteryStatusNotificationThread::StopListening, | 301 base::Bind(&BatteryStatusNotificationThread::StopListening, |
| 302 base::Unretained(notifier_thread_.get()))); | 302 base::Unretained(notifier_thread_.get()))); |
| 303 } | 303 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 } | 374 } |
| 375 | 375 |
| 376 // static | 376 // static |
| 377 scoped_ptr<BatteryStatusManager> BatteryStatusManager::Create( | 377 scoped_ptr<BatteryStatusManager> BatteryStatusManager::Create( |
| 378 const BatteryStatusService::BatteryUpdateCallback& callback) { | 378 const BatteryStatusService::BatteryUpdateCallback& callback) { |
| 379 return scoped_ptr<BatteryStatusManager>( | 379 return scoped_ptr<BatteryStatusManager>( |
| 380 new BatteryStatusManagerLinux(callback)); | 380 new BatteryStatusManagerLinux(callback)); |
| 381 } | 381 } |
| 382 | 382 |
| 383 } // namespace content | 383 } // namespace content |
| OLD | NEW |