dom/indexedDB/IndexedDatabaseInlines.h

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

     1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* vim: set ts=2 et sw=2 tw=80: */
     3 /* This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 #ifndef IndexedDatabaseInlines_h
     8 #define IndexedDatabaseInlines_h
    10 #ifndef mozilla_dom_indexeddb_indexeddatabase_h__
    11 #error Must include IndexedDatabase.h first
    12 #endif
    14 BEGIN_INDEXEDDB_NAMESPACE
    16 inline
    17 StructuredCloneWriteInfo::StructuredCloneWriteInfo()
    18 : mTransaction(nullptr),
    19   mOffsetToKeyProp(0)
    20 {
    21 }
    23 inline
    24 StructuredCloneWriteInfo::StructuredCloneWriteInfo(
    25                                     StructuredCloneWriteInfo&& aCloneWriteInfo)
    26 : mCloneBuffer(Move(aCloneWriteInfo.mCloneBuffer))
    27 , mTransaction(aCloneWriteInfo.mTransaction)
    28 , mOffsetToKeyProp(aCloneWriteInfo.mOffsetToKeyProp)
    29 {
    30   mFiles.SwapElements(aCloneWriteInfo.mFiles);
    31   aCloneWriteInfo.mTransaction = nullptr;
    32   aCloneWriteInfo.mOffsetToKeyProp = 0;
    33 }
    35 inline
    36 bool
    37 StructuredCloneWriteInfo::SetFromSerialized(
    38                                const SerializedStructuredCloneWriteInfo& aOther)
    39 {
    40   if (!aOther.dataLength) {
    41     mCloneBuffer.clear();
    42   }
    43   else if (!mCloneBuffer.copy(aOther.data, aOther.dataLength)) {
    44     return false;
    45   }
    47   mFiles.Clear();
    48   mOffsetToKeyProp = aOther.offsetToKeyProp;
    49   return true;
    50 }
    52 inline
    53 StructuredCloneReadInfo::StructuredCloneReadInfo()
    54 : mDatabase(nullptr)
    55 {
    56 }
    58 inline StructuredCloneReadInfo&
    59 StructuredCloneReadInfo::operator=(StructuredCloneReadInfo&& aCloneReadInfo)
    60 {
    61   MOZ_ASSERT(&aCloneReadInfo != this);
    63   mCloneBuffer = Move(aCloneReadInfo.mCloneBuffer);
    64   mFiles.Clear();
    65   mFiles.SwapElements(aCloneReadInfo.mFiles);
    66   mDatabase = aCloneReadInfo.mDatabase;
    67   aCloneReadInfo.mDatabase = nullptr;
    68   return *this;
    69 }
    71 inline
    72 bool
    73 StructuredCloneReadInfo::SetFromSerialized(
    74                                 const SerializedStructuredCloneReadInfo& aOther)
    75 {
    76   if (aOther.dataLength &&
    77       !mCloneBuffer.copy(aOther.data, aOther.dataLength)) {
    78     return false;
    79   }
    81   mFiles.Clear();
    82   return true;
    83 }
    85 inline
    86 void
    87 AppendConditionClause(const nsACString& aColumnName,
    88                       const nsACString& aArgName,
    89                       bool aLessThan,
    90                       bool aEquals,
    91                       nsACString& aResult)
    92 {
    93   aResult += NS_LITERAL_CSTRING(" AND ") + aColumnName +
    94              NS_LITERAL_CSTRING(" ");
    96   if (aLessThan) {
    97     aResult.AppendLiteral("<");
    98   }
    99   else {
   100     aResult.AppendLiteral(">");
   101   }
   103   if (aEquals) {
   104     aResult.AppendLiteral("=");
   105   }
   107   aResult += NS_LITERAL_CSTRING(" :") + aArgName;
   108 }
   110 END_INDEXEDDB_NAMESPACE
   112 #endif

mercurial