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

Unified Diff: ash/system/chromeos/network/tray_network.cc

Issue 811623002: Add logging for slow device events, limit network UI update rate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@patch_441650
Patch Set: Feedback Created 6 years 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 side-by-side diff with in-line comments
Download patch
Index: ash/system/chromeos/network/tray_network.cc
diff --git a/ash/system/chromeos/network/tray_network.cc b/ash/system/chromeos/network/tray_network.cc
index a5c5570f499ef339b74e61f577f811a15e606f6d..b00e220cfb74d2c2142592608b5021ce24a577c9 100644
--- a/ash/system/chromeos/network/tray_network.cc
+++ b/ash/system/chromeos/network/tray_network.cc
@@ -47,8 +47,7 @@ class NetworkTrayView : public TrayItemView,
public ui::network_icon::AnimationObserver {
public:
explicit NetworkTrayView(TrayNetwork* network_tray)
- : TrayItemView(network_tray),
- network_tray_(network_tray) {
+ : TrayItemView(network_tray), network_tray_(network_tray) {
SetLayoutManager(
new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0));
@@ -58,13 +57,11 @@ class NetworkTrayView : public TrayItemView,
UpdateNetworkStateHandlerIcon();
}
- virtual ~NetworkTrayView() {
+ ~NetworkTrayView() override {
ui::network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this);
}
- virtual const char* GetClassName() const override {
- return "NetworkTrayView";
- }
+ const char* GetClassName() const override { return "NetworkTrayView"; }
void UpdateNetworkStateHandlerIcon() {
NetworkStateHandler* handler =
@@ -85,31 +82,29 @@ class NetworkTrayView : public TrayItemView,
const NetworkState* connected_network =
handler->ConnectedNetworkByType(NetworkTypePattern::NonVirtual());
if (connected_network) {
- UpdateConnectionStatus(
- base::UTF8ToUTF16(connected_network->name()), true);
+ UpdateConnectionStatus(base::UTF8ToUTF16(connected_network->name()),
+ true);
} else {
UpdateConnectionStatus(base::string16(), false);
}
}
void UpdateAlignment(ShelfAlignment alignment) {
- SetLayoutManager(new views::BoxLayout(
- alignment == SHELF_ALIGNMENT_BOTTOM ?
- views::BoxLayout::kHorizontal : views::BoxLayout::kVertical,
- 0, 0, 0));
+ SetLayoutManager(new views::BoxLayout(alignment == SHELF_ALIGNMENT_BOTTOM
+ ? views::BoxLayout::kHorizontal
+ : views::BoxLayout::kVertical,
+ 0, 0, 0));
Layout();
}
// views::View override.
- virtual void GetAccessibleState(ui::AXViewState* state) override {
+ void GetAccessibleState(ui::AXViewState* state) override {
state->name = connection_status_string_;
state->role = ui::AX_ROLE_BUTTON;
}
// ui::network_icon::AnimationObserver
- virtual void NetworkIconChanged() override {
- UpdateNetworkStateHandlerIcon();
- }
+ void NetworkIconChanged() override { UpdateNetworkStateHandlerIcon(); }
private:
// Updates connection status and notifies accessibility event when necessary.
@@ -122,7 +117,7 @@ class NetworkTrayView : public TrayItemView,
}
if (new_connection_status_string != connection_status_string_) {
connection_status_string_ = new_connection_status_string;
- if(!connection_status_string_.empty())
+ if (!connection_status_string_.empty())
NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true);
}
}
@@ -144,12 +139,11 @@ class NetworkDefaultView : public TrayItemMore,
public ui::network_icon::AnimationObserver {
public:
NetworkDefaultView(TrayNetwork* network_tray, bool show_more)
- : TrayItemMore(network_tray, show_more),
- network_tray_(network_tray) {
+ : TrayItemMore(network_tray, show_more), network_tray_(network_tray) {
Update();
}
- virtual ~NetworkDefaultView() {
+ ~NetworkDefaultView() override {
ui::network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this);
}
@@ -170,9 +164,7 @@ class NetworkDefaultView : public TrayItemMore,
}
// ui::network_icon::AnimationObserver
- virtual void NetworkIconChanged() override {
- Update();
- }
+ void NetworkIconChanged() override { Update(); }
private:
TrayNetwork* network_tray_;
@@ -185,8 +177,7 @@ class NetworkWifiDetailedView : public NetworkDetailedView {
explicit NetworkWifiDetailedView(SystemTrayItem* owner)
: NetworkDetailedView(owner) {
SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal,
- kTrayPopupPaddingHorizontal,
- 10,
+ kTrayPopupPaddingHorizontal, 10,
kTrayPopupPaddingBetweenItems));
image_view_ = new views::ImageView;
AddChildView(image_view_);
@@ -199,58 +190,44 @@ class NetworkWifiDetailedView : public NetworkDetailedView {
Update();
}
- virtual ~NetworkWifiDetailedView() {
- }
+ ~NetworkWifiDetailedView() override {}
// Overridden from NetworkDetailedView:
- virtual void Init() override {
- }
+ void Init() override {}
- virtual NetworkDetailedView::DetailedViewType GetViewType() const override {
+ NetworkDetailedView::DetailedViewType GetViewType() const override {
return NetworkDetailedView::WIFI_VIEW;
}
- virtual void ManagerChanged() override {
- Update();
- }
-
- virtual void NetworkListChanged() override {
- Update();
- }
-
- virtual void NetworkServiceChanged(
- const chromeos::NetworkState* network) override {
- }
-
- private:
- virtual void Layout() override {
+ void Layout() override {
// Center both views vertically.
views::View::Layout();
- image_view_->SetY(
- (height() - image_view_->GetPreferredSize().height()) / 2);
- label_view_->SetY(
- (height() - label_view_->GetPreferredSize().height()) / 2);
+ image_view_->SetY((height() - image_view_->GetPreferredSize().height()) /
+ 2);
+ label_view_->SetY((height() - label_view_->GetPreferredSize().height()) /
+ 2);
}
- void Update() {
+ void Update() override {
bool wifi_enabled =
NetworkHandler::Get()->network_state_handler()->IsTechnologyEnabled(
NetworkTypePattern::WiFi());
- const int image_id = wifi_enabled ?
- IDR_AURA_UBER_TRAY_WIFI_ENABLED : IDR_AURA_UBER_TRAY_WIFI_DISABLED;
+ const int image_id = wifi_enabled ? IDR_AURA_UBER_TRAY_WIFI_ENABLED
+ : IDR_AURA_UBER_TRAY_WIFI_DISABLED;
ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
image_view_->SetImage(bundle.GetImageNamed(image_id).ToImageSkia());
- const int string_id = wifi_enabled ?
- IDS_ASH_STATUS_TRAY_NETWORK_WIFI_ENABLED :
- IDS_ASH_STATUS_TRAY_NETWORK_WIFI_DISABLED;
+ const int string_id = wifi_enabled
+ ? IDS_ASH_STATUS_TRAY_NETWORK_WIFI_ENABLED
+ : IDS_ASH_STATUS_TRAY_NETWORK_WIFI_DISABLED;
label_view_->SetText(bundle.GetLocalizedString(string_id));
- label_view_->SizeToFit(kTrayPopupMinWidth -
- kTrayPopupPaddingHorizontal * 2 - kTrayPopupPaddingBetweenItems -
- kTrayPopupDetailsIconWidth);
+ label_view_->SizeToFit(
+ kTrayPopupMinWidth - kTrayPopupPaddingHorizontal * 2 -
+ kTrayPopupPaddingBetweenItems - kTrayPopupDetailsIconWidth);
}
+ private:
views::ImageView* image_view_;
views::Label* label_view_;
@@ -290,15 +267,15 @@ views::View* TrayNetwork::CreateDefaultView(user::LoginStatus status) {
if (!chromeos::NetworkHandler::IsInitialized())
return NULL;
CHECK(tray_ != NULL);
- default_ = new tray::NetworkDefaultView(
- this, status != user::LOGGED_IN_LOCKED);
+ default_ =
+ new tray::NetworkDefaultView(this, status != user::LOGGED_IN_LOCKED);
return default_;
}
views::View* TrayNetwork::CreateDetailedView(user::LoginStatus status) {
CHECK(detailed_ == NULL);
Shell::GetInstance()->metrics()->RecordUserMetricsAction(
- ash::UMA_STATUS_AREA_DETAILED_NETWORK_VIEW);
+ ash::UMA_STATUS_AREA_DETAILED_NETWORK_VIEW);
if (!chromeos::NetworkHandler::IsInitialized())
return NULL;
if (request_wifi_view_) {
@@ -344,35 +321,24 @@ void TrayNetwork::RequestToggleWifi() {
NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler();
bool enabled = handler->IsTechnologyEnabled(NetworkTypePattern::WiFi());
Shell::GetInstance()->metrics()->RecordUserMetricsAction(
- enabled ?
- ash::UMA_STATUS_AREA_DISABLE_WIFI :
- ash::UMA_STATUS_AREA_ENABLE_WIFI);
- handler->SetTechnologyEnabled(NetworkTypePattern::WiFi(),
- !enabled,
+ enabled ? ash::UMA_STATUS_AREA_DISABLE_WIFI
+ : ash::UMA_STATUS_AREA_ENABLE_WIFI);
+ handler->SetTechnologyEnabled(NetworkTypePattern::WiFi(), !enabled,
chromeos::network_handler::ErrorCallback());
}
void TrayNetwork::OnCaptivePortalDetected(
const std::string& /* service_path */) {
- NetworkStateChanged(false);
+ NetworkStateChanged();
}
-void TrayNetwork::NetworkStateChanged(bool list_changed) {
+void TrayNetwork::NetworkStateChanged() {
if (tray_)
tray_->UpdateNetworkStateHandlerIcon();
if (default_)
default_->Update();
- if (detailed_) {
- if (list_changed)
- detailed_->NetworkListChanged();
- else
- detailed_->ManagerChanged();
- }
-}
-
-void TrayNetwork::NetworkServiceChanged(const chromeos::NetworkState* network) {
if (detailed_)
- detailed_->NetworkServiceChanged(network);
+ detailed_->Update();
}
} // namespace ash
« no previous file with comments | « ash/system/chromeos/network/tray_network.h ('k') | ash/system/chromeos/network/tray_network_state_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698