| 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  * Class to handle changes to auto-scan. |    6  * Class to handle changes to auto-scan. | 
|    7  * |    7  * | 
|    8  * @constructor |    8  * @constructor | 
|    9  * @param {SwitchAccessInterface} switchAccess |    9  * @param {SwitchAccessInterface} switchAccess | 
|   10  */ |   10  */ | 
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   60   /** |   60   /** | 
|   61    * Return true if auto-scan is currently running. Otherwise return false. |   61    * Return true if auto-scan is currently running. Otherwise return false. | 
|   62    * |   62    * | 
|   63    * @return {boolean} |   63    * @return {boolean} | 
|   64    */ |   64    */ | 
|   65   isRunning: function() { |   65   isRunning: function() { | 
|   66     return this.intervalID_ !== undefined; |   66     return this.intervalID_ !== undefined; | 
|   67   }, |   67   }, | 
|   68  |   68  | 
|   69   /** |   69   /** | 
|   70    * Restart auto-scan under the current settings. |   70    * Restart auto-scan under the current settings if it is currently running. | 
|   71    */ |   71    */ | 
|   72   restart: function() { |   72   restartIfRunning: function() { | 
|   73     this.stop_(); |   73     if (this.isRunning()) { | 
|   74     this.start_(); |   74       this.stop_(); | 
 |   75       this.start_(); | 
 |   76     } | 
|   75   }, |   77   }, | 
|   76  |   78  | 
|   77   /** |   79   /** | 
|   78    * Stop auto-scan if it is currently running. Then, if |enabled| is true, |   80    * Stop auto-scan if it is currently running. Then, if |enabled| is true, | 
|   79    * turn on auto-scan. Otherwise leave it off. |   81    * turn on auto-scan. Otherwise leave it off. | 
|   80    * |   82    * | 
|   81    * @param {boolean} enabled |   83    * @param {boolean} enabled | 
|   82    */ |   84    */ | 
|   83   setEnabled: function(enabled) { |   85   setEnabled: function(enabled) { | 
|   84     if (this.isRunning()) |   86     if (this.isRunning()) | 
|   85       this.stop_(); |   87       this.stop_(); | 
|   86     if (enabled) |   88     if (enabled) | 
|   87       this.start_(); |   89       this.start_(); | 
|   88   }, |   90   }, | 
|   89  |   91  | 
|   90   /** |   92   /** | 
|   91    * Update this.scanTime_ to |scanTime|. Then, if auto-scan is currently |   93    * Update this.scanTime_ to |scanTime|. Then, if auto-scan is currently | 
|   92    * running, restart it. |   94    * running, restart it. | 
|   93    * |   95    * | 
|   94    * @param {number} scanTime Auto-scan interval time in milliseconds. |   96    * @param {number} scanTime Auto-scan interval time in milliseconds. | 
|   95    */ |   97    */ | 
|   96   setScanTime: function(scanTime) { |   98   setScanTime: function(scanTime) { | 
|   97     this.scanTime_ = scanTime; |   99     this.scanTime_ = scanTime; | 
|   98     if (this.isRunning()) { |  100     this.restartIfRunning(); | 
|   99       this.restart(); |  | 
|  100     } |  | 
|  101   }, |  101   }, | 
|  102 }; |  102 }; | 
| OLD | NEW |