Line data Source code
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/. */
6 :
7 : #include "mozilla/dom/WorkerLocation.h"
8 :
9 : #include "mozilla/dom/WorkerLocationBinding.h"
10 :
11 : namespace mozilla {
12 : namespace dom {
13 :
14 0 : NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(WorkerLocation)
15 :
16 0 : NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(WorkerLocation, AddRef)
17 0 : NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(WorkerLocation, Release)
18 :
19 : /* static */ already_AddRefed<WorkerLocation>
20 0 : WorkerLocation::Create(workers::WorkerPrivate::LocationInfo& aInfo)
21 : {
22 : RefPtr<WorkerLocation> location =
23 0 : new WorkerLocation(NS_ConvertUTF8toUTF16(aInfo.mHref),
24 0 : NS_ConvertUTF8toUTF16(aInfo.mProtocol),
25 0 : NS_ConvertUTF8toUTF16(aInfo.mHost),
26 0 : NS_ConvertUTF8toUTF16(aInfo.mHostname),
27 0 : NS_ConvertUTF8toUTF16(aInfo.mPort),
28 0 : NS_ConvertUTF8toUTF16(aInfo.mPathname),
29 0 : NS_ConvertUTF8toUTF16(aInfo.mSearch),
30 0 : NS_ConvertUTF8toUTF16(aInfo.mHash),
31 0 : aInfo.mOrigin);
32 :
33 0 : return location.forget();
34 : }
35 :
36 : JSObject*
37 0 : WorkerLocation::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
38 : {
39 0 : return WorkerLocationBinding::Wrap(aCx, this, aGivenProto);
40 : }
41 :
42 : } // namespace dom
43 : } // namespace mozilla
|