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

Side by Side Diff: chrome/browser/ui/webui/chromeos/power_ui.cc

Issue 1865213004: Convert //chrome/browser/ui from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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 "chrome/browser/ui/webui/chromeos/power_ui.h" 5 #include "chrome/browser/ui/webui/chromeos/power_ui.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 base::Bind(&PowerMessageHandler::OnGetCpuFreqData, 78 base::Bind(&PowerMessageHandler::OnGetCpuFreqData,
79 base::Unretained(this))); 79 base::Unretained(this)));
80 } 80 }
81 81
82 void PowerMessageHandler::OnGetBatteryChargeData(const base::ListValue* value) { 82 void PowerMessageHandler::OnGetBatteryChargeData(const base::ListValue* value) {
83 const std::deque<PowerDataCollector::PowerSupplySample>& power_supply = 83 const std::deque<PowerDataCollector::PowerSupplySample>& power_supply =
84 PowerDataCollector::Get()->power_supply_data(); 84 PowerDataCollector::Get()->power_supply_data();
85 base::ListValue js_power_supply_data; 85 base::ListValue js_power_supply_data;
86 for (size_t i = 0; i < power_supply.size(); ++i) { 86 for (size_t i = 0; i < power_supply.size(); ++i) {
87 const PowerDataCollector::PowerSupplySample& sample = power_supply[i]; 87 const PowerDataCollector::PowerSupplySample& sample = power_supply[i];
88 scoped_ptr<base::DictionaryValue> element(new base::DictionaryValue); 88 std::unique_ptr<base::DictionaryValue> element(new base::DictionaryValue);
89 element->SetDouble("batteryPercent", sample.battery_percent); 89 element->SetDouble("batteryPercent", sample.battery_percent);
90 element->SetDouble("batteryDischargeRate", sample.battery_discharge_rate); 90 element->SetDouble("batteryDischargeRate", sample.battery_discharge_rate);
91 element->SetBoolean("externalPower", sample.external_power); 91 element->SetBoolean("externalPower", sample.external_power);
92 element->SetDouble("time", sample.time.ToJsTime()); 92 element->SetDouble("time", sample.time.ToJsTime());
93 93
94 js_power_supply_data.Append(element.release()); 94 js_power_supply_data.Append(element.release());
95 } 95 }
96 96
97 base::ListValue js_system_resumed_data; 97 base::ListValue js_system_resumed_data;
98 GetJsSystemResumedData(&js_system_resumed_data); 98 GetJsSystemResumedData(&js_system_resumed_data);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 js_system_resumed_data); 140 js_system_resumed_data);
141 } 141 }
142 142
143 void PowerMessageHandler::GetJsSystemResumedData(base::ListValue *data) { 143 void PowerMessageHandler::GetJsSystemResumedData(base::ListValue *data) {
144 DCHECK(data); 144 DCHECK(data);
145 145
146 const std::deque<PowerDataCollector::SystemResumedSample>& system_resumed = 146 const std::deque<PowerDataCollector::SystemResumedSample>& system_resumed =
147 PowerDataCollector::Get()->system_resumed_data(); 147 PowerDataCollector::Get()->system_resumed_data();
148 for (size_t i = 0; i < system_resumed.size(); ++i) { 148 for (size_t i = 0; i < system_resumed.size(); ++i) {
149 const PowerDataCollector::SystemResumedSample& sample = system_resumed[i]; 149 const PowerDataCollector::SystemResumedSample& sample = system_resumed[i];
150 scoped_ptr<base::DictionaryValue> element(new base::DictionaryValue); 150 std::unique_ptr<base::DictionaryValue> element(new base::DictionaryValue);
151 element->SetDouble("sleepDuration", 151 element->SetDouble("sleepDuration",
152 sample.sleep_duration.InMillisecondsF()); 152 sample.sleep_duration.InMillisecondsF());
153 element->SetDouble("time", sample.time.ToJsTime()); 153 element->SetDouble("time", sample.time.ToJsTime());
154 154
155 data->Append(element.release()); 155 data->Append(element.release());
156 } 156 }
157 } 157 }
158 158
159 void PowerMessageHandler::GetJsStateOccupancyData( 159 void PowerMessageHandler::GetJsStateOccupancyData(
160 const std::vector<CpuDataCollector::StateOccupancySampleDeque>& data, 160 const std::vector<CpuDataCollector::StateOccupancySampleDeque>& data,
161 const std::vector<std::string>& state_names, 161 const std::vector<std::string>& state_names,
162 base::ListValue *js_data) { 162 base::ListValue *js_data) {
163 for (unsigned int cpu = 0; cpu < data.size(); ++cpu) { 163 for (unsigned int cpu = 0; cpu < data.size(); ++cpu) {
164 const CpuDataCollector::StateOccupancySampleDeque& sample_deque = data[cpu]; 164 const CpuDataCollector::StateOccupancySampleDeque& sample_deque = data[cpu];
165 scoped_ptr<base::ListValue> js_sample_list(new base::ListValue); 165 std::unique_ptr<base::ListValue> js_sample_list(new base::ListValue);
166 for (unsigned int i = 0; i < sample_deque.size(); ++i) { 166 for (unsigned int i = 0; i < sample_deque.size(); ++i) {
167 const CpuDataCollector::StateOccupancySample& sample = sample_deque[i]; 167 const CpuDataCollector::StateOccupancySample& sample = sample_deque[i];
168 scoped_ptr<base::DictionaryValue> js_sample(new base::DictionaryValue); 168 std::unique_ptr<base::DictionaryValue> js_sample(
169 new base::DictionaryValue);
169 js_sample->SetDouble("time", sample.time.ToJsTime()); 170 js_sample->SetDouble("time", sample.time.ToJsTime());
170 js_sample->SetBoolean("cpuOnline", sample.cpu_online); 171 js_sample->SetBoolean("cpuOnline", sample.cpu_online);
171 172
172 scoped_ptr<base::DictionaryValue> state_dict(new base::DictionaryValue); 173 std::unique_ptr<base::DictionaryValue> state_dict(
174 new base::DictionaryValue);
173 for (size_t index = 0; index < sample.time_in_state.size(); ++index) { 175 for (size_t index = 0; index < sample.time_in_state.size(); ++index) {
174 state_dict->SetDouble(state_names[index], 176 state_dict->SetDouble(state_names[index],
175 static_cast<double>(sample.time_in_state[index])); 177 static_cast<double>(sample.time_in_state[index]));
176 } 178 }
177 js_sample->Set("timeInState", state_dict.release()); 179 js_sample->Set("timeInState", state_dict.release());
178 180
179 js_sample_list->Append(js_sample.release()); 181 js_sample_list->Append(js_sample.release());
180 } 182 }
181 js_data->Append(js_sample_list.release()); 183 js_data->Append(js_sample_list.release());
182 } 184 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 html->SetDefaultResource(IDR_ABOUT_POWER_HTML); 237 html->SetDefaultResource(IDR_ABOUT_POWER_HTML);
236 238
237 Profile* profile = Profile::FromWebUI(web_ui); 239 Profile* profile = Profile::FromWebUI(web_ui);
238 content::WebUIDataSource::Add(profile, html); 240 content::WebUIDataSource::Add(profile, html);
239 } 241 }
240 242
241 PowerUI::~PowerUI() { 243 PowerUI::~PowerUI() {
242 } 244 }
243 245
244 } // namespace chromeos 246 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/chromeos/network_ui.cc ('k') | chrome/browser/ui/webui/chromeos/proxy_settings_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698