dom/indexedDB/IndexedDatabaseInlines.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/indexedDB/IndexedDatabaseInlines.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,112 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim: set ts=2 et sw=2 tw=80: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef IndexedDatabaseInlines_h
    1.11 +#define IndexedDatabaseInlines_h
    1.12 +
    1.13 +#ifndef mozilla_dom_indexeddb_indexeddatabase_h__
    1.14 +#error Must include IndexedDatabase.h first
    1.15 +#endif
    1.16 +
    1.17 +BEGIN_INDEXEDDB_NAMESPACE
    1.18 +
    1.19 +inline
    1.20 +StructuredCloneWriteInfo::StructuredCloneWriteInfo()
    1.21 +: mTransaction(nullptr),
    1.22 +  mOffsetToKeyProp(0)
    1.23 +{
    1.24 +}
    1.25 +
    1.26 +inline
    1.27 +StructuredCloneWriteInfo::StructuredCloneWriteInfo(
    1.28 +                                    StructuredCloneWriteInfo&& aCloneWriteInfo)
    1.29 +: mCloneBuffer(Move(aCloneWriteInfo.mCloneBuffer))
    1.30 +, mTransaction(aCloneWriteInfo.mTransaction)
    1.31 +, mOffsetToKeyProp(aCloneWriteInfo.mOffsetToKeyProp)
    1.32 +{
    1.33 +  mFiles.SwapElements(aCloneWriteInfo.mFiles);
    1.34 +  aCloneWriteInfo.mTransaction = nullptr;
    1.35 +  aCloneWriteInfo.mOffsetToKeyProp = 0;
    1.36 +}
    1.37 +
    1.38 +inline
    1.39 +bool
    1.40 +StructuredCloneWriteInfo::SetFromSerialized(
    1.41 +                               const SerializedStructuredCloneWriteInfo& aOther)
    1.42 +{
    1.43 +  if (!aOther.dataLength) {
    1.44 +    mCloneBuffer.clear();
    1.45 +  }
    1.46 +  else if (!mCloneBuffer.copy(aOther.data, aOther.dataLength)) {
    1.47 +    return false;
    1.48 +  }
    1.49 +
    1.50 +  mFiles.Clear();
    1.51 +  mOffsetToKeyProp = aOther.offsetToKeyProp;
    1.52 +  return true;
    1.53 +}
    1.54 +
    1.55 +inline
    1.56 +StructuredCloneReadInfo::StructuredCloneReadInfo()
    1.57 +: mDatabase(nullptr)
    1.58 +{
    1.59 +}
    1.60 +
    1.61 +inline StructuredCloneReadInfo&
    1.62 +StructuredCloneReadInfo::operator=(StructuredCloneReadInfo&& aCloneReadInfo)
    1.63 +{
    1.64 +  MOZ_ASSERT(&aCloneReadInfo != this);
    1.65 +
    1.66 +  mCloneBuffer = Move(aCloneReadInfo.mCloneBuffer);
    1.67 +  mFiles.Clear();
    1.68 +  mFiles.SwapElements(aCloneReadInfo.mFiles);
    1.69 +  mDatabase = aCloneReadInfo.mDatabase;
    1.70 +  aCloneReadInfo.mDatabase = nullptr;
    1.71 +  return *this;
    1.72 +}
    1.73 +
    1.74 +inline
    1.75 +bool
    1.76 +StructuredCloneReadInfo::SetFromSerialized(
    1.77 +                                const SerializedStructuredCloneReadInfo& aOther)
    1.78 +{
    1.79 +  if (aOther.dataLength &&
    1.80 +      !mCloneBuffer.copy(aOther.data, aOther.dataLength)) {
    1.81 +    return false;
    1.82 +  }
    1.83 +
    1.84 +  mFiles.Clear();
    1.85 +  return true;
    1.86 +}
    1.87 +
    1.88 +inline
    1.89 +void
    1.90 +AppendConditionClause(const nsACString& aColumnName,
    1.91 +                      const nsACString& aArgName,
    1.92 +                      bool aLessThan,
    1.93 +                      bool aEquals,
    1.94 +                      nsACString& aResult)
    1.95 +{
    1.96 +  aResult += NS_LITERAL_CSTRING(" AND ") + aColumnName +
    1.97 +             NS_LITERAL_CSTRING(" ");
    1.98 +
    1.99 +  if (aLessThan) {
   1.100 +    aResult.AppendLiteral("<");
   1.101 +  }
   1.102 +  else {
   1.103 +    aResult.AppendLiteral(">");
   1.104 +  }
   1.105 +
   1.106 +  if (aEquals) {
   1.107 +    aResult.AppendLiteral("=");
   1.108 +  }
   1.109 +
   1.110 +  aResult += NS_LITERAL_CSTRING(" :") + aArgName;
   1.111 +}
   1.112 +
   1.113 +END_INDEXEDDB_NAMESPACE
   1.114 +
   1.115 +#endif

mercurial