Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: content/browser/power_profiler/power_profiler_service.cc

Issue 332943005: [Chromium] [PowerProfiler] Support accuracy level attribute for power data provider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Patch for landing! Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 24 matching lines...) Expand all
35 data_provider_(provider.Pass()) { 35 data_provider_(provider.Pass()) {
36 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 36 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
37 37
38 if (data_provider_.get()) 38 if (data_provider_.get())
39 status_ = INITIALIZED; 39 status_ = INITIALIZED;
40 } 40 }
41 41
42 PowerProfilerService::~PowerProfilerService() { 42 PowerProfilerService::~PowerProfilerService() {
43 } 43 }
44 44
45 bool PowerProfilerService::IsAvailable() { 45 bool PowerProfilerService::IsAvailable() const {
46 return status_ != UNINITIALIZED; 46 return status_ != UNINITIALIZED;
47 } 47 }
48 48
49 std::string PowerProfilerService::GetAccuracyLevel() const {
50 DCHECK(IsAvailable());
51 switch (data_provider_->GetAccuracyLevel()) {
52 case PowerDataProvider::High:
53 return "High";
54 case PowerDataProvider::Moderate:
55 return "Moderate";
56 case PowerDataProvider::Low:
57 return "Low";
58 }
59 return "";
60 }
61
49 PowerProfilerService* PowerProfilerService::GetInstance() { 62 PowerProfilerService* PowerProfilerService::GetInstance() {
50 return Singleton<PowerProfilerService>::get(); 63 return Singleton<PowerProfilerService>::get();
51 } 64 }
52 65
53 void PowerProfilerService::AddObserver(PowerProfilerObserver* observer) { 66 void PowerProfilerService::AddObserver(PowerProfilerObserver* observer) {
54 if (status_ == UNINITIALIZED) 67 if (status_ == UNINITIALIZED)
55 return; 68 return;
56 69
57 observers_.AddObserver(observer); 70 observers_.AddObserver(observer);
58 if (status_ != PROFILING) 71 if (status_ != PROFILING)
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 113
101 // Get data and notify. 114 // Get data and notify.
102 PowerEventVector events = data_provider_->GetData(); 115 PowerEventVector events = data_provider_->GetData();
103 if (events.size() != 0) { 116 if (events.size() != 0) {
104 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( 117 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind(
105 &PowerProfilerService::Notify, base::Unretained(this), events)); 118 &PowerProfilerService::Notify, base::Unretained(this), events));
106 } 119 }
107 } 120 }
108 121
109 } // namespace content 122 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698