2015-05-03 19:32:37 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* 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/. */
|
2011-01-07 06:21:26 +00:00
|
|
|
|
2016-03-18 21:15:46 +00:00
|
|
|
#ifndef mozilla_dom_workernavigator_h__
|
|
|
|
#define mozilla_dom_workernavigator_h__
|
2011-07-17 19:09:13 +00:00
|
|
|
|
|
|
|
#include "Workers.h"
|
2014-09-23 19:11:18 +00:00
|
|
|
#include "RuntimeService.h"
|
2013-09-23 17:25:00 +00:00
|
|
|
#include "nsString.h"
|
2013-09-30 04:15:37 +00:00
|
|
|
#include "nsWrapperCache.h"
|
2016-11-15 22:44:43 +00:00
|
|
|
#include "mozilla/dom/BindingDeclarations.h"
|
2016-09-07 08:24:25 +00:00
|
|
|
#include "mozilla/dom/StorageManager.h"
|
2011-07-17 19:09:13 +00:00
|
|
|
|
2014-02-24 13:57:15 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class Promise;
|
2016-06-14 12:57:36 +00:00
|
|
|
class StorageManager;
|
2011-07-17 19:09:13 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
class WorkerNavigator final : public nsWrapperCache
|
2013-07-24 07:38:23 +00:00
|
|
|
{
|
2016-03-18 21:15:46 +00:00
|
|
|
typedef struct workers::RuntimeService::NavigatorProperties NavigatorProperties;
|
2014-09-23 19:11:18 +00:00
|
|
|
|
|
|
|
NavigatorProperties mProperties;
|
2016-06-14 12:57:36 +00:00
|
|
|
RefPtr<StorageManager> mStorageManager;
|
2013-11-19 23:08:50 +00:00
|
|
|
bool mOnline;
|
2013-07-24 07:38:23 +00:00
|
|
|
|
2016-12-15 16:06:22 +00:00
|
|
|
WorkerNavigator(const NavigatorProperties& aProperties,
|
|
|
|
bool aOnline)
|
|
|
|
: mProperties(aProperties)
|
|
|
|
, mOnline(aOnline)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(WorkerNavigator);
|
|
|
|
}
|
|
|
|
|
|
|
|
~WorkerNavigator()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(WorkerNavigator);
|
|
|
|
}
|
2014-06-23 19:56:07 +00:00
|
|
|
|
2013-07-24 07:38:23 +00:00
|
|
|
public:
|
2013-09-30 04:15:37 +00:00
|
|
|
|
|
|
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WorkerNavigator)
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WorkerNavigator)
|
|
|
|
|
2013-07-24 07:38:23 +00:00
|
|
|
static already_AddRefed<WorkerNavigator>
|
2013-11-19 23:08:50 +00:00
|
|
|
Create(bool aOnLine);
|
2013-07-24 07:38:23 +00:00
|
|
|
|
2013-09-30 04:15:37 +00:00
|
|
|
virtual JSObject*
|
2015-03-21 16:28:04 +00:00
|
|
|
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2011-07-17 19:09:13 +00:00
|
|
|
|
2013-09-30 04:15:37 +00:00
|
|
|
nsISupports* GetParentObject() const {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2011-07-17 19:09:13 +00:00
|
|
|
|
2013-11-20 14:29:01 +00:00
|
|
|
void GetAppCodeName(nsString& aAppCodeName) const
|
|
|
|
{
|
|
|
|
aAppCodeName.AssignLiteral("Mozilla");
|
|
|
|
}
|
2016-11-15 22:44:43 +00:00
|
|
|
void GetAppName(nsString& aAppName, CallerType aCallerType) const;
|
2013-11-19 23:08:50 +00:00
|
|
|
|
2016-11-15 22:44:43 +00:00
|
|
|
void GetAppVersion(nsString& aAppVersion, CallerType aCallerType,
|
|
|
|
ErrorResult& aRv) const;
|
2014-09-23 19:11:18 +00:00
|
|
|
|
2016-11-15 22:44:43 +00:00
|
|
|
void GetPlatform(nsString& aPlatform, CallerType aCallerType,
|
|
|
|
ErrorResult& aRv) const;
|
2013-11-19 23:08:50 +00:00
|
|
|
|
2013-11-20 14:29:01 +00:00
|
|
|
void GetProduct(nsString& aProduct) const
|
|
|
|
{
|
|
|
|
aProduct.AssignLiteral("Gecko");
|
|
|
|
}
|
2014-09-23 19:11:18 +00:00
|
|
|
|
2013-11-20 14:29:01 +00:00
|
|
|
bool TaintEnabled() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2013-11-19 23:08:50 +00:00
|
|
|
|
2014-09-05 14:26:34 +00:00
|
|
|
void GetLanguage(nsString& aLanguage) const
|
|
|
|
{
|
2014-09-23 19:11:18 +00:00
|
|
|
if (mProperties.mLanguages.Length() >= 1) {
|
|
|
|
aLanguage.Assign(mProperties.mLanguages[0]);
|
2014-09-05 14:26:34 +00:00
|
|
|
} else {
|
|
|
|
aLanguage.Truncate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GetLanguages(nsTArray<nsString>& aLanguages) const
|
|
|
|
{
|
2014-09-23 19:11:18 +00:00
|
|
|
aLanguages = mProperties.mLanguages;
|
2014-09-05 14:26:34 +00:00
|
|
|
}
|
|
|
|
|
2016-11-15 22:44:43 +00:00
|
|
|
void GetUserAgent(nsString& aUserAgent, CallerType aCallerType,
|
|
|
|
ErrorResult& aRv) const;
|
2013-11-19 23:08:50 +00:00
|
|
|
|
|
|
|
bool OnLine() const
|
|
|
|
{
|
|
|
|
return mOnline;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Worker thread only!
|
|
|
|
void SetOnLine(bool aOnline)
|
|
|
|
{
|
|
|
|
mOnline = aOnline;
|
|
|
|
}
|
2014-02-24 13:57:15 +00:00
|
|
|
|
2014-09-05 14:26:34 +00:00
|
|
|
void SetLanguages(const nsTArray<nsString>& aLanguages);
|
|
|
|
|
2016-03-16 19:41:38 +00:00
|
|
|
uint64_t HardwareConcurrency() const;
|
2016-06-14 12:57:36 +00:00
|
|
|
|
|
|
|
StorageManager* Storage();
|
2013-09-30 02:41:23 +00:00
|
|
|
};
|
2013-09-30 04:15:37 +00:00
|
|
|
|
2016-03-18 21:15:46 +00:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2011-07-17 19:09:13 +00:00
|
|
|
|
2016-03-18 21:15:46 +00:00
|
|
|
#endif // mozilla_dom_workernavigator_h__
|