dom/camera/DOMCameraManager.h

Thu, 15 Jan 2015 15:55:04 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:55:04 +0100
branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
permissions
-rw-r--r--

Back out 97036ab72558 which inappropriately compared turds to third parties.

michael@0 1 /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
michael@0 2 /* vim: set ts=2 et sw=2 tw=40: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
michael@0 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef DOM_CAMERA_DOMCAMERAMANAGER_H
michael@0 8 #define DOM_CAMERA_DOMCAMERAMANAGER_H
michael@0 9
michael@0 10 #include "mozilla/dom/BindingDeclarations.h"
michael@0 11 #include "nsCOMPtr.h"
michael@0 12 #include "nsAutoPtr.h"
michael@0 13 #include "nsIObserver.h"
michael@0 14 #include "nsHashKeys.h"
michael@0 15 #include "nsWrapperCache.h"
michael@0 16 #include "nsWeakReference.h"
michael@0 17 #include "nsClassHashtable.h"
michael@0 18 #include "nsCycleCollectionParticipant.h"
michael@0 19 #include "mozilla/Attributes.h"
michael@0 20
michael@0 21 class nsPIDOMWindow;
michael@0 22
michael@0 23 namespace mozilla {
michael@0 24 class ErrorResult;
michael@0 25 class nsDOMCameraControl;
michael@0 26 namespace dom {
michael@0 27 class CameraConfiguration;
michael@0 28 class GetCameraCallback;
michael@0 29 class CameraErrorCallback;
michael@0 30 }
michael@0 31 }
michael@0 32
michael@0 33 typedef nsTArray<nsRefPtr<mozilla::nsDOMCameraControl> > CameraControls;
michael@0 34 typedef nsClassHashtable<nsUint64HashKey, CameraControls> WindowTable;
michael@0 35 typedef mozilla::dom::Optional<mozilla::dom::OwningNonNull<mozilla::dom::CameraErrorCallback>>
michael@0 36 OptionalNonNullCameraErrorCallback;
michael@0 37
michael@0 38 class nsDOMCameraManager MOZ_FINAL
michael@0 39 : public nsIObserver
michael@0 40 , public nsSupportsWeakReference
michael@0 41 , public nsWrapperCache
michael@0 42 {
michael@0 43 public:
michael@0 44 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
michael@0 45 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsDOMCameraManager,
michael@0 46 nsIObserver)
michael@0 47 NS_DECL_NSIOBSERVER
michael@0 48
michael@0 49 // Because this header's filename doesn't match its C++ or DOM-facing
michael@0 50 // classname, we can't rely on the [Func="..."] WebIDL tag to implicitly
michael@0 51 // include the right header for us; instead we must explicitly include a
michael@0 52 // HasSupport() method in each header. We can get rid of these with the
michael@0 53 // Great Renaming proposed in bug 983177.
michael@0 54 static bool HasSupport(JSContext* aCx, JSObject* aGlobal);
michael@0 55
michael@0 56 static bool CheckPermission(nsPIDOMWindow* aWindow);
michael@0 57 static already_AddRefed<nsDOMCameraManager>
michael@0 58 CreateInstance(nsPIDOMWindow* aWindow);
michael@0 59 static bool IsWindowStillActive(uint64_t aWindowId);
michael@0 60
michael@0 61 void Register(mozilla::nsDOMCameraControl* aDOMCameraControl);
michael@0 62 void OnNavigation(uint64_t aWindowId);
michael@0 63
michael@0 64 void PermissionAllowed(uint32_t aCameraId,
michael@0 65 const mozilla::dom::CameraConfiguration& aOptions,
michael@0 66 mozilla::dom::GetCameraCallback* aOnSuccess,
michael@0 67 mozilla::dom::CameraErrorCallback* aOnError);
michael@0 68
michael@0 69 void PermissionCancelled(uint32_t aCameraId,
michael@0 70 const mozilla::dom::CameraConfiguration& aOptions,
michael@0 71 mozilla::dom::GetCameraCallback* aOnSuccess,
michael@0 72 mozilla::dom::CameraErrorCallback* aOnError);
michael@0 73
michael@0 74 // WebIDL
michael@0 75 void GetCamera(const nsAString& aCamera,
michael@0 76 const mozilla::dom::CameraConfiguration& aOptions,
michael@0 77 mozilla::dom::GetCameraCallback& aOnSuccess,
michael@0 78 const OptionalNonNullCameraErrorCallback& aOnError,
michael@0 79 mozilla::ErrorResult& aRv);
michael@0 80 void GetListOfCameras(nsTArray<nsString>& aList, mozilla::ErrorResult& aRv);
michael@0 81
michael@0 82 nsPIDOMWindow* GetParentObject() const { return mWindow; }
michael@0 83 virtual JSObject* WrapObject(JSContext* aCx)
michael@0 84 MOZ_OVERRIDE;
michael@0 85
michael@0 86 protected:
michael@0 87 void XpComShutdown();
michael@0 88 void Shutdown(uint64_t aWindowId);
michael@0 89 ~nsDOMCameraManager();
michael@0 90
michael@0 91 private:
michael@0 92 nsDOMCameraManager() MOZ_DELETE;
michael@0 93 nsDOMCameraManager(nsPIDOMWindow* aWindow);
michael@0 94 nsDOMCameraManager(const nsDOMCameraManager&) MOZ_DELETE;
michael@0 95 nsDOMCameraManager& operator=(const nsDOMCameraManager&) MOZ_DELETE;
michael@0 96
michael@0 97 protected:
michael@0 98 uint64_t mWindowId;
michael@0 99 uint32_t mPermission;
michael@0 100 nsCOMPtr<nsPIDOMWindow> mWindow;
michael@0 101 /**
michael@0 102 * 'sActiveWindows' is only ever accessed while in the Main Thread,
michael@0 103 * so it is not otherwise protected.
michael@0 104 */
michael@0 105 static ::WindowTable* sActiveWindows;
michael@0 106 };
michael@0 107
michael@0 108 #endif // DOM_CAMERA_DOMCAMERAMANAGER_H

mercurial