mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 13:23:07 +00:00
4751a4e732
- Bug 1231975 - Part 3: Break a reference cycle between PendingResolution and DNSRequestChild. r=drno (ecf45de535) - Bug 1231975 - Part 4: Add some logging and simplification in TestNrSocket. r=drno (fa811f7743) - Bug 1231975 - Part 5: Fix an intermittent failure caused by the NAT simulator erroneously canceling NR_ASYNC_WAIT_READ. r=drno (e436a8cc75) - var-let (d228288673) - Bug 1256022 - dom/network slow GC on mochitest fix r=dragana (e0dffd5033) - Bug 1231130 - added mHadLocalInstance to constructor.r=jaas (c4f6d0c530) - Bug 1121290: Use "%ls" instead of "%s" in _snwprintf_s format string# r=bsmedberg (e0434aca5a) - Bug 1206952 - Rename MagicRequest to ByteRangeRequest. r=sicking (6780309aa2) - Bug 1206952 - Convert PluginStreamListener to use channel->AsyncOpen2(). r=sicking (8f41f3e148) - Bug 1262335 - Part 2. Remove Android GB/HC defines from OMX. r=snorp (e5b7435d92) - Bug 956899 - Add a std::condition_variable work-alike; r=froydnj (98076c707e) - Bug 1254123 - Handle OOM more gracefully in js::ErrorToException. (r=Waldo) (f9a2ef18d1) - Bug 1255128 - Standard argument coercion in new ArrayBuffer(length). r=nbp. Thanks to snowmantw for tests. (06e5cedd80) - Bug 1251919 - Nuke Debugger wrappers on failure. (r=shu) (64bc41b1f1) - Bug 1254190 - Propagate failure of matchAllDebuggeeGlobals() in Debugger. (r=shu) (927bf01ec5) - Bug 1254172 - Make UnboxedLayout::makeNativeGroup robust to unknownProperties on unboxed type. (r=jandem) (398a6b3aa7) - Bug 1268213 - BlobImplFile::GetTypeRunnable can be a WorkerMainThreadRunnable, r=khuey (30e4ff4b75) - Bug 1268231 - Get rid of StopSyncLoopRunnable, r=khuey (29b0a0ed4f) - Bug 1267904 - Add telemetry for WorkerMainThreadRunnable, r=khuey (970d39bcce) - Bug 1264968 part 2 - Allow persisting attributes of xul:window if its owner document is not root. r=enndeakin (ca8182b534) - Bug 1244948 - silence the 'loaded script twice' warning. r=bz (fa571b837c)
169 lines
4.3 KiB
C++
169 lines
4.3 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "mozilla/dom/BindingUtils.h"
|
|
#include "mozilla/dom/Promise.h"
|
|
#include "mozilla/dom/PromiseWorkerProxy.h"
|
|
#include "mozilla/dom/WorkerNavigator.h"
|
|
#include "mozilla/dom/WorkerNavigatorBinding.h"
|
|
|
|
#include "nsProxyRelease.h"
|
|
#include "RuntimeService.h"
|
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "WorkerPrivate.h"
|
|
#include "WorkerRunnable.h"
|
|
#include "WorkerScope.h"
|
|
|
|
#include "mozilla/dom/Navigator.h"
|
|
|
|
namespace mozilla {
|
|
namespace dom {
|
|
|
|
using namespace mozilla::dom::workers;
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(WorkerNavigator)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(WorkerNavigator, AddRef)
|
|
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(WorkerNavigator, Release)
|
|
|
|
/* static */ already_AddRefed<WorkerNavigator>
|
|
WorkerNavigator::Create(bool aOnLine)
|
|
{
|
|
RuntimeService* rts = RuntimeService::GetService();
|
|
MOZ_ASSERT(rts);
|
|
|
|
const RuntimeService::NavigatorProperties& properties =
|
|
rts->GetNavigatorProperties();
|
|
|
|
RefPtr<WorkerNavigator> navigator =
|
|
new WorkerNavigator(properties, aOnLine);
|
|
|
|
return navigator.forget();
|
|
}
|
|
|
|
JSObject*
|
|
WorkerNavigator::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
|
{
|
|
return WorkerNavigatorBinding::Wrap(aCx, this, aGivenProto);
|
|
}
|
|
|
|
void
|
|
WorkerNavigator::SetLanguages(const nsTArray<nsString>& aLanguages)
|
|
{
|
|
WorkerNavigatorBinding::ClearCachedLanguagesValue(this);
|
|
mProperties.mLanguages = aLanguages;
|
|
}
|
|
|
|
void
|
|
WorkerNavigator::GetAppName(nsString& aAppName) const
|
|
{
|
|
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
|
|
MOZ_ASSERT(workerPrivate);
|
|
|
|
if (!mProperties.mAppNameOverridden.IsEmpty() &&
|
|
!workerPrivate->UsesSystemPrincipal()) {
|
|
aAppName = mProperties.mAppNameOverridden;
|
|
} else {
|
|
aAppName = mProperties.mAppName;
|
|
}
|
|
}
|
|
|
|
void
|
|
WorkerNavigator::GetAppVersion(nsString& aAppVersion) const
|
|
{
|
|
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
|
|
MOZ_ASSERT(workerPrivate);
|
|
|
|
if (!mProperties.mAppVersionOverridden.IsEmpty() &&
|
|
!workerPrivate->UsesSystemPrincipal()) {
|
|
aAppVersion = mProperties.mAppVersionOverridden;
|
|
} else {
|
|
aAppVersion = mProperties.mAppVersion;
|
|
}
|
|
}
|
|
|
|
void
|
|
WorkerNavigator::GetPlatform(nsString& aPlatform) const
|
|
{
|
|
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
|
|
MOZ_ASSERT(workerPrivate);
|
|
|
|
if (!mProperties.mPlatformOverridden.IsEmpty() &&
|
|
!workerPrivate->UsesSystemPrincipal()) {
|
|
aPlatform = mProperties.mPlatformOverridden;
|
|
} else {
|
|
aPlatform = mProperties.mPlatform;
|
|
}
|
|
}
|
|
|
|
namespace {
|
|
|
|
class GetUserAgentRunnable final : public WorkerMainThreadRunnable
|
|
{
|
|
nsString& mUA;
|
|
|
|
public:
|
|
GetUserAgentRunnable(WorkerPrivate* aWorkerPrivate, nsString& aUA)
|
|
: WorkerMainThreadRunnable(aWorkerPrivate,
|
|
NS_LITERAL_CSTRING("UserAgent getter"))
|
|
, mUA(aUA)
|
|
{
|
|
MOZ_ASSERT(aWorkerPrivate);
|
|
aWorkerPrivate->AssertIsOnWorkerThread();
|
|
}
|
|
|
|
virtual bool MainThreadRun() override
|
|
{
|
|
AssertIsOnMainThread();
|
|
|
|
nsCOMPtr<nsPIDOMWindow> window = mWorkerPrivate->GetWindow();
|
|
nsCOMPtr<nsIURI> uri;
|
|
if (window && window->GetDocShell()) {
|
|
nsIDocument* doc = window->GetExtantDoc();
|
|
if (doc) {
|
|
doc->NodePrincipal()->GetURI(getter_AddRefs(uri));
|
|
}
|
|
}
|
|
|
|
bool isCallerChrome = mWorkerPrivate->UsesSystemPrincipal();
|
|
nsresult rv = dom::Navigator::GetUserAgent(window, uri,
|
|
isCallerChrome, mUA);
|
|
if (NS_FAILED(rv)) {
|
|
NS_WARNING("Failed to retrieve user-agent from the worker thread.");
|
|
}
|
|
|
|
return true;
|
|
}
|
|
};
|
|
|
|
} // namespace
|
|
|
|
void
|
|
WorkerNavigator::GetUserAgent(nsString& aUserAgent, ErrorResult& aRv) const
|
|
{
|
|
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
|
|
MOZ_ASSERT(workerPrivate);
|
|
|
|
RefPtr<GetUserAgentRunnable> runnable =
|
|
new GetUserAgentRunnable(workerPrivate, aUserAgent);
|
|
|
|
runnable->Dispatch(aRv);
|
|
}
|
|
|
|
uint64_t
|
|
WorkerNavigator::HardwareConcurrency() const
|
|
{
|
|
RuntimeService* rts = RuntimeService::GetService();
|
|
MOZ_ASSERT(rts);
|
|
|
|
return rts->ClampedHardwareConcurrency();
|
|
}
|
|
|
|
} // namespace dom
|
|
} // namespace mozilla
|