| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 /** | 5 /** |
| 6 * Javascript for CharacteristicList and CharacteristicListItem, served from | 6 * Javascript for CharacteristicList and CharacteristicListItem, served from |
| 7 * chrome://bluetooth-internals/. | 7 * chrome://bluetooth-internals/. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 cr.define('characteristic_list', function() { | 10 cr.define('characteristic_list', function() { |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 */ | 175 */ |
| 176 load: function(deviceAddress, serviceId) { | 176 load: function(deviceAddress, serviceId) { |
| 177 if (this.characteristicsRequested_ || !this.isLoading()) | 177 if (this.characteristicsRequested_ || !this.isLoading()) |
| 178 return; | 178 return; |
| 179 | 179 |
| 180 this.characteristicsRequested_ = true; | 180 this.characteristicsRequested_ = true; |
| 181 | 181 |
| 182 device_broker.connectToDevice(deviceAddress).then(function(device) { | 182 device_broker.connectToDevice(deviceAddress).then(function(device) { |
| 183 return device.getCharacteristics(serviceId); | 183 return device.getCharacteristics(serviceId); |
| 184 }.bind(this)).then(function(response) { | 184 }.bind(this)).then(function(response) { |
| 185 this.setData(new ArrayDataModel(response.characteristics)); | 185 this.setData(new ArrayDataModel(response.characteristics || [])); |
| 186 this.setLoading(false); | 186 this.setLoading(false); |
| 187 this.characteristicsRequested_ = false; | 187 this.characteristicsRequested_ = false; |
| 188 }.bind(this)).catch(function(error) { | 188 }.bind(this)).catch(function(error) { |
| 189 this.characteristicsRequested_ = false; | 189 this.characteristicsRequested_ = false; |
| 190 Snackbar.show( | 190 Snackbar.show( |
| 191 deviceAddress + ': ' + error.message, SnackbarType.ERROR, 'Retry', | 191 deviceAddress + ': ' + error.message, SnackbarType.ERROR, 'Retry', |
| 192 function() { | 192 function() { |
| 193 this.load(deviceAddress, serviceId); | 193 this.load(deviceAddress, serviceId); |
| 194 }.bind(this)); | 194 }.bind(this)); |
| 195 }.bind(this)); | 195 }.bind(this)); |
| 196 }, | 196 }, |
| 197 }; | 197 }; |
| 198 | 198 |
| 199 return { | 199 return { |
| 200 CharacteristicList: CharacteristicList, | 200 CharacteristicList: CharacteristicList, |
| 201 CharacteristicListItem: CharacteristicListItem, | 201 CharacteristicListItem: CharacteristicListItem, |
| 202 }; | 202 }; |
| 203 }); | 203 }); |
| OLD | NEW |