diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/fetch/Headers.cpp | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/fetch/Headers.cpp')
-rw-r--r-- | dom/fetch/Headers.cpp | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/dom/fetch/Headers.cpp b/dom/fetch/Headers.cpp new file mode 100644 index 000000000..1e1a46c62 --- /dev/null +++ b/dom/fetch/Headers.cpp @@ -0,0 +1,97 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "mozilla/dom/Headers.h" + +#include "mozilla/ErrorResult.h" +#include "mozilla/dom/WorkerPrivate.h" +#include "mozilla/Preferences.h" + +namespace mozilla { +namespace dom { + +NS_IMPL_CYCLE_COLLECTING_ADDREF(Headers) +NS_IMPL_CYCLE_COLLECTING_RELEASE(Headers) +NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(Headers, mOwner) + +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Headers) + NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY + NS_INTERFACE_MAP_ENTRY(nsISupports) +NS_INTERFACE_MAP_END + +// static +already_AddRefed<Headers> +Headers::Constructor(const GlobalObject& aGlobal, + const Optional<HeadersOrByteStringSequenceSequenceOrByteStringMozMap>& aInit, + ErrorResult& aRv) +{ + RefPtr<InternalHeaders> ih = new InternalHeaders(); + RefPtr<Headers> headers = new Headers(aGlobal.GetAsSupports(), ih); + + if (!aInit.WasPassed()) { + return headers.forget(); + } + + if (aInit.Value().IsHeaders()) { + ih->Fill(*aInit.Value().GetAsHeaders().mInternalHeaders, aRv); + } else if (aInit.Value().IsByteStringSequenceSequence()) { + ih->Fill(aInit.Value().GetAsByteStringSequenceSequence(), aRv); + } else if (aInit.Value().IsByteStringMozMap()) { + ih->Fill(aInit.Value().GetAsByteStringMozMap(), aRv); + } + + if (aRv.Failed()) { + return nullptr; + } + + return headers.forget(); +} + +// static +already_AddRefed<Headers> +Headers::Constructor(const GlobalObject& aGlobal, + const OwningHeadersOrByteStringSequenceSequenceOrByteStringMozMap& aInit, + ErrorResult& aRv) +{ + nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports()); + return Create(global, aInit, aRv); +} + +/* static */ already_AddRefed<Headers> +Headers::Create(nsIGlobalObject* aGlobal, + const OwningHeadersOrByteStringSequenceSequenceOrByteStringMozMap& aInit, + ErrorResult& aRv) +{ + RefPtr<InternalHeaders> ih = new InternalHeaders(); + RefPtr<Headers> headers = new Headers(aGlobal, ih); + + if (aInit.IsHeaders()) { + ih->Fill(*(aInit.GetAsHeaders().get()->mInternalHeaders), aRv); + } else if (aInit.IsByteStringSequenceSequence()) { + ih->Fill(aInit.GetAsByteStringSequenceSequence(), aRv); + } else if (aInit.IsByteStringMozMap()) { + ih->Fill(aInit.GetAsByteStringMozMap(), aRv); + } + + if (NS_WARN_IF(aRv.Failed())) { + return nullptr; + } + + return headers.forget(); +} + +JSObject* +Headers::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) +{ + return mozilla::dom::HeadersBinding::Wrap(aCx, this, aGivenProto); +} + +Headers::~Headers() +{ +} + +} // namespace dom +} // namespace mozilla |