|
1 /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #include "Location.h" |
|
7 |
|
8 #include "mozilla/dom/WorkerLocationBinding.h" |
|
9 |
|
10 BEGIN_WORKERS_NAMESPACE |
|
11 |
|
12 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(WorkerLocation) |
|
13 |
|
14 NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(WorkerLocation, AddRef) |
|
15 NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(WorkerLocation, Release) |
|
16 |
|
17 /* static */ already_AddRefed<WorkerLocation> |
|
18 WorkerLocation::Create(WorkerPrivate::LocationInfo& aInfo) |
|
19 { |
|
20 nsRefPtr<WorkerLocation> location = |
|
21 new WorkerLocation(NS_ConvertUTF8toUTF16(aInfo.mHref), |
|
22 NS_ConvertUTF8toUTF16(aInfo.mProtocol), |
|
23 NS_ConvertUTF8toUTF16(aInfo.mHost), |
|
24 NS_ConvertUTF8toUTF16(aInfo.mHostname), |
|
25 NS_ConvertUTF8toUTF16(aInfo.mPort), |
|
26 NS_ConvertUTF8toUTF16(aInfo.mPathname), |
|
27 NS_ConvertUTF8toUTF16(aInfo.mSearch), |
|
28 NS_ConvertUTF8toUTF16(aInfo.mHash), |
|
29 aInfo.mOrigin); |
|
30 |
|
31 return location.forget(); |
|
32 } |
|
33 |
|
34 JSObject* |
|
35 WorkerLocation::WrapObject(JSContext* aCx) |
|
36 { |
|
37 return WorkerLocationBinding_workers::Wrap(aCx, this); |
|
38 } |
|
39 |
|
40 END_WORKERS_NAMESPACE |