1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/base/MessageChannel.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,72 @@ 1.4 + 1.5 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 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_MessageChannel_h 1.11 +#define mozilla_dom_MessageChannel_h 1.12 + 1.13 +#include "mozilla/Attributes.h" 1.14 +#include "mozilla/ErrorResult.h" 1.15 +#include "mozilla/dom/BindingDeclarations.h" 1.16 +#include "nsCycleCollectionParticipant.h" 1.17 +#include "nsWrapperCache.h" 1.18 +#include "nsCOMPtr.h" 1.19 + 1.20 +class nsPIDOMWindow; 1.21 + 1.22 +namespace mozilla { 1.23 +namespace dom { 1.24 + 1.25 +class MessagePort; 1.26 + 1.27 +class MessageChannel MOZ_FINAL : public nsISupports 1.28 + , public nsWrapperCache 1.29 +{ 1.30 +public: 1.31 + NS_DECL_CYCLE_COLLECTING_ISUPPORTS 1.32 + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MessageChannel) 1.33 + 1.34 + static bool PrefEnabled(); 1.35 + 1.36 +public: 1.37 + MessageChannel(nsPIDOMWindow* aWindow); 1.38 + 1.39 + ~MessageChannel(); 1.40 + 1.41 + nsPIDOMWindow* 1.42 + GetParentObject() const 1.43 + { 1.44 + return mWindow; 1.45 + } 1.46 + 1.47 + virtual JSObject* 1.48 + WrapObject(JSContext* aCx) MOZ_OVERRIDE; 1.49 + 1.50 + static already_AddRefed<MessageChannel> 1.51 + Constructor(const GlobalObject& aGlobal, ErrorResult& aRv); 1.52 + 1.53 + MessagePort* 1.54 + Port1() const 1.55 + { 1.56 + return mPort1; 1.57 + } 1.58 + 1.59 + MessagePort* 1.60 + Port2() const 1.61 + { 1.62 + return mPort2; 1.63 + } 1.64 + 1.65 +private: 1.66 + nsCOMPtr<nsPIDOMWindow> mWindow; 1.67 + 1.68 + nsRefPtr<MessagePort> mPort1; 1.69 + nsRefPtr<MessagePort> mPort2; 1.70 +}; 1.71 + 1.72 +} // namespace dom 1.73 +} // namespace mozilla 1.74 + 1.75 +#endif // mozilla_dom_MessageChannel_h