1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef DOM_CAMERA_CAMERAPREFERENCES_H
7 #define DOM_CAMERA_CAMERAPREFERENCES_H
10 #include "nsIObserver.h"
11 #ifdef MOZ_WIDGET_GONK
12 #include "mozilla/StaticPtr.h"
15 #if defined(MOZ_HAVE_CXX11_STRONG_ENUMS) || defined(MOZ_HAVE_CXX11_ENUM_TYPE)
16 // Older compilers that don't support strongly-typed enums
17 // just typedef uint32_t to nsresult, which results in conflicting
18 // overloaded members in CameraPreferences.
19 #define CAMERAPREFERENCES_HAVE_SEPARATE_UINT32_AND_NSRESULT
24 template<class T
> class StaticAutoPtr
;
26 class CameraPreferences
27 #ifdef MOZ_WIDGET_GONK
32 #ifdef MOZ_WIDGET_GONK
37 static bool Initialize();
38 static void Shutdown();
40 static bool GetPref(const char* aPref
, nsACString
& aVal
);
41 #ifdef CAMERAPREFERENCES_HAVE_SEPARATE_UINT32_AND_NSRESULT
42 static bool GetPref(const char* aPref
, nsresult
& aVal
);
44 static bool GetPref(const char* aPref
, uint32_t& aVal
);
45 static bool GetPref(const char* aPref
, bool& aVal
);
48 static const uint32_t kPrefNotFound
= UINT32_MAX
;
49 static uint32_t PrefToIndex(const char* aPref
);
51 static void PreferenceChanged(const char* aPref
, void* aClosure
);
52 #ifdef CAMERAPREFERENCES_HAVE_SEPARATE_UINT32_AND_NSRESULT
53 static nsresult
UpdatePref(const char* aPref
, nsresult
& aVar
);
55 static nsresult
UpdatePref(const char* aPref
, uint32_t& aVar
);
56 static nsresult
UpdatePref(const char* aPref
, nsACString
& aVar
);
57 static nsresult
UpdatePref(const char* aPref
, bool& aVar
);
66 const char* const mPref
;
67 PrefValueType mValueType
;
69 // The 'mAsVoid' member must be first and is required to allow 'mValue'
70 // to be initialized with any pointer type, as not all of our platforms
71 // support the use of designated initializers; in their absence, only
72 // the first element of a union can be statically initialized, and
73 // 'void*' lets us stuff any pointer type into it.
75 StaticAutoPtr
<nsCString
>* mAsCString
;
76 nsresult
* mAsNsResult
;
83 static StaticAutoPtr
<nsCString
> sPrefTestEnabled
;
84 static StaticAutoPtr
<nsCString
> sPrefHardwareTest
;
85 static StaticAutoPtr
<nsCString
> sPrefGonkParameters
;
87 static nsresult sPrefCameraControlMethodErrorOverride
;
88 static nsresult sPrefCameraControlAsyncErrorOverride
;
90 static uint32_t sPrefCameraControlLowMemoryThresholdMB
;
92 static bool sPrefCameraParametersIsLowMemory
;
94 #ifdef MOZ_WIDGET_GONK
95 static StaticRefPtr
<CameraPreferences
> sObserver
;
97 nsresult
PreinitCameraHardware();
100 // Objects may be instantiated for use as observers.
101 CameraPreferences() { }
102 virtual ~CameraPreferences() { }
105 // Static class only.
107 ~CameraPreferences();
111 } // namespace mozilla
113 #endif // DOM_CAMERA_CAMERAPREFERENCES_H