tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

TestInterfaceAsyncIterableSingleWithArgs.h (2446B)


      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 #ifndef mozilla_dom_TestInterfaceAsyncIterableSingleWithArgs_h
      8 #define mozilla_dom_TestInterfaceAsyncIterableSingleWithArgs_h
      9 
     10 #include "mozilla/dom/TestInterfaceAsyncIterableSingle.h"
     11 
     12 namespace mozilla::dom {
     13 
     14 struct TestInterfaceAsyncIteratorOptions;
     15 
     16 // Implementation of test binding for webidl iterable interfaces, using
     17 // primitives for value type
     18 class TestInterfaceAsyncIterableSingleWithArgs final
     19    : public TestInterfaceAsyncIterableSingle {
     20 public:
     21  NS_DECL_ISUPPORTS_INHERITED
     22  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(
     23      TestInterfaceAsyncIterableSingleWithArgs,
     24      TestInterfaceAsyncIterableSingle)
     25 
     26  using TestInterfaceAsyncIterableSingle::TestInterfaceAsyncIterableSingle;
     27  virtual JSObject* WrapObject(JSContext* aCx,
     28                               JS::Handle<JSObject*> aGivenProto) override;
     29  static already_AddRefed<TestInterfaceAsyncIterableSingleWithArgs> Constructor(
     30      const GlobalObject& aGlobal, ErrorResult& rv);
     31 
     32  using Iterator =
     33      AsyncIterableIterator<TestInterfaceAsyncIterableSingleWithArgs>;
     34 
     35  void InitAsyncIteratorData(IteratorData& aData, Iterator::IteratorType aType,
     36                             const TestInterfaceAsyncIteratorOptions& aOptions,
     37                             ErrorResult& aError);
     38 
     39  already_AddRefed<Promise> GetNextIterationResult(
     40      Iterator* aIterator, ErrorResult& aRv) MOZ_CAN_RUN_SCRIPT;
     41  already_AddRefed<Promise> IteratorReturn(JSContext* aCx, Iterator* aIterator,
     42                                           JS::Handle<JS::Value> aValue,
     43                                           ErrorResult& aRv) MOZ_CAN_RUN_SCRIPT;
     44 
     45  uint32_t ReturnCallCount() { return mReturnCallCount; }
     46  void GetReturnLastCalledWith(JSContext* aCx,
     47                               JS::MutableHandle<JS::Value> aReturnCalledWith) {
     48    aReturnCalledWith.set(mReturnLastCalledWith);
     49  }
     50 
     51 private:
     52  ~TestInterfaceAsyncIterableSingleWithArgs() = default;
     53 
     54  JS::Heap<JS::Value> mReturnLastCalledWith;
     55  uint32_t mReturnCallCount = 0;
     56 };
     57 
     58 }  // namespace mozilla::dom
     59 
     60 #endif  // mozilla_dom_TestInterfaceAsyncIterableSingleWithArgs_h