Commit b1abba97 authored by Steven Bennetts's avatar Steven Bennetts Committed by Commit Bot

Settings: Cellular: Improve active network updates

This change does two things:
1. Improves error handling to ignore InvalidNetworkGuid errors which
   may happen e.g. when a device is disabled.
2. Uses 'set' to property update an active network state and notify
   observers.

Bug: 781776
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I37e584870c63676a885d19167f1c2bdadf7be6b3
Reviewed-on: https://chromium-review.googlesource.com/804595Reviewed-by: default avatarBen Chan <benchan@chromium.org>
Commit-Queue: Steven Bennetts <stevenjb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521189}
parent 25c64bbe
......@@ -159,12 +159,13 @@ Polymer({
getActiveStateCallback_: function(id, state) {
if (chrome.runtime.lastError) {
var message = chrome.runtime.lastError.message;
if (message != 'Error.NetworkUnavailable') {
if (message != 'Error.NetworkUnavailable' &&
message != 'Error.InvalidNetworkGuid') {
console.error(
'Unexpected networkingPrivate.getState error: ' + message +
' For: ' + id);
return;
}
return;
}
// Async call, ensure id still exists.
if (!this.activeNetworkIds_.has(id))
......@@ -174,14 +175,12 @@ Polymer({
return;
}
// Find the active state for the type and update it.
for (var i = 0; i < this.activeNetworkStates_.length; ++i) {
if (this.activeNetworkStates_[i].type == state.type) {
this.activeNetworkStates_[i] = state;
return;
}
var idx = this.activeNetworkStates_.findIndex((s) => s.Type == state.Type);
if (idx == -1) {
console.error('Active state not found: ' + state.Name);
return;
}
// Not found
console.error('Active state not found: ' + state.Name);
this.set(['activeNetworkStates_', idx], state);
},
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment