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 "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 <memory> |
9 #include <utility> | 10 #include <utility> |
10 | 11 |
11 #include "base/bind.h" | 12 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
13 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
14 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
15 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
16 #include "base/time/time.h" | 17 #include "base/time/time.h" |
17 #include "base/values.h" | 18 #include "base/values.h" |
18 #include "chrome/browser/chromeos/power/power_data_collector.h" | 19 #include "chrome/browser/chromeos/power/power_data_collector.h" |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 new base::DictionaryValue); | 171 new base::DictionaryValue); |
171 js_sample->SetDouble("time", sample.time.ToJsTime()); | 172 js_sample->SetDouble("time", sample.time.ToJsTime()); |
172 js_sample->SetBoolean("cpuOnline", sample.cpu_online); | 173 js_sample->SetBoolean("cpuOnline", sample.cpu_online); |
173 | 174 |
174 std::unique_ptr<base::DictionaryValue> state_dict( | 175 std::unique_ptr<base::DictionaryValue> state_dict( |
175 new base::DictionaryValue); | 176 new base::DictionaryValue); |
176 for (size_t index = 0; index < sample.time_in_state.size(); ++index) { | 177 for (size_t index = 0; index < sample.time_in_state.size(); ++index) { |
177 state_dict->SetDouble(state_names[index], | 178 state_dict->SetDouble(state_names[index], |
178 static_cast<double>(sample.time_in_state[index])); | 179 static_cast<double>(sample.time_in_state[index])); |
179 } | 180 } |
180 js_sample->Set("timeInState", state_dict.release()); | 181 js_sample->Set("timeInState", std::move(state_dict)); |
181 | 182 |
182 js_sample_list->Append(std::move(js_sample)); | 183 js_sample_list->Append(std::move(js_sample)); |
183 } | 184 } |
184 js_data->Append(std::move(js_sample_list)); | 185 js_data->Append(std::move(js_sample_list)); |
185 } | 186 } |
186 } | 187 } |
187 | 188 |
188 } // namespace | 189 } // namespace |
189 | 190 |
190 PowerUI::PowerUI(content::WebUI* web_ui) : content::WebUIController(web_ui) { | 191 PowerUI::PowerUI(content::WebUI* web_ui) : content::WebUIController(web_ui) { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 html->SetDefaultResource(IDR_ABOUT_POWER_HTML); | 239 html->SetDefaultResource(IDR_ABOUT_POWER_HTML); |
239 | 240 |
240 Profile* profile = Profile::FromWebUI(web_ui); | 241 Profile* profile = Profile::FromWebUI(web_ui); |
241 content::WebUIDataSource::Add(profile, html); | 242 content::WebUIDataSource::Add(profile, html); |
242 } | 243 } |
243 | 244 |
244 PowerUI::~PowerUI() { | 245 PowerUI::~PowerUI() { |
245 } | 246 } |
246 | 247 |
247 } // namespace chromeos | 248 } // namespace chromeos |
OLD | NEW |