OLD | NEW |
(Empty) | |
| 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 "content/public/browser/power_profiler_observer.h" |
| 6 |
| 7 #include "content/public/browser/browser_thread.h" |
| 8 #include "content/public/browser/power_profiler_service.h" |
| 9 |
| 10 namespace content { |
| 11 |
| 12 PowerProfilerObserver::PowerProfilerObserver() : resolution_(NORMAL) { |
| 13 } |
| 14 |
| 15 PowerProfilerObserver::~PowerProfilerObserver() { |
| 16 } |
| 17 |
| 18 bool PowerProfilerObserver::Register() { |
| 19 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 20 |
| 21 if (!PowerProfilerService::GetInstance()->IsAvailable()) |
| 22 return false; |
| 23 |
| 24 PowerProfilerService::GetInstance()->AddObserver(this); |
| 25 |
| 26 return true; |
| 27 } |
| 28 |
| 29 void PowerProfilerObserver::Unregister() { |
| 30 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 31 |
| 32 PowerProfilerService::GetInstance()->RemoveObserver(this); |
| 33 } |
| 34 |
| 35 void PowerProfilerObserver::SetResolution(Resolution resolution) { |
| 36 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 37 |
| 38 resolution_ = resolution; |
| 39 PowerProfilerService::GetInstance()->UpdateResolution(); |
| 40 } |
| 41 |
| 42 } // namespace content |
OLD | NEW |