| 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/power_profiler/power_profiler_service.h" | 5 #include "content/browser/power_profiler/power_profiler_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/threading/sequenced_worker_pool.h" | 9 #include "base/threading/sequenced_worker_pool.h" |
| 10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 return "High"; | 53 return "High"; |
| 54 case PowerDataProvider::Moderate: | 54 case PowerDataProvider::Moderate: |
| 55 return "Moderate"; | 55 return "Moderate"; |
| 56 case PowerDataProvider::Low: | 56 case PowerDataProvider::Low: |
| 57 return "Low"; | 57 return "Low"; |
| 58 } | 58 } |
| 59 return ""; | 59 return ""; |
| 60 } | 60 } |
| 61 | 61 |
| 62 PowerProfilerService* PowerProfilerService::GetInstance() { | 62 PowerProfilerService* PowerProfilerService::GetInstance() { |
| 63 return Singleton<PowerProfilerService>::get(); | 63 return base::Singleton<PowerProfilerService>::get(); |
| 64 } | 64 } |
| 65 | 65 |
| 66 void PowerProfilerService::AddObserver(PowerProfilerObserver* observer) { | 66 void PowerProfilerService::AddObserver(PowerProfilerObserver* observer) { |
| 67 if (status_ == UNINITIALIZED) | 67 if (status_ == UNINITIALIZED) |
| 68 return; | 68 return; |
| 69 | 69 |
| 70 observers_.AddObserver(observer); | 70 observers_.AddObserver(observer); |
| 71 if (status_ != PROFILING) | 71 if (status_ != PROFILING) |
| 72 Start(); | 72 Start(); |
| 73 } | 73 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 | 113 |
| 114 // Get data and notify. | 114 // Get data and notify. |
| 115 PowerEventVector events = data_provider_->GetData(); | 115 PowerEventVector events = data_provider_->GetData(); |
| 116 if (events.size() != 0) { | 116 if (events.size() != 0) { |
| 117 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( | 117 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( |
| 118 &PowerProfilerService::Notify, base::Unretained(this), events)); | 118 &PowerProfilerService::Notify, base::Unretained(this), events)); |
| 119 } | 119 } |
| 120 } | 120 } |
| 121 | 121 |
| 122 } // namespace content | 122 } // namespace content |
| OLD | NEW |