Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
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 | #ifndef mozilla_dom_workers_navigator_h__ |
michael@0 | 7 | #define mozilla_dom_workers_navigator_h__ |
michael@0 | 8 | |
michael@0 | 9 | #include "Workers.h" |
michael@0 | 10 | #include "RuntimeService.h" |
michael@0 | 11 | #include "nsString.h" |
michael@0 | 12 | #include "nsWrapperCache.h" |
michael@0 | 13 | |
michael@0 | 14 | BEGIN_WORKERS_NAMESPACE |
michael@0 | 15 | |
michael@0 | 16 | class WorkerNavigator MOZ_FINAL : public nsWrapperCache |
michael@0 | 17 | { |
michael@0 | 18 | typedef struct RuntimeService::NavigatorProperties NavigatorProperties; |
michael@0 | 19 | |
michael@0 | 20 | NavigatorProperties mProperties; |
michael@0 | 21 | bool mOnline; |
michael@0 | 22 | |
michael@0 | 23 | WorkerNavigator(const NavigatorProperties& aProperties, |
michael@0 | 24 | bool aOnline) |
michael@0 | 25 | : mProperties(aProperties) |
michael@0 | 26 | , mOnline(aOnline) |
michael@0 | 27 | { |
michael@0 | 28 | MOZ_COUNT_CTOR(WorkerNavigator); |
michael@0 | 29 | SetIsDOMBinding(); |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | public: |
michael@0 | 33 | |
michael@0 | 34 | NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WorkerNavigator) |
michael@0 | 35 | NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WorkerNavigator) |
michael@0 | 36 | |
michael@0 | 37 | static already_AddRefed<WorkerNavigator> |
michael@0 | 38 | Create(bool aOnLine); |
michael@0 | 39 | |
michael@0 | 40 | virtual JSObject* |
michael@0 | 41 | WrapObject(JSContext* aCx) MOZ_OVERRIDE; |
michael@0 | 42 | |
michael@0 | 43 | nsISupports* GetParentObject() const { |
michael@0 | 44 | return nullptr; |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | ~WorkerNavigator() |
michael@0 | 48 | { |
michael@0 | 49 | MOZ_COUNT_DTOR(WorkerNavigator); |
michael@0 | 50 | } |
michael@0 | 51 | |
michael@0 | 52 | void GetAppCodeName(nsString& aAppCodeName) const |
michael@0 | 53 | { |
michael@0 | 54 | aAppCodeName.AssignLiteral("Mozilla"); |
michael@0 | 55 | } |
michael@0 | 56 | void GetAppName(nsString& aAppName) const; |
michael@0 | 57 | |
michael@0 | 58 | void GetAppVersion(nsString& aAppVersion) const; |
michael@0 | 59 | |
michael@0 | 60 | void GetPlatform(nsString& aPlatform) const; |
michael@0 | 61 | |
michael@0 | 62 | void GetProduct(nsString& aProduct) const |
michael@0 | 63 | { |
michael@0 | 64 | aProduct.AssignLiteral("Gecko"); |
michael@0 | 65 | } |
michael@0 | 66 | |
michael@0 | 67 | bool TaintEnabled() const |
michael@0 | 68 | { |
michael@0 | 69 | return false; |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | void GetUserAgent(nsString& aUserAgent) const |
michael@0 | 73 | { |
michael@0 | 74 | aUserAgent = mProperties.mUserAgent; |
michael@0 | 75 | } |
michael@0 | 76 | |
michael@0 | 77 | bool OnLine() const |
michael@0 | 78 | { |
michael@0 | 79 | return mOnline; |
michael@0 | 80 | } |
michael@0 | 81 | |
michael@0 | 82 | // Worker thread only! |
michael@0 | 83 | void SetOnLine(bool aOnline) |
michael@0 | 84 | { |
michael@0 | 85 | mOnline = aOnline; |
michael@0 | 86 | } |
michael@0 | 87 | }; |
michael@0 | 88 | |
michael@0 | 89 | END_WORKERS_NAMESPACE |
michael@0 | 90 | |
michael@0 | 91 | #endif // mozilla_dom_workers_navigator_h__ |