dom/quota/FileStreams.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim: set ts=2 et sw=2 tw=80: */
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
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef mozilla_dom_quota_filestreams_h__
michael@0 8 #define mozilla_dom_quota_filestreams_h__
michael@0 9
michael@0 10 #include "QuotaCommon.h"
michael@0 11
michael@0 12 #include "nsFileStreams.h"
michael@0 13
michael@0 14 #include "PersistenceType.h"
michael@0 15 #include "QuotaObject.h"
michael@0 16
michael@0 17 BEGIN_QUOTA_NAMESPACE
michael@0 18
michael@0 19 template <class FileStreamBase>
michael@0 20 class FileQuotaStream : public FileStreamBase
michael@0 21 {
michael@0 22 public:
michael@0 23 // nsFileStreamBase override
michael@0 24 NS_IMETHOD
michael@0 25 SetEOF() MOZ_OVERRIDE;
michael@0 26
michael@0 27 NS_IMETHOD
michael@0 28 Close() MOZ_OVERRIDE;
michael@0 29
michael@0 30 protected:
michael@0 31 FileQuotaStream(PersistenceType aPersistenceType, const nsACString& aGroup,
michael@0 32 const nsACString& aOrigin)
michael@0 33 : mPersistenceType(aPersistenceType), mGroup(aGroup), mOrigin(aOrigin)
michael@0 34 { }
michael@0 35
michael@0 36 // nsFileStreamBase override
michael@0 37 virtual nsresult
michael@0 38 DoOpen() MOZ_OVERRIDE;
michael@0 39
michael@0 40 PersistenceType mPersistenceType;
michael@0 41 nsCString mGroup;
michael@0 42 nsCString mOrigin;
michael@0 43 nsRefPtr<QuotaObject> mQuotaObject;
michael@0 44 };
michael@0 45
michael@0 46 template <class FileStreamBase>
michael@0 47 class FileQuotaStreamWithWrite : public FileQuotaStream<FileStreamBase>
michael@0 48 {
michael@0 49 public:
michael@0 50 // nsFileStreamBase override
michael@0 51 NS_IMETHOD
michael@0 52 Write(const char* aBuf, uint32_t aCount, uint32_t* _retval) MOZ_OVERRIDE;
michael@0 53
michael@0 54 protected:
michael@0 55 FileQuotaStreamWithWrite(PersistenceType aPersistenceType,
michael@0 56 const nsACString& aGroup, const nsACString& aOrigin)
michael@0 57 : FileQuotaStream<FileStreamBase>(aPersistenceType, aGroup, aOrigin)
michael@0 58 { }
michael@0 59 };
michael@0 60
michael@0 61 class FileInputStream : public FileQuotaStream<nsFileInputStream>
michael@0 62 {
michael@0 63 public:
michael@0 64 NS_DECL_ISUPPORTS_INHERITED
michael@0 65
michael@0 66 static already_AddRefed<FileInputStream>
michael@0 67 Create(PersistenceType aPersistenceType, const nsACString& aGroup,
michael@0 68 const nsACString& aOrigin, nsIFile* aFile, int32_t aIOFlags = -1,
michael@0 69 int32_t aPerm = -1, int32_t aBehaviorFlags = 0);
michael@0 70
michael@0 71 private:
michael@0 72 FileInputStream(PersistenceType aPersistenceType, const nsACString& aGroup,
michael@0 73 const nsACString& aOrigin)
michael@0 74 : FileQuotaStream<nsFileInputStream>(aPersistenceType, aGroup, aOrigin)
michael@0 75 { }
michael@0 76
michael@0 77 virtual ~FileInputStream() {
michael@0 78 Close();
michael@0 79 }
michael@0 80 };
michael@0 81
michael@0 82 class FileOutputStream : public FileQuotaStreamWithWrite<nsFileOutputStream>
michael@0 83 {
michael@0 84 public:
michael@0 85 NS_DECL_ISUPPORTS_INHERITED
michael@0 86
michael@0 87 static already_AddRefed<FileOutputStream>
michael@0 88 Create(PersistenceType aPersistenceType, const nsACString& aGroup,
michael@0 89 const nsACString& aOrigin, nsIFile* aFile, int32_t aIOFlags = -1,
michael@0 90 int32_t aPerm = -1, int32_t aBehaviorFlags = 0);
michael@0 91
michael@0 92 private:
michael@0 93 FileOutputStream(PersistenceType aPersistenceType, const nsACString& aGroup,
michael@0 94 const nsACString& aOrigin)
michael@0 95 : FileQuotaStreamWithWrite<nsFileOutputStream>(aPersistenceType, aGroup,
michael@0 96 aOrigin)
michael@0 97 { }
michael@0 98
michael@0 99 virtual ~FileOutputStream() {
michael@0 100 Close();
michael@0 101 }
michael@0 102 };
michael@0 103
michael@0 104 class FileStream : public FileQuotaStreamWithWrite<nsFileStream>
michael@0 105 {
michael@0 106 public:
michael@0 107 NS_DECL_ISUPPORTS_INHERITED
michael@0 108
michael@0 109 static already_AddRefed<FileStream>
michael@0 110 Create(PersistenceType aPersistenceType, const nsACString& aGroup,
michael@0 111 const nsACString& aOrigin, nsIFile* aFile, int32_t aIOFlags = -1,
michael@0 112 int32_t aPerm = -1, int32_t aBehaviorFlags = 0);
michael@0 113
michael@0 114 private:
michael@0 115 FileStream(PersistenceType aPersistenceType, const nsACString& aGroup,
michael@0 116 const nsACString& aOrigin)
michael@0 117 : FileQuotaStreamWithWrite<nsFileStream>(aPersistenceType, aGroup, aOrigin)
michael@0 118 { }
michael@0 119
michael@0 120 virtual ~FileStream() {
michael@0 121 Close();
michael@0 122 }
michael@0 123 };
michael@0 124
michael@0 125 END_QUOTA_NAMESPACE
michael@0 126
michael@0 127 #endif /* mozilla_dom_quota_filestreams_h__ */

mercurial