|
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/. */ |
|
6 |
|
7 #ifndef IndexedDatabaseInlines_h |
|
8 #define IndexedDatabaseInlines_h |
|
9 |
|
10 #ifndef mozilla_dom_indexeddb_indexeddatabase_h__ |
|
11 #error Must include IndexedDatabase.h first |
|
12 #endif |
|
13 |
|
14 BEGIN_INDEXEDDB_NAMESPACE |
|
15 |
|
16 inline |
|
17 StructuredCloneWriteInfo::StructuredCloneWriteInfo() |
|
18 : mTransaction(nullptr), |
|
19 mOffsetToKeyProp(0) |
|
20 { |
|
21 } |
|
22 |
|
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 } |
|
34 |
|
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 } |
|
46 |
|
47 mFiles.Clear(); |
|
48 mOffsetToKeyProp = aOther.offsetToKeyProp; |
|
49 return true; |
|
50 } |
|
51 |
|
52 inline |
|
53 StructuredCloneReadInfo::StructuredCloneReadInfo() |
|
54 : mDatabase(nullptr) |
|
55 { |
|
56 } |
|
57 |
|
58 inline StructuredCloneReadInfo& |
|
59 StructuredCloneReadInfo::operator=(StructuredCloneReadInfo&& aCloneReadInfo) |
|
60 { |
|
61 MOZ_ASSERT(&aCloneReadInfo != this); |
|
62 |
|
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 } |
|
70 |
|
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 } |
|
80 |
|
81 mFiles.Clear(); |
|
82 return true; |
|
83 } |
|
84 |
|
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(" "); |
|
95 |
|
96 if (aLessThan) { |
|
97 aResult.AppendLiteral("<"); |
|
98 } |
|
99 else { |
|
100 aResult.AppendLiteral(">"); |
|
101 } |
|
102 |
|
103 if (aEquals) { |
|
104 aResult.AppendLiteral("="); |
|
105 } |
|
106 |
|
107 aResult += NS_LITERAL_CSTRING(" :") + aArgName; |
|
108 } |
|
109 |
|
110 END_INDEXEDDB_NAMESPACE |
|
111 |
|
112 #endif |