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