Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 3 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | #ifndef DOM_CAMERA_CAMERACONTROLLISTENER_H |
michael@0 | 6 | #define DOM_CAMERA_CAMERACONTROLLISTENER_H |
michael@0 | 7 | |
michael@0 | 8 | #include <stdint.h> |
michael@0 | 9 | #include "ICameraControl.h" |
michael@0 | 10 | |
michael@0 | 11 | namespace mozilla { |
michael@0 | 12 | |
michael@0 | 13 | namespace layers { |
michael@0 | 14 | class Image; |
michael@0 | 15 | } |
michael@0 | 16 | |
michael@0 | 17 | class CameraControlListener |
michael@0 | 18 | { |
michael@0 | 19 | public: |
michael@0 | 20 | CameraControlListener() |
michael@0 | 21 | { |
michael@0 | 22 | MOZ_COUNT_CTOR(CameraControlListener); |
michael@0 | 23 | } |
michael@0 | 24 | |
michael@0 | 25 | protected: |
michael@0 | 26 | // Protected destructor, to discourage deletion outside of Release(): |
michael@0 | 27 | virtual ~CameraControlListener() |
michael@0 | 28 | { |
michael@0 | 29 | MOZ_COUNT_DTOR(CameraControlListener); |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | public: |
michael@0 | 33 | NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CameraControlListener); |
michael@0 | 34 | |
michael@0 | 35 | enum HardwareState |
michael@0 | 36 | { |
michael@0 | 37 | kHardwareOpen, |
michael@0 | 38 | kHardwareClosed |
michael@0 | 39 | }; |
michael@0 | 40 | virtual void OnHardwareStateChange(HardwareState aState) { } |
michael@0 | 41 | |
michael@0 | 42 | enum PreviewState |
michael@0 | 43 | { |
michael@0 | 44 | kPreviewStopped, |
michael@0 | 45 | kPreviewPaused, |
michael@0 | 46 | kPreviewStarted |
michael@0 | 47 | }; |
michael@0 | 48 | virtual void OnPreviewStateChange(PreviewState aState) { } |
michael@0 | 49 | |
michael@0 | 50 | enum RecorderState |
michael@0 | 51 | { |
michael@0 | 52 | kRecorderStopped, |
michael@0 | 53 | kRecorderStarted, |
michael@0 | 54 | #ifdef MOZ_B2G_CAMERA |
michael@0 | 55 | kFileSizeLimitReached, |
michael@0 | 56 | kVideoLengthLimitReached, |
michael@0 | 57 | kTrackCompleted, |
michael@0 | 58 | kTrackFailed, |
michael@0 | 59 | kMediaRecorderFailed, |
michael@0 | 60 | kMediaServerFailed |
michael@0 | 61 | #endif |
michael@0 | 62 | }; |
michael@0 | 63 | enum { kNoTrackNumber = -1 }; |
michael@0 | 64 | virtual void OnRecorderStateChange(RecorderState aState, int32_t aStatus, int32_t aTrackNum) { } |
michael@0 | 65 | |
michael@0 | 66 | virtual void OnShutter() { } |
michael@0 | 67 | virtual bool OnNewPreviewFrame(layers::Image* aFrame, uint32_t aWidth, uint32_t aHeight) |
michael@0 | 68 | { |
michael@0 | 69 | return false; |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | class CameraListenerConfiguration : public ICameraControl::Configuration |
michael@0 | 73 | { |
michael@0 | 74 | public: |
michael@0 | 75 | uint32_t mMaxMeteringAreas; |
michael@0 | 76 | uint32_t mMaxFocusAreas; |
michael@0 | 77 | }; |
michael@0 | 78 | virtual void OnConfigurationChange(const CameraListenerConfiguration& aConfiguration) { } |
michael@0 | 79 | |
michael@0 | 80 | virtual void OnAutoFocusComplete(bool aAutoFocusSucceeded) { } |
michael@0 | 81 | virtual void OnAutoFocusMoving(bool aIsMoving) { } |
michael@0 | 82 | virtual void OnTakePictureComplete(uint8_t* aData, uint32_t aLength, const nsAString& aMimeType) { } |
michael@0 | 83 | virtual void OnFacesDetected(const nsTArray<ICameraControl::Face>& aFaces) { } |
michael@0 | 84 | |
michael@0 | 85 | enum CameraErrorContext |
michael@0 | 86 | { |
michael@0 | 87 | kInStartCamera, |
michael@0 | 88 | kInStopCamera, |
michael@0 | 89 | kInAutoFocus, |
michael@0 | 90 | kInStartFaceDetection, |
michael@0 | 91 | kInStopFaceDetection, |
michael@0 | 92 | kInTakePicture, |
michael@0 | 93 | kInStartRecording, |
michael@0 | 94 | kInStopRecording, |
michael@0 | 95 | kInSetConfiguration, |
michael@0 | 96 | kInStartPreview, |
michael@0 | 97 | kInStopPreview, |
michael@0 | 98 | kInResumeContinuousFocus, |
michael@0 | 99 | kInUnspecified |
michael@0 | 100 | }; |
michael@0 | 101 | enum CameraError |
michael@0 | 102 | { |
michael@0 | 103 | kErrorApiFailed, |
michael@0 | 104 | kErrorInitFailed, |
michael@0 | 105 | kErrorInvalidConfiguration, |
michael@0 | 106 | kErrorServiceFailed, |
michael@0 | 107 | kErrorSetPictureSizeFailed, |
michael@0 | 108 | kErrorSetThumbnailSizeFailed, |
michael@0 | 109 | kErrorUnknown |
michael@0 | 110 | }; |
michael@0 | 111 | virtual void OnError(CameraErrorContext aContext, CameraError aError) { } |
michael@0 | 112 | }; |
michael@0 | 113 | |
michael@0 | 114 | } // namespace mozilla |
michael@0 | 115 | |
michael@0 | 116 | #endif // DOM_CAMERA_CAMERACONTROLLISTENER_H |