dom/indexedDB/IndexedDatabaseInlines.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 IndexedDatabaseInlines_h
michael@0 8 #define IndexedDatabaseInlines_h
michael@0 9
michael@0 10 #ifndef mozilla_dom_indexeddb_indexeddatabase_h__
michael@0 11 #error Must include IndexedDatabase.h first
michael@0 12 #endif
michael@0 13
michael@0 14 BEGIN_INDEXEDDB_NAMESPACE
michael@0 15
michael@0 16 inline
michael@0 17 StructuredCloneWriteInfo::StructuredCloneWriteInfo()
michael@0 18 : mTransaction(nullptr),
michael@0 19 mOffsetToKeyProp(0)
michael@0 20 {
michael@0 21 }
michael@0 22
michael@0 23 inline
michael@0 24 StructuredCloneWriteInfo::StructuredCloneWriteInfo(
michael@0 25 StructuredCloneWriteInfo&& aCloneWriteInfo)
michael@0 26 : mCloneBuffer(Move(aCloneWriteInfo.mCloneBuffer))
michael@0 27 , mTransaction(aCloneWriteInfo.mTransaction)
michael@0 28 , mOffsetToKeyProp(aCloneWriteInfo.mOffsetToKeyProp)
michael@0 29 {
michael@0 30 mFiles.SwapElements(aCloneWriteInfo.mFiles);
michael@0 31 aCloneWriteInfo.mTransaction = nullptr;
michael@0 32 aCloneWriteInfo.mOffsetToKeyProp = 0;
michael@0 33 }
michael@0 34
michael@0 35 inline
michael@0 36 bool
michael@0 37 StructuredCloneWriteInfo::SetFromSerialized(
michael@0 38 const SerializedStructuredCloneWriteInfo& aOther)
michael@0 39 {
michael@0 40 if (!aOther.dataLength) {
michael@0 41 mCloneBuffer.clear();
michael@0 42 }
michael@0 43 else if (!mCloneBuffer.copy(aOther.data, aOther.dataLength)) {
michael@0 44 return false;
michael@0 45 }
michael@0 46
michael@0 47 mFiles.Clear();
michael@0 48 mOffsetToKeyProp = aOther.offsetToKeyProp;
michael@0 49 return true;
michael@0 50 }
michael@0 51
michael@0 52 inline
michael@0 53 StructuredCloneReadInfo::StructuredCloneReadInfo()
michael@0 54 : mDatabase(nullptr)
michael@0 55 {
michael@0 56 }
michael@0 57
michael@0 58 inline StructuredCloneReadInfo&
michael@0 59 StructuredCloneReadInfo::operator=(StructuredCloneReadInfo&& aCloneReadInfo)
michael@0 60 {
michael@0 61 MOZ_ASSERT(&aCloneReadInfo != this);
michael@0 62
michael@0 63 mCloneBuffer = Move(aCloneReadInfo.mCloneBuffer);
michael@0 64 mFiles.Clear();
michael@0 65 mFiles.SwapElements(aCloneReadInfo.mFiles);
michael@0 66 mDatabase = aCloneReadInfo.mDatabase;
michael@0 67 aCloneReadInfo.mDatabase = nullptr;
michael@0 68 return *this;
michael@0 69 }
michael@0 70
michael@0 71 inline
michael@0 72 bool
michael@0 73 StructuredCloneReadInfo::SetFromSerialized(
michael@0 74 const SerializedStructuredCloneReadInfo& aOther)
michael@0 75 {
michael@0 76 if (aOther.dataLength &&
michael@0 77 !mCloneBuffer.copy(aOther.data, aOther.dataLength)) {
michael@0 78 return false;
michael@0 79 }
michael@0 80
michael@0 81 mFiles.Clear();
michael@0 82 return true;
michael@0 83 }
michael@0 84
michael@0 85 inline
michael@0 86 void
michael@0 87 AppendConditionClause(const nsACString& aColumnName,
michael@0 88 const nsACString& aArgName,
michael@0 89 bool aLessThan,
michael@0 90 bool aEquals,
michael@0 91 nsACString& aResult)
michael@0 92 {
michael@0 93 aResult += NS_LITERAL_CSTRING(" AND ") + aColumnName +
michael@0 94 NS_LITERAL_CSTRING(" ");
michael@0 95
michael@0 96 if (aLessThan) {
michael@0 97 aResult.AppendLiteral("<");
michael@0 98 }
michael@0 99 else {
michael@0 100 aResult.AppendLiteral(">");
michael@0 101 }
michael@0 102
michael@0 103 if (aEquals) {
michael@0 104 aResult.AppendLiteral("=");
michael@0 105 }
michael@0 106
michael@0 107 aResult += NS_LITERAL_CSTRING(" :") + aArgName;
michael@0 108 }
michael@0 109
michael@0 110 END_INDEXEDDB_NAMESPACE
michael@0 111
michael@0 112 #endif

mercurial