OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 (function(global, binding, v8) { | 5 (function(global, binding, v8) { |
6 'use strict'; | 6 'use strict'; |
7 | 7 |
8 const defineProperty = global.Object.defineProperty; | 8 const defineProperty = global.Object.defineProperty; |
9 | 9 |
10 class CountQueuingStrategy { | 10 class CountQueuingStrategy { |
11 constructor(options) { | 11 constructor(options) { |
12 defineProperty(this, 'highWaterMark', { | 12 defineProperty(this, 'highWaterMark', { |
13 value: options.highWaterMark, | 13 value: options.highWaterMark, |
14 enumerable: true, | 14 enumerable: true, |
15 configurable: true, | 15 configurable: true, |
16 writable: true | 16 writable: true |
17 }); | 17 }); |
18 } | 18 } |
| 19 |
19 size(chunk) { return 1; } | 20 size(chunk) { return 1; } |
20 } | 21 } |
21 | 22 |
22 defineProperty(global, 'CountQueuingStrategy', { | 23 defineProperty(global, 'CountQueuingStrategy', { |
23 value: CountQueuingStrategy, | 24 value: CountQueuingStrategy, |
24 enumerable: false, | 25 enumerable: false, |
25 configurable: true, | 26 configurable: true, |
26 writable: true | 27 writable: true |
27 }); | 28 }); |
| 29 |
| 30 // Export a separate copy that doesn't need options objects and can't be |
| 31 // interfered with. |
| 32 class BuiltInCountQueuingStrategy { |
| 33 constructor(highWaterMark) { |
| 34 defineProperty(this, 'highWaterMark', {value: highWaterMark}); |
| 35 } |
| 36 |
| 37 size(chunk) { return 1; } |
| 38 } |
| 39 |
| 40 binding.createBuiltInCountQueuingStrategy = highWaterMark => |
| 41 new BuiltInCountQueuingStrategy(highWaterMark); |
28 }); | 42 }); |
OLD | NEW |