1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/base/MessagePortList.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,76 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim:set ts=2 sw=2 sts=2 et cindent: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef mozilla_dom_MessagePortList_h 1.11 +#define mozilla_dom_MessagePortList_h 1.12 + 1.13 +#include "mozilla/Attributes.h" 1.14 +#include "mozilla/ErrorResult.h" 1.15 +#include "nsCycleCollectionParticipant.h" 1.16 +#include "mozilla/dom/MessagePort.h" 1.17 +#include "nsWrapperCache.h" 1.18 +#include "nsAutoPtr.h" 1.19 +#include "nsTArray.h" 1.20 + 1.21 +namespace mozilla { 1.22 +namespace dom { 1.23 + 1.24 +class MessagePortList MOZ_FINAL : public nsISupports 1.25 + , public nsWrapperCache 1.26 +{ 1.27 +public: 1.28 + NS_DECL_CYCLE_COLLECTING_ISUPPORTS 1.29 + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MessagePortList) 1.30 + 1.31 +public: 1.32 + MessagePortList(nsISupports* aOwner, nsTArray<nsRefPtr<MessagePortBase>>& aPorts) 1.33 + : mOwner(aOwner) 1.34 + , mPorts(aPorts) 1.35 + { 1.36 + SetIsDOMBinding(); 1.37 + } 1.38 + 1.39 + nsISupports* 1.40 + GetParentObject() const 1.41 + { 1.42 + return mOwner; 1.43 + } 1.44 + 1.45 + virtual JSObject* 1.46 + WrapObject(JSContext* aCx) MOZ_OVERRIDE; 1.47 + 1.48 + uint32_t 1.49 + Length() const 1.50 + { 1.51 + return mPorts.Length(); 1.52 + } 1.53 + 1.54 + MessagePortBase* 1.55 + Item(uint32_t aIndex) 1.56 + { 1.57 + return mPorts.SafeElementAt(aIndex); 1.58 + } 1.59 + 1.60 + MessagePortBase* 1.61 + IndexedGetter(uint32_t aIndex, bool &aFound) 1.62 + { 1.63 + aFound = aIndex < mPorts.Length(); 1.64 + if (!aFound) { 1.65 + return nullptr; 1.66 + } 1.67 + return mPorts[aIndex]; 1.68 + } 1.69 + 1.70 +public: 1.71 + nsCOMPtr<nsISupports> mOwner; 1.72 + nsTArray<nsRefPtr<MessagePortBase>> mPorts; 1.73 +}; 1.74 + 1.75 +} // namespace dom 1.76 +} // namespace mozilla 1.77 + 1.78 +#endif // mozilla_dom_MessagePortList_h 1.79 +