Bumping manifests a=b2g-bump
[gecko.git] / dom / base / MessagePortList.h
blobde72131050c6d7833aff48021e22ed74f0e83563
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)
35 SetIsDOMBinding();
38 nsISupports*
39 GetParentObject() const
41 return mOwner;
44 virtual JSObject*
45 WrapObject(JSContext* aCx) MOZ_OVERRIDE;
47 uint32_t
48 Length() const
50 return mPorts.Length();
53 MessagePortBase*
54 Item(uint32_t aIndex)
56 return mPorts.SafeElementAt(aIndex);
59 MessagePortBase*
60 IndexedGetter(uint32_t aIndex, bool &aFound)
62 aFound = aIndex < mPorts.Length();
63 if (!aFound) {
64 return nullptr;
66 return mPorts[aIndex];
69 public:
70 nsCOMPtr<nsISupports> mOwner;
71 nsTArray<nsRefPtr<MessagePortBase>> mPorts;
74 } // namespace dom
75 } // namespace mozilla
77 #endif // mozilla_dom_MessagePortList_h