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

Side by Side Diff: ash/common/system/chromeos/power/power_status_view.cc

Issue 2731463002: Adding logging to help determine why System Menu battery time isn't shown sometimes. (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/common/system/chromeos/power/power_status_view.h" 5 #include "ash/common/system/chromeos/power/power_status_view.h"
6 6
7 #include "ash/common/material_design/material_design_controller.h" 7 #include "ash/common/material_design/material_design_controller.h"
8 #include "ash/common/strings/grit/ash_strings.h" 8 #include "ash/common/strings/grit/ash_strings.h"
9 #include "ash/common/system/chromeos/power/power_status.h" 9 #include "ash/common/system/chromeos/power/power_status.h"
10 #include "ash/common/system/chromeos/power/tray_power.h" 10 #include "ash/common/system/chromeos/power/tray_power.h"
11 #include "ash/common/system/tray/fixed_sized_image_view.h" 11 #include "ash/common/system/tray/fixed_sized_image_view.h"
12 #include "ash/common/system/tray/tray_constants.h" 12 #include "ash/common/system/tray/tray_constants.h"
13 #include "ash/common/system/tray/tray_popup_item_style.h" 13 #include "ash/common/system/tray/tray_popup_item_style.h"
14 #include "ash/common/system/tray/tray_popup_utils.h" 14 #include "ash/common/system/tray/tray_popup_utils.h"
15 #include "base/i18n/number_formatting.h" 15 #include "base/i18n/number_formatting.h"
16 #include "base/i18n/time_formatting.h" 16 #include "base/i18n/time_formatting.h"
17 #include "base/logging.h"
17 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
18 #include "ui/accessibility/ax_node_data.h" 19 #include "ui/accessibility/ax_node_data.h"
19 #include "ui/base/l10n/l10n_util.h" 20 #include "ui/base/l10n/l10n_util.h"
20 #include "ui/native_theme/native_theme.h" 21 #include "ui/native_theme/native_theme.h"
21 #include "ui/views/controls/image_view.h" 22 #include "ui/views/controls/image_view.h"
22 #include "ui/views/controls/label.h" 23 #include "ui/views/controls/label.h"
23 #include "ui/views/layout/box_layout.h" 24 #include "ui/views/layout/box_layout.h"
24 #include "ui/views/layout/grid_layout.h" 25 #include "ui/views/layout/grid_layout.h"
25 26
26 namespace ash { 27 namespace ash {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 if (status.IsUsbChargerConnected()) { 116 if (status.IsUsbChargerConnected()) {
116 battery_time_status = l10n_util::GetStringUTF16( 117 battery_time_status = l10n_util::GetStringUTF16(
117 IDS_ASH_STATUS_TRAY_BATTERY_CHARGING_UNRELIABLE); 118 IDS_ASH_STATUS_TRAY_BATTERY_CHARGING_UNRELIABLE);
118 } else if (status.IsBatteryTimeBeingCalculated()) { 119 } else if (status.IsBatteryTimeBeingCalculated()) {
119 battery_time_status = 120 battery_time_status =
120 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_BATTERY_CALCULATING); 121 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_BATTERY_CALCULATING);
121 } else { 122 } else {
122 base::TimeDelta time = status.IsBatteryCharging() 123 base::TimeDelta time = status.IsBatteryCharging()
123 ? status.GetBatteryTimeToFull() 124 ? status.GetBatteryTimeToFull()
124 : status.GetBatteryTimeToEmpty(); 125 : status.GetBatteryTimeToEmpty();
126 bool should_warn = false;
125 if (PowerStatus::ShouldDisplayBatteryTime(time) && 127 if (PowerStatus::ShouldDisplayBatteryTime(time) &&
126 !status.IsBatteryDischargingOnLinePower()) { 128 !status.IsBatteryDischargingOnLinePower()) {
127 battery_time_status = l10n_util::GetStringFUTF16( 129 battery_time_status = l10n_util::GetStringFUTF16(
128 status.IsBatteryCharging() 130 status.IsBatteryCharging()
129 ? IDS_ASH_STATUS_TRAY_BATTERY_TIME_UNTIL_FULL_SHORT 131 ? IDS_ASH_STATUS_TRAY_BATTERY_TIME_UNTIL_FULL_SHORT
130 : IDS_ASH_STATUS_TRAY_BATTERY_TIME_LEFT_SHORT, 132 : IDS_ASH_STATUS_TRAY_BATTERY_TIME_LEFT_SHORT,
131 TimeDurationFormat(time, base::DURATION_WIDTH_NUMERIC)); 133 TimeDurationFormat(time, base::DURATION_WIDTH_NUMERIC));
Daniel Erat 2017/03/02 17:07:09 since (i think) what we really want to figure out
134
135 should_warn = battery_time_status.empty();
136 } else {
137 should_warn = true;
Daniel Erat 2017/03/02 14:38:11 why do you want to warn in this case?
bruthig 2017/03/02 15:23:35 I thought just showing the '%', like in comment #2
Daniel Erat 2017/03/02 17:07:09 hmm... it's definitely expected to happen when the
138 }
139
140 if (should_warn) {
141 DCHECK(false)
bruthig 2017/03/02 05:08:06 This might be a little too aggressive given it is
Daniel Erat 2017/03/02 17:07:09 definitely too aggressive. :-)
142 << "Please submit feedback, including logs for issue 677043.";
143 // Capturing more info to determine why the remaining battery time is
144 // sometimes not visible, see https://crbug.com/677043.
145 if (status.IsBatteryCharging())
146 LOG(WARNING) << "Time to full: " << time.InMilliseconds();
147 else
148 LOG(WARNING) << "Time to empty: " << time.InMilliseconds();
Daniel Erat 2017/03/02 14:38:11 can't we already see the values that powerd sent t
bruthig 2017/03/02 15:23:35 I'm not familiar with the other logging, but we pr
149 LOG(WARNING) << "ShouldDisplayBatteryTime(time)="
150 << PowerStatus::ShouldDisplayBatteryTime(time);
151 LOG(WARNING) << "IsBatteryDischargingOnLinePower()="
152 << status.IsBatteryDischargingOnLinePower();
132 } 153 }
133 } 154 }
134 } 155 }
135 percentage_label_->SetVisible(!battery_percentage.empty()); 156 percentage_label_->SetVisible(!battery_percentage.empty());
136 percentage_label_->SetText(battery_percentage); 157 percentage_label_->SetText(battery_percentage);
137 separator_label_->SetVisible(!battery_percentage.empty() && 158 separator_label_->SetVisible(!battery_percentage.empty() &&
138 !battery_time_status.empty()); 159 !battery_time_status.empty());
139 time_status_label_->SetVisible(!battery_time_status.empty()); 160 time_status_label_->SetVisible(!battery_time_status.empty());
140 time_status_label_->SetText(battery_time_status); 161 time_status_label_->SetText(battery_time_status);
141 162
(...skipping 13 matching lines...) Expand all
155 176
156 void PowerStatusView::Layout() { 177 void PowerStatusView::Layout() {
157 views::View::Layout(); 178 views::View::Layout();
158 179
159 // Move the time_status_label_, separator_label_, and percentage_label_ 180 // Move the time_status_label_, separator_label_, and percentage_label_
160 // closer to each other. 181 // closer to each other.
161 if (percentage_label_ && separator_label_ && time_status_label_ && 182 if (percentage_label_ && separator_label_ && time_status_label_ &&
162 percentage_label_->visible() && time_status_label_->visible()) { 183 percentage_label_->visible() && time_status_label_->visible()) {
163 separator_label_->SetX(percentage_label_->bounds().right() + 1); 184 separator_label_->SetX(percentage_label_->bounds().right() + 1);
164 time_status_label_->SetX(separator_label_->bounds().right() + 1); 185 time_status_label_->SetX(separator_label_->bounds().right() + 1);
186
187 // Capturing more info to determine why the remaining battery time infos
188 // sometimes not visible, see https://crbug.com/677043.
189 if (time_status_label_->x() < 0 ||
190 time_status_label_->x() > bounds().right()) {
191 LOG(WARNING) << "time_status_label_.x(): " << time_status_label_->x();
192 }
165 } 193 }
166 } 194 }
167 195
168 void PowerStatusView::GetAccessibleNodeData(ui::AXNodeData* node_data) { 196 void PowerStatusView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
169 if (!MaterialDesignController::IsSystemTrayMenuMaterial()) 197 if (!MaterialDesignController::IsSystemTrayMenuMaterial())
170 return; 198 return;
171 199
172 node_data->role = ui::AX_ROLE_LABEL_TEXT; 200 node_data->role = ui::AX_ROLE_LABEL_TEXT;
173 node_data->SetName(accessible_name_); 201 node_data->SetName(accessible_name_);
174 } 202 }
175 203
176 } // namespace ash 204 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698