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
)
15 NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(WorkerLocation
, AddRef
)
16 NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(WorkerLocation
, Release
)
19 already_AddRefed
<WorkerLocation
> WorkerLocation::Create(
20 WorkerPrivate::LocationInfo
& aInfo
) {
21 RefPtr
<WorkerLocation
> location
=
22 new WorkerLocation(NS_ConvertUTF8toUTF16(aInfo
.mHref
),
23 NS_ConvertUTF8toUTF16(aInfo
.mProtocol
),
24 NS_ConvertUTF8toUTF16(aInfo
.mHost
),
25 NS_ConvertUTF8toUTF16(aInfo
.mHostname
),
26 NS_ConvertUTF8toUTF16(aInfo
.mPort
),
27 NS_ConvertUTF8toUTF16(aInfo
.mPathname
),
28 NS_ConvertUTF8toUTF16(aInfo
.mSearch
),
29 NS_ConvertUTF8toUTF16(aInfo
.mHash
), aInfo
.mOrigin
);
31 return location
.forget();
34 JSObject
* WorkerLocation::WrapObject(JSContext
* aCx
,
35 JS::Handle
<JSObject
*> aGivenProto
) {
36 return WorkerLocation_Binding::Wrap(aCx
, this, aGivenProto
);
39 } // namespace mozilla::dom