1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- 2 * vim: set ts=8 sts=2 et sw=2 tw=80: 3 * This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 /* Queuing strategies. */ 8 9 #ifndef builtin_stream_QueueingStrategies_h 10 #define builtin_stream_QueueingStrategies_h 11 12 #include "js/Class.h" // JSClass, js::ClassSpec 13 #include "js/Value.h" // JS::Value 14 #include "vm/JSContext.h" // JSContext 15 #include "vm/NativeObject.h" // js::NativeObject 16 17 namespace js { 18 19 class ByteLengthQueuingStrategy : public NativeObject { 20 public: 21 enum Slots { Slot_HighWaterMark, SlotCount }; 22 highWaterMark()23 double highWaterMark() const { 24 return getFixedSlot(Slot_HighWaterMark).toDouble(); 25 } setHighWaterMark(double value)26 void setHighWaterMark(double value) { 27 setFixedSlot(Slot_HighWaterMark, JS::DoubleValue(value)); 28 } 29 30 static bool constructor(JSContext* cx, unsigned argc, JS::Value* vp); 31 static const ClassSpec classSpec_; 32 static const JSClass class_; 33 static const ClassSpec protoClassSpec_; 34 static const JSClass protoClass_; 35 }; 36 37 class CountQueuingStrategy : public NativeObject { 38 public: 39 enum Slots { Slot_HighWaterMark, SlotCount }; 40 highWaterMark()41 double highWaterMark() const { 42 return getFixedSlot(Slot_HighWaterMark).toDouble(); 43 } setHighWaterMark(double value)44 void setHighWaterMark(double value) { 45 setFixedSlot(Slot_HighWaterMark, JS::DoubleValue(value)); 46 } 47 48 static bool constructor(JSContext* cx, unsigned argc, JS::Value* vp); 49 static const ClassSpec classSpec_; 50 static const JSClass class_; 51 static const ClassSpec protoClassSpec_; 52 static const JSClass protoClass_; 53 }; 54 55 } // namespace js 56 57 #endif // builtin_stream_QueueingStrategies_h 58