| 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 ServiceList and ServiceListItem, served from | 6 * Javascript for ServiceList and ServiceListItem, served from |
| 7 * chrome://bluetooth-internals/. | 7 * chrome://bluetooth-internals/. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 cr.define('service_list', function() { | 10 cr.define('service_list', function() { |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 * exists, one is created. | 140 * exists, one is created. |
| 141 * @param {string} deviceAddress | 141 * @param {string} deviceAddress |
| 142 */ | 142 */ |
| 143 load: function(deviceAddress) { | 143 load: function(deviceAddress) { |
| 144 if (this.servicesRequested_ || !this.isSpinnerShowing()) | 144 if (this.servicesRequested_ || !this.isSpinnerShowing()) |
| 145 return; | 145 return; |
| 146 | 146 |
| 147 this.deviceAddress_ = deviceAddress; | 147 this.deviceAddress_ = deviceAddress; |
| 148 this.servicesRequested_ = true; | 148 this.servicesRequested_ = true; |
| 149 | 149 |
| 150 device_broker.connectToDevice(this.deviceAddress_).then( | 150 device_broker.connectToDevice(this.deviceAddress_) |
| 151 function(device) { | 151 .then(function(device) { |
| 152 return device.getServices(); | 152 return device.getServices(); |
| 153 }.bind(this)).then(function(response) { | 153 }.bind(this)) |
| 154 .then(function(response) { |
| 154 this.setData(new ArrayDataModel(response.services)); | 155 this.setData(new ArrayDataModel(response.services)); |
| 155 this.setSpinnerShowing(false); | 156 this.setSpinnerShowing(false); |
| 156 this.servicesRequested_ = false; | 157 this.servicesRequested_ = false; |
| 157 }.bind(this)).catch(function(error) { | 158 }.bind(this)) |
| 159 .catch(function(error) { |
| 158 this.servicesRequested_ = false; | 160 this.servicesRequested_ = false; |
| 159 Snackbar.show( | 161 Snackbar.show( |
| 160 deviceAddress + ': ' + error.message, SnackbarType.ERROR, | 162 deviceAddress + ': ' + error.message, SnackbarType.ERROR, |
| 161 'Retry', function() { this.load(deviceAddress); }.bind(this)); | 163 'Retry', function() { |
| 164 this.load(deviceAddress); |
| 165 }.bind(this)); |
| 162 }.bind(this)); | 166 }.bind(this)); |
| 163 }, | 167 }, |
| 164 }; | 168 }; |
| 165 | 169 |
| 166 return { | 170 return { |
| 167 ServiceList: ServiceList, | 171 ServiceList: ServiceList, |
| 168 ServiceListItem: ServiceListItem, | 172 ServiceListItem: ServiceListItem, |
| 169 }; | 173 }; |
| 170 }); | 174 }); |
| OLD | NEW |