dom/workers/Navigator.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/workers/Navigator.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,91 @@
     1.4 +/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef mozilla_dom_workers_navigator_h__
    1.10 +#define mozilla_dom_workers_navigator_h__
    1.11 +
    1.12 +#include "Workers.h"
    1.13 +#include "RuntimeService.h"
    1.14 +#include "nsString.h"
    1.15 +#include "nsWrapperCache.h"
    1.16 +
    1.17 +BEGIN_WORKERS_NAMESPACE
    1.18 +
    1.19 +class WorkerNavigator MOZ_FINAL : public nsWrapperCache
    1.20 +{
    1.21 +  typedef struct RuntimeService::NavigatorProperties NavigatorProperties;
    1.22 +
    1.23 +  NavigatorProperties mProperties;
    1.24 +  bool mOnline;
    1.25 +
    1.26 +  WorkerNavigator(const NavigatorProperties& aProperties,
    1.27 +                  bool aOnline)
    1.28 +    : mProperties(aProperties)
    1.29 +    , mOnline(aOnline)
    1.30 +  {
    1.31 +    MOZ_COUNT_CTOR(WorkerNavigator);
    1.32 +    SetIsDOMBinding();
    1.33 +  }
    1.34 +
    1.35 +public:
    1.36 +
    1.37 +  NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WorkerNavigator)
    1.38 +  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WorkerNavigator)
    1.39 +
    1.40 +  static already_AddRefed<WorkerNavigator>
    1.41 +  Create(bool aOnLine);
    1.42 +
    1.43 +  virtual JSObject*
    1.44 +  WrapObject(JSContext* aCx) MOZ_OVERRIDE;
    1.45 +
    1.46 +  nsISupports* GetParentObject() const {
    1.47 +    return nullptr;
    1.48 +  }
    1.49 +
    1.50 +  ~WorkerNavigator()
    1.51 +  {
    1.52 +    MOZ_COUNT_DTOR(WorkerNavigator);
    1.53 +  }
    1.54 +
    1.55 +  void GetAppCodeName(nsString& aAppCodeName) const
    1.56 +  {
    1.57 +    aAppCodeName.AssignLiteral("Mozilla");
    1.58 +  }
    1.59 +  void GetAppName(nsString& aAppName) const;
    1.60 +
    1.61 +  void GetAppVersion(nsString& aAppVersion) const;
    1.62 +
    1.63 +  void GetPlatform(nsString& aPlatform) const;
    1.64 +
    1.65 +  void GetProduct(nsString& aProduct) const
    1.66 +  {
    1.67 +    aProduct.AssignLiteral("Gecko");
    1.68 +  }
    1.69 +
    1.70 +  bool TaintEnabled() const
    1.71 +  {
    1.72 +    return false;
    1.73 +  }
    1.74 +
    1.75 +  void GetUserAgent(nsString& aUserAgent) const
    1.76 +  {
    1.77 +    aUserAgent = mProperties.mUserAgent;
    1.78 +  }
    1.79 +
    1.80 +  bool OnLine() const
    1.81 +  {
    1.82 +    return mOnline;
    1.83 +  }
    1.84 +
    1.85 +  // Worker thread only!
    1.86 +  void SetOnLine(bool aOnline)
    1.87 +  {
    1.88 +    mOnline = aOnline;
    1.89 +  }
    1.90 +};
    1.91 +
    1.92 +END_WORKERS_NAMESPACE
    1.93 +
    1.94 +#endif // mozilla_dom_workers_navigator_h__

mercurial