tor-browser

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

MIDIOutputMap.h (1558B)


      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_MIDIOutputMap_h
      8 #define mozilla_dom_MIDIOutputMap_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 output ports available for
     21 * access. Almost all functions are implemented automatically by WebIDL.
     22 *
     23 */
     24 class MIDIOutputMap final : public nsISupports, public nsWrapperCache {
     25 public:
     26  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
     27  NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(MIDIOutputMap)
     28 
     29  explicit MIDIOutputMap(nsPIDOMWindowInner* aParent);
     30 
     31  nsPIDOMWindowInner* GetParentObject() const { return mParent; }
     32 
     33  JSObject* WrapObject(JSContext* aCx,
     34                       JS::Handle<JSObject*> aGivenProto) override;
     35  bool Has(nsAString& aId) { return mPorts.Get(aId) != nullptr; }
     36  void Insert(nsAString& aId, RefPtr<MIDIPort> aPort) {
     37    mPorts.InsertOrUpdate(aId, aPort);
     38  }
     39  void Remove(nsAString& aId) { mPorts.Remove(aId); }
     40 
     41 private:
     42  ~MIDIOutputMap() = default;
     43  nsTHashMap<nsString, RefPtr<MIDIPort>> mPorts;
     44  nsCOMPtr<nsPIDOMWindowInner> mParent;
     45 };
     46 
     47 }  // namespace mozilla::dom
     48 
     49 #endif  // mozilla_dom_MIDIOutputMap_h