MutableFileBase.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* -*- Mode: C++; tab-width: 8; 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 file,
  4. * You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef mozilla_dom_MutableFile_h
  6. #define mozilla_dom_MutableFile_h
  7. #include "mozilla/dom/FileHandleCommon.h"
  8. #include "nscore.h"
  9. template <class> struct already_AddRefed;
  10. class nsISupports;
  11. class nsString;
  12. struct PRThread;
  13. namespace mozilla {
  14. namespace dom {
  15. class BackgroundMutableFileChildBase;
  16. class BlobImpl;
  17. class File;
  18. class FileHandleBase;
  19. /**
  20. * This class provides a base for MutableFile implementations.
  21. * (for example IDBMutableFile provides IndexedDB specific implementation).
  22. */
  23. class MutableFileBase
  24. : public RefCountedThreadObject
  25. {
  26. protected:
  27. BackgroundMutableFileChildBase* mBackgroundActor;
  28. public:
  29. BackgroundMutableFileChildBase*
  30. GetBackgroundActor() const
  31. {
  32. AssertIsOnOwningThread();
  33. return mBackgroundActor;
  34. }
  35. void
  36. ClearBackgroundActor()
  37. {
  38. AssertIsOnOwningThread();
  39. mBackgroundActor = nullptr;
  40. }
  41. virtual const nsString&
  42. Name() const = 0;
  43. virtual const nsString&
  44. Type() const = 0;
  45. virtual bool
  46. IsInvalidated() = 0;
  47. virtual already_AddRefed<File>
  48. CreateFileFor(BlobImpl* aBlobImpl,
  49. FileHandleBase* aFileHandle) = 0;
  50. protected:
  51. MutableFileBase(DEBUGONLY(PRThread* aOwningThread,)
  52. BackgroundMutableFileChildBase* aActor);
  53. virtual ~MutableFileBase();
  54. };
  55. } // namespace dom
  56. } // namespace mozilla
  57. #endif // mozilla_dom_MutableFile_h