tor-browser

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

MIDIInputMap.h (1545B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
      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_MIDIInputMap_h
      8 #define mozilla_dom_MIDIInputMap_h
      9 
     10 #include "mozilla/dom/MIDIPort.h"
     11 #include "nsCOMPtr.h"
     12 #include "nsTHashMap.h"
     13 #include "nsWrapperCache.h"
     14 
     15 class nsPIDOMWindowInner;
     16 
     17 namespace mozilla::dom {
     18 
     19 /**
     20 * Maplike DOM object that holds a list of all MIDI input ports available for
     21 * access. Almost all functions are implemented automatically by WebIDL.
     22 */
     23 class MIDIInputMap final : public nsISupports, public nsWrapperCache {
     24 public:
     25  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
     26  NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(MIDIInputMap)
     27  nsPIDOMWindowInner* GetParentObject() const { return mParent; }
     28 
     29  explicit MIDIInputMap(nsPIDOMWindowInner* aParent);
     30  JSObject* WrapObject(JSContext* aCx,
     31                       JS::Handle<JSObject*> aGivenProto) override;
     32  bool Has(nsAString& aId) { return mPorts.Get(aId) != nullptr; }
     33  void Insert(nsAString& aId, RefPtr<MIDIPort> aPort) {
     34    mPorts.InsertOrUpdate(aId, aPort);
     35  }
     36  void Remove(nsAString& aId) { mPorts.Remove(aId); }
     37 
     38 private:
     39  ~MIDIInputMap() = default;
     40  nsTHashMap<nsString, RefPtr<MIDIPort>> mPorts;
     41  nsCOMPtr<nsPIDOMWindowInner> mParent;
     42 };
     43 
     44 }  // namespace mozilla::dom
     45 
     46 #endif  // mozilla_dom_MIDIInputMap_h