Bumping gaia.json for 8 gaia revision(s) a=gaia-bump
[gecko.git] / dom / base / MessagePortList.h
blobfa852f73259f57fa4b368d65612c44c75f41ce02
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/. */
7 #ifndef mozilla_dom_MessagePortList_h
8 #define mozilla_dom_MessagePortList_h
10 #include "mozilla/Attributes.h"
11 #include "mozilla/ErrorResult.h"
12 #include "nsCycleCollectionParticipant.h"
13 #include "mozilla/dom/MessagePort.h"
14 #include "nsWrapperCache.h"
15 #include "nsAutoPtr.h"
16 #include "nsTArray.h"
18 namespace mozilla {
19 namespace dom {
21 class MessagePortList MOZ_FINAL : public nsISupports
22 , public nsWrapperCache
24 ~MessagePortList() {}
26 public:
27 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
28 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MessagePortList)
30 public:
31 MessagePortList(nsISupports* aOwner, nsTArray<nsRefPtr<MessagePortBase>>& aPorts)
32 : mOwner(aOwner)
33 , mPorts(aPorts)
37 nsISupports*
38 GetParentObject() const
40 return mOwner;
43 virtual JSObject*
44 WrapObject(JSContext* aCx) MOZ_OVERRIDE;
46 uint32_t
47 Length() const
49 return mPorts.Length();
52 MessagePortBase*
53 Item(uint32_t aIndex)
55 return mPorts.SafeElementAt(aIndex);
58 MessagePortBase*
59 IndexedGetter(uint32_t aIndex, bool &aFound)
61 aFound = aIndex < mPorts.Length();
62 if (!aFound) {
63 return nullptr;
65 return mPorts[aIndex];
68 public:
69 nsCOMPtr<nsISupports> mOwner;
70 nsTArray<nsRefPtr<MessagePortBase>> mPorts;
73 } // namespace dom
74 } // namespace mozilla
76 #endif // mozilla_dom_MessagePortList_h