1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
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 #include "mozilla/dom/WorkerLocation.h"
9 #include "mozilla/dom/WorkerLocationBinding.h"
11 namespace mozilla::dom
{
13 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(WorkerLocation
)
16 already_AddRefed
<WorkerLocation
> WorkerLocation::Create(
17 WorkerPrivate::LocationInfo
& aInfo
) {
18 RefPtr
<WorkerLocation
> location
=
19 new WorkerLocation(NS_ConvertUTF8toUTF16(aInfo
.mHref
),
20 NS_ConvertUTF8toUTF16(aInfo
.mProtocol
),
21 NS_ConvertUTF8toUTF16(aInfo
.mHost
),
22 NS_ConvertUTF8toUTF16(aInfo
.mHostname
),
23 NS_ConvertUTF8toUTF16(aInfo
.mPort
),
24 NS_ConvertUTF8toUTF16(aInfo
.mPathname
),
25 NS_ConvertUTF8toUTF16(aInfo
.mSearch
),
26 NS_ConvertUTF8toUTF16(aInfo
.mHash
), aInfo
.mOrigin
);
28 return location
.forget();
31 JSObject
* WorkerLocation::WrapObject(JSContext
* aCx
,
32 JS::Handle
<JSObject
*> aGivenProto
) {
33 return WorkerLocation_Binding::Wrap(aCx
, this, aGivenProto
);
36 } // namespace mozilla::dom