michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_dom_domerror_h__ michael@0: #define mozilla_dom_domerror_h__ michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "nsWrapperCache.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsString.h" michael@0: #include "nsPIDOMWindow.h" michael@0: michael@0: namespace mozilla { michael@0: michael@0: class ErrorResult; michael@0: michael@0: namespace dom { michael@0: michael@0: class GlobalObject; michael@0: michael@0: class DOMError : public nsISupports, michael@0: public nsWrapperCache michael@0: { michael@0: nsCOMPtr mWindow; michael@0: nsString mName; michael@0: nsString mMessage; michael@0: michael@0: public: michael@0: NS_DECL_CYCLE_COLLECTING_ISUPPORTS michael@0: NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMError) michael@0: michael@0: // aWindow can be null if this DOMError is not associated with a particular michael@0: // window. michael@0: michael@0: DOMError(nsPIDOMWindow* aWindow); michael@0: michael@0: DOMError(nsPIDOMWindow* aWindow, nsresult aValue); michael@0: michael@0: DOMError(nsPIDOMWindow* aWindow, const nsAString& aName); michael@0: michael@0: DOMError(nsPIDOMWindow* aWindow, const nsAString& aName, michael@0: const nsAString& aMessage); michael@0: michael@0: virtual ~DOMError(); michael@0: michael@0: nsPIDOMWindow* GetParentObject() const michael@0: { michael@0: return mWindow; michael@0: } michael@0: michael@0: virtual JSObject* michael@0: WrapObject(JSContext* aCx) MOZ_OVERRIDE; michael@0: michael@0: static already_AddRefed michael@0: Constructor(const GlobalObject& global, const nsAString& name, michael@0: const nsAString& message, ErrorResult& aRv); michael@0: michael@0: void GetName(nsString& aRetval) const michael@0: { michael@0: aRetval = mName; michael@0: } michael@0: michael@0: void GetMessage(nsString& aRetval) const michael@0: { michael@0: aRetval = mMessage; michael@0: } michael@0: michael@0: void Init(const nsAString& aName, const nsAString& aMessage) michael@0: { michael@0: mName = aName; michael@0: mMessage = aMessage; michael@0: } michael@0: }; michael@0: michael@0: } // namespace dom michael@0: } // namespace mozilla michael@0: michael@0: #endif // mozilla_dom_domerror_h__