LCOV - code coverage report
Current view: top level - widget - GfxInfoBase.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 8 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 7 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* vim: se cin sw=2 ts=2 et : */
       2             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
       3             :  *
       4             :  * This Source Code Form is subject to the terms of the Mozilla Public
       5             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       6             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       7             : 
       8             : #ifndef __mozilla_widget_GfxInfoBase_h__
       9             : #define __mozilla_widget_GfxInfoBase_h__
      10             : 
      11             : #include "GfxDriverInfo.h"
      12             : #include "GfxInfoCollector.h"
      13             : #include "gfxFeature.h"
      14             : #include "gfxTelemetry.h"
      15             : #include "js/Value.h"
      16             : #include "mozilla/Attributes.h"
      17             : #include "mozilla/Maybe.h"
      18             : #include "mozilla/Mutex.h"
      19             : #include "mozilla/dom/PContentParent.h"
      20             : #include "nsCOMPtr.h"
      21             : #include "nsIGfxInfo.h"
      22             : #include "nsIGfxInfoDebug.h"
      23             : #include "nsIObserver.h"
      24             : #include "nsString.h"
      25             : #include "nsTArray.h"
      26             : #include "nsWeakReference.h"
      27             : 
      28             : namespace mozilla {
      29             : namespace widget {  
      30             : 
      31             : class GfxInfoBase : public nsIGfxInfo,
      32             :                     public nsIObserver,
      33             :                     public nsSupportsWeakReference
      34             : #ifdef DEBUG
      35             :                   , public nsIGfxInfoDebug
      36             : #endif
      37             : {
      38             : public:
      39             :   GfxInfoBase();
      40             : 
      41             :   NS_DECL_THREADSAFE_ISUPPORTS
      42             :   NS_DECL_NSIOBSERVER
      43             : 
      44             :   // We only declare a subset of the nsIGfxInfo interface. It's up to derived
      45             :   // classes to implement the rest of the interface.  
      46             :   // Derived classes need to use
      47             :   // using GfxInfoBase::GetFeatureStatus;
      48             :   // using GfxInfoBase::GetFeatureSuggestedDriverVersion;
      49             :   // using GfxInfoBase::GetWebGLParameter;
      50             :   // to import the relevant methods into their namespace.
      51             :   NS_IMETHOD GetFeatureStatus(int32_t aFeature, nsACString& aFailureId, int32_t *_retval) override;
      52             :   NS_IMETHOD GetFeatureSuggestedDriverVersion(int32_t aFeature, nsAString & _retval) override;
      53             :   NS_IMETHOD GetWebGLParameter(const nsAString & aParam, nsAString & _retval) override;
      54             : 
      55             :   NS_IMETHOD GetMonitors(JSContext* cx, JS::MutableHandleValue _retval) override;
      56             :   NS_IMETHOD GetFailures(uint32_t *failureCount, int32_t** indices, char ***failures) override;
      57             :   NS_IMETHOD_(void) LogFailure(const nsACString &failure) override;
      58             :   NS_IMETHOD GetInfo(JSContext*, JS::MutableHandle<JS::Value>) override;
      59             :   NS_IMETHOD GetFeatures(JSContext*, JS::MutableHandle<JS::Value>) override;
      60             :   NS_IMETHOD GetFeatureLog(JSContext*, JS::MutableHandle<JS::Value>) override;
      61             :   NS_IMETHOD GetActiveCrashGuards(JSContext*, JS::MutableHandle<JS::Value>) override;
      62             :   NS_IMETHOD GetContentBackend(nsAString & aContentBackend) override;
      63             :   NS_IMETHOD GetUsingGPUProcess(bool *aOutValue) override;
      64             :   NS_IMETHOD GetWebRenderEnabled(bool* aWebRenderEnabled) override;
      65             : 
      66             :   // Initialization function. If you override this, you must call this class's
      67             :   // version of Init first.
      68             :   // We need Init to be called separately from the constructor so we can
      69             :   // register as an observer after all derived classes have been constructed
      70             :   // and we know we have a non-zero refcount.
      71             :   // Ideally, Init() would be void-return, but the rules of
      72             :   // NS_GENERIC_FACTORY_CONSTRUCTOR_INIT require it be nsresult return.
      73             :   virtual nsresult Init();
      74             :   
      75             :   // only useful on X11
      76           0 :   NS_IMETHOD_(void) GetData() override { }
      77             : 
      78             :   static void AddCollector(GfxInfoCollectorBase* collector);
      79             :   static void RemoveCollector(GfxInfoCollectorBase* collector);
      80             : 
      81             :   static nsTArray<GfxDriverInfo>* mDriverInfo;
      82             :   static nsTArray<mozilla::dom::GfxInfoFeatureStatus>* mFeatureStatus;
      83             :   static bool mDriverInfoObserverInitialized;
      84             :   static bool mShutdownOccurred;
      85             : 
      86           0 :   virtual nsString Model() { return EmptyString(); }
      87           0 :   virtual nsString Hardware() { return EmptyString(); }
      88           0 :   virtual nsString Product() { return EmptyString(); }
      89           0 :   virtual nsString Manufacturer() { return EmptyString(); }
      90           0 :   virtual uint32_t OperatingSystemVersion() { return 0; }
      91             : 
      92             :   // Convenience to get the application version
      93             :   static const nsCString& GetApplicationVersion();
      94             : 
      95           0 :   virtual nsresult FindMonitors(JSContext* cx, JS::HandleObject array) {
      96           0 :     return NS_ERROR_NOT_IMPLEMENTED;
      97             :   }
      98             : 
      99             :   static void SetFeatureStatus(
     100             :       const nsTArray<mozilla::dom::GfxInfoFeatureStatus>& aFS);
     101             : 
     102             : protected:
     103             : 
     104             :   virtual ~GfxInfoBase();
     105             : 
     106             :   virtual nsresult GetFeatureStatusImpl(int32_t aFeature, int32_t* aStatus,
     107             :                                         nsAString& aSuggestedDriverVersion,
     108             :                                         const nsTArray<GfxDriverInfo>& aDriverInfo,
     109             :                                         nsACString& aFailureId,
     110             :                                         OperatingSystem* aOS = nullptr);
     111             : 
     112             :   // Gets the driver info table. Used by GfxInfoBase to check for general cases
     113             :   // (while subclasses check for more specific ones).
     114             :   virtual const nsTArray<GfxDriverInfo>& GetGfxDriverInfo() = 0;
     115             : 
     116             :   virtual void DescribeFeatures(JSContext* aCx, JS::Handle<JSObject*> obj);
     117             :   bool InitFeatureObject(
     118             :     JSContext* aCx,
     119             :     JS::Handle<JSObject*> aContainer,
     120             :     const char* aName,
     121             :     int32_t aFeature,
     122             :     const Maybe<mozilla::gfx::FeatureStatus>& aKnownStatus,
     123             :     JS::MutableHandle<JSObject*> aOutObj);
     124             : 
     125             :   NS_IMETHOD ControlGPUProcessForXPCShell(bool aEnable, bool *_retval) override;
     126             : 
     127             : private:
     128             :   virtual int32_t FindBlocklistedDeviceInList(const nsTArray<GfxDriverInfo>& aDriverInfo,
     129             :                                               nsAString& aSuggestedVersion,
     130             :                                               int32_t aFeature,
     131             :                                               nsACString &aFailureId,
     132             :                                               OperatingSystem os);
     133             : 
     134             :   void EvaluateDownloadedBlacklist(nsTArray<GfxDriverInfo>& aDriverInfo);
     135             : 
     136             :   bool BuildFeatureStateLog(JSContext* aCx, const gfx::FeatureState& aFeature,
     137             :                             JS::MutableHandle<JS::Value> aOut);
     138             : 
     139             :   Mutex mMutex;
     140             : 
     141             : };
     142             : 
     143             : } // namespace widget
     144             : } // namespace mozilla
     145             : 
     146             : #endif /* __mozilla_widget_GfxInfoBase_h__ */

Generated by: LCOV version 1.13