tor-browser

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

mozStorageAsyncStatementParams.h (2269B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
      2 * vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ :
      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_storage_mozStorageAsyncStatementParams_h_
      8 #define mozilla_storage_mozStorageAsyncStatementParams_h_
      9 
     10 #include "nsPIDOMWindow.h"
     11 #include "nsWrapperCache.h"
     12 
     13 namespace mozilla {
     14 class ErrorResult;
     15 
     16 namespace storage {
     17 
     18 class AsyncStatement;
     19 
     20 class AsyncStatementParams final : public nsISupports, public nsWrapperCache {
     21 public:
     22  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
     23  NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(AsyncStatementParams)
     24 
     25  explicit AsyncStatementParams(nsPIDOMWindowInner* aWindow,
     26                                AsyncStatement* aStatement);
     27 
     28  void NamedGetter(JSContext* aCx, const nsAString& aName, bool& aFound,
     29                   JS::MutableHandle<JS::Value> aResult,
     30                   mozilla::ErrorResult& aRv);
     31 
     32  void NamedSetter(JSContext* aCx, const nsAString& aName,
     33                   JS::Handle<JS::Value> aValue, mozilla::ErrorResult& aRv);
     34 
     35  uint32_t Length() const {
     36    // WebIDL requires a .length property when there's an indexed getter.
     37    // Unfortunately we don't know how many params there are in the async case,
     38    // so we have to lie.
     39    return UINT16_MAX;
     40  }
     41 
     42  void IndexedGetter(JSContext* aCx, uint32_t aIndex, bool& aFound,
     43                     JS::MutableHandle<JS::Value> aResult,
     44                     mozilla::ErrorResult& aRv);
     45 
     46  void IndexedSetter(JSContext* aCx, uint32_t aIndex,
     47                     JS::Handle<JS::Value> aValue, mozilla::ErrorResult& aRv);
     48 
     49  void GetSupportedNames(nsTArray<nsString>& aNames);
     50 
     51  JSObject* WrapObject(JSContext* aCx,
     52                       JS::Handle<JSObject*> aGivenProto) override;
     53 
     54  nsPIDOMWindowInner* GetParentObject() const { return mWindow; }
     55 
     56 private:
     57  virtual ~AsyncStatementParams() {}
     58 
     59  nsCOMPtr<nsPIDOMWindowInner> mWindow;
     60  AsyncStatement* mStatement;
     61 
     62  friend class AsyncStatementParamsHolder;
     63 };
     64 
     65 }  // namespace storage
     66 }  // namespace mozilla
     67 
     68 #endif  // mozilla_storage_mozStorageAsyncStatementParams_h_