dom/workers/Navigator.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #include "Navigator.h"
michael@0 7
michael@0 8 #include "mozilla/dom/WorkerNavigatorBinding.h"
michael@0 9
michael@0 10 #include "RuntimeService.h"
michael@0 11 #include "WorkerPrivate.h"
michael@0 12
michael@0 13 BEGIN_WORKERS_NAMESPACE
michael@0 14
michael@0 15 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(WorkerNavigator)
michael@0 16
michael@0 17 NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(WorkerNavigator, AddRef)
michael@0 18 NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(WorkerNavigator, Release)
michael@0 19
michael@0 20 /* static */ already_AddRefed<WorkerNavigator>
michael@0 21 WorkerNavigator::Create(bool aOnLine)
michael@0 22 {
michael@0 23 RuntimeService* rts = RuntimeService::GetService();
michael@0 24 MOZ_ASSERT(rts);
michael@0 25
michael@0 26 const RuntimeService::NavigatorProperties& properties =
michael@0 27 rts->GetNavigatorProperties();
michael@0 28
michael@0 29 nsRefPtr<WorkerNavigator> navigator =
michael@0 30 new WorkerNavigator(properties, aOnLine);
michael@0 31
michael@0 32 return navigator.forget();
michael@0 33 }
michael@0 34
michael@0 35 JSObject*
michael@0 36 WorkerNavigator::WrapObject(JSContext* aCx)
michael@0 37 {
michael@0 38 return WorkerNavigatorBinding_workers::Wrap(aCx, this);
michael@0 39 }
michael@0 40
michael@0 41 void
michael@0 42 WorkerNavigator::GetAppName(nsString& aAppName) const
michael@0 43 {
michael@0 44 WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
michael@0 45 MOZ_ASSERT(workerPrivate);
michael@0 46
michael@0 47 if (!mProperties.mAppNameOverridden.IsEmpty() &&
michael@0 48 !workerPrivate->UsesSystemPrincipal()) {
michael@0 49 aAppName = mProperties.mAppNameOverridden;
michael@0 50 } else {
michael@0 51 aAppName = mProperties.mAppName;
michael@0 52 }
michael@0 53 }
michael@0 54
michael@0 55 void
michael@0 56 WorkerNavigator::GetAppVersion(nsString& aAppVersion) const
michael@0 57 {
michael@0 58 WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
michael@0 59 MOZ_ASSERT(workerPrivate);
michael@0 60
michael@0 61 if (!mProperties.mAppVersionOverridden.IsEmpty() &&
michael@0 62 !workerPrivate->UsesSystemPrincipal()) {
michael@0 63 aAppVersion = mProperties.mAppVersionOverridden;
michael@0 64 } else {
michael@0 65 aAppVersion = mProperties.mAppVersion;
michael@0 66 }
michael@0 67 }
michael@0 68
michael@0 69 void
michael@0 70 WorkerNavigator::GetPlatform(nsString& aPlatform) const
michael@0 71 {
michael@0 72 WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
michael@0 73 MOZ_ASSERT(workerPrivate);
michael@0 74
michael@0 75 if (!mProperties.mPlatformOverridden.IsEmpty() &&
michael@0 76 !workerPrivate->UsesSystemPrincipal()) {
michael@0 77 aPlatform = mProperties.mPlatformOverridden;
michael@0 78 } else {
michael@0 79 aPlatform = mProperties.mPlatform;
michael@0 80 }
michael@0 81 }
michael@0 82
michael@0 83 END_WORKERS_NAMESPACE

mercurial