tor-browser

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

TestInterfaceMaplike.cpp (2542B)


      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 file,
      5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #include "mozilla/dom/TestInterfaceMaplike.h"
      8 
      9 #include "mozilla/dom/BindingUtils.h"
     10 #include "mozilla/dom/TestInterfaceJSMaplikeSetlikeIterableBinding.h"
     11 #include "nsPIDOMWindow.h"
     12 
     13 namespace mozilla::dom {
     14 
     15 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(TestInterfaceMaplike, mParent)
     16 
     17 NS_IMPL_CYCLE_COLLECTING_ADDREF(TestInterfaceMaplike)
     18 NS_IMPL_CYCLE_COLLECTING_RELEASE(TestInterfaceMaplike)
     19 
     20 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TestInterfaceMaplike)
     21  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
     22  NS_INTERFACE_MAP_ENTRY(nsISupports)
     23 NS_INTERFACE_MAP_END
     24 
     25 TestInterfaceMaplike::TestInterfaceMaplike(nsPIDOMWindowInner* aParent)
     26    : mParent(aParent) {}
     27 
     28 // static
     29 already_AddRefed<TestInterfaceMaplike> TestInterfaceMaplike::Constructor(
     30    const GlobalObject& aGlobal, ErrorResult& aRv) {
     31  nsCOMPtr<nsPIDOMWindowInner> window =
     32      do_QueryInterface(aGlobal.GetAsSupports());
     33  if (!window) {
     34    aRv.Throw(NS_ERROR_FAILURE);
     35    return nullptr;
     36  }
     37 
     38  RefPtr<TestInterfaceMaplike> r = new TestInterfaceMaplike(window);
     39  return r.forget();
     40 }
     41 
     42 JSObject* TestInterfaceMaplike::WrapObject(JSContext* aCx,
     43                                           JS::Handle<JSObject*> aGivenProto) {
     44  return TestInterfaceMaplike_Binding::Wrap(aCx, this, aGivenProto);
     45 }
     46 
     47 nsPIDOMWindowInner* TestInterfaceMaplike::GetParentObject() const {
     48  return mParent;
     49 }
     50 
     51 void TestInterfaceMaplike::SetInternal(const nsAString& aKey, int32_t aValue) {
     52  ErrorResult rv;
     53  TestInterfaceMaplike_Binding::MaplikeHelpers::Set(this, aKey, aValue, rv);
     54 }
     55 
     56 void TestInterfaceMaplike::ClearInternal() {
     57  ErrorResult rv;
     58  TestInterfaceMaplike_Binding::MaplikeHelpers::Clear(this, rv);
     59 }
     60 
     61 bool TestInterfaceMaplike::DeleteInternal(const nsAString& aKey) {
     62  ErrorResult rv;
     63  return TestInterfaceMaplike_Binding::MaplikeHelpers::Delete(this, aKey, rv);
     64 }
     65 
     66 bool TestInterfaceMaplike::HasInternal(const nsAString& aKey) {
     67  ErrorResult rv;
     68  return TestInterfaceMaplike_Binding::MaplikeHelpers::Has(this, aKey, rv);
     69 }
     70 
     71 int32_t TestInterfaceMaplike::GetInternal(const nsAString& aKey,
     72                                          ErrorResult& aRv) {
     73  return TestInterfaceMaplike_Binding::MaplikeHelpers::Get(this, aKey, aRv);
     74 }
     75 }  // namespace mozilla::dom