tor-browser

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

TestInterfaceAsyncIterableDoubleUnion.h (2237B)


      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_TestInterfaceAsyncIterableDoubleUnion_h
      8 #define mozilla_dom_TestInterfaceAsyncIterableDoubleUnion_h
      9 
     10 #include "IterableIterator.h"
     11 #include "mozilla/dom/TestInterfaceJSMaplikeSetlikeIterableBinding.h"
     12 #include "nsCOMPtr.h"
     13 #include "nsWrapperCache.h"
     14 
     15 class nsPIDOMWindowInner;
     16 
     17 namespace mozilla {
     18 
     19 class ErrorResult;
     20 
     21 namespace dom {
     22 
     23 class GlobalObject;
     24 
     25 // Implementation of test binding for webidl iterable interfaces, using
     26 // primitives for value type
     27 class TestInterfaceAsyncIterableDoubleUnion final : public nsISupports,
     28                                                    public nsWrapperCache {
     29 public:
     30  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
     31  NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(
     32      TestInterfaceAsyncIterableDoubleUnion)
     33 
     34  explicit TestInterfaceAsyncIterableDoubleUnion(nsPIDOMWindowInner* aParent);
     35  nsPIDOMWindowInner* GetParentObject() const;
     36  virtual JSObject* WrapObject(JSContext* aCx,
     37                               JS::Handle<JSObject*> aGivenProto) override;
     38  static already_AddRefed<TestInterfaceAsyncIterableDoubleUnion> Constructor(
     39      const GlobalObject& aGlobal, ErrorResult& rv);
     40 
     41  struct IteratorData {
     42    uint32_t mIndex = 0;
     43  };
     44 
     45  using Iterator = AsyncIterableIterator<TestInterfaceAsyncIterableDoubleUnion>;
     46 
     47  void InitAsyncIteratorData(IteratorData& aData, Iterator::IteratorType aType,
     48                             ErrorResult& aError) {}
     49 
     50  already_AddRefed<Promise> GetNextIterationResult(Iterator* aIterator,
     51                                                   ErrorResult& aRv);
     52 
     53 private:
     54  virtual ~TestInterfaceAsyncIterableDoubleUnion() = default;
     55  void ResolvePromise(Iterator* aIterator, Promise* aPromise);
     56 
     57  nsCOMPtr<nsPIDOMWindowInner> mParent;
     58  nsTArray<std::pair<nsString, OwningStringOrLong>> mValues;
     59 };
     60 
     61 }  // namespace dom
     62 }  // namespace mozilla
     63 
     64 #endif  // mozilla_dom_TestInterfaceAsyncIterableDoubleUnion_h