(delay)
| 30 | } |
| 31 | |
| 32 | setTimeout(delay) { |
| 33 | if (this._state !== ResourceRequest.PENDING) { |
| 34 | return; |
| 35 | } |
| 36 | const ttl = parseInt(delay, 10); |
| 37 | |
| 38 | if (isNaN(ttl) || ttl <= 0) { |
| 39 | throw new Error("delay must be a positive int"); |
| 40 | } |
| 41 | |
| 42 | const age = Date.now() - this._creationTimestamp; |
| 43 | |
| 44 | if (this._timeout) { |
| 45 | this.removeTimeout(); |
| 46 | } |
| 47 | |
| 48 | this._timeout = setTimeout( |
| 49 | fbind(this._fireTimeout, this), |
| 50 | Math.max(ttl - age, 0) |
| 51 | ); |
| 52 | } |
| 53 | |
| 54 | removeTimeout() { |
| 55 | if (this._timeout) { |
no test coverage detected