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 : /* ***** BEGIN LICENSE BLOCK *****
4 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 : *
6 : * The contents of this file are subject to the Mozilla Public License Version
7 : * 1.1 (the "License"); you may not use this file except in compliance with
8 : * the License. You may obtain a copy of the License at
9 : * http://www.mozilla.org/MPL/
10 : *
11 : * Software distributed under the License is distributed on an "AS IS" basis,
12 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 : * for the specific language governing rights and limitations under the
14 : * License.
15 : *
16 : * The Original Code is Indexed Database.
17 : *
18 : * The Initial Developer of the Original Code is
19 : * The Mozilla Foundation.
20 : * Portions created by the Initial Developer are Copyright (C) 2010
21 : * the Initial Developer. All Rights Reserved.
22 : *
23 : * Contributor(s):
24 : * Shawn Wilsher <me@shawnwilsher.com>
25 : * Ben Turner <bent.mozilla@gmail.com>
26 : *
27 : * Alternatively, the contents of this file may be used under the terms of
28 : * either the GNU General Public License Version 2 or later (the "GPL"), or
29 : * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 : * in which case the provisions of the GPL or the LGPL are applicable instead
31 : * of those above. If you wish to allow use of your version of this file only
32 : * under the terms of either the GPL or the LGPL, and not to allow others to
33 : * use your version of this file under the terms of the MPL, indicate your
34 : * decision by deleting the provisions above and replace them with the notice
35 : * and other provisions required by the GPL or the LGPL. If you do not delete
36 : * the provisions above, a recipient may use your version of this file under
37 : * the terms of any one of the MPL, the GPL or the LGPL.
38 : *
39 : * ***** END LICENSE BLOCK ***** */
40 :
41 : #ifndef mozilla_dom_indexeddb_indexeddatabase_h__
42 : #define mozilla_dom_indexeddb_indexeddatabase_h__
43 :
44 : #include "nsIProgrammingLanguage.h"
45 :
46 : #include "jsapi.h"
47 : #include "nsAutoPtr.h"
48 : #include "nsCOMPtr.h"
49 : #include "nsDebug.h"
50 : #include "nsDOMError.h"
51 : #include "nsStringGlue.h"
52 : #include "nsTArray.h"
53 :
54 : #define BEGIN_INDEXEDDB_NAMESPACE \
55 : namespace mozilla { namespace dom { namespace indexedDB {
56 :
57 : #define END_INDEXEDDB_NAMESPACE \
58 : } /* namespace indexedDB */ } /* namepsace dom */ } /* namespace mozilla */
59 :
60 : #define USING_INDEXEDDB_NAMESPACE \
61 : using namespace mozilla::dom::indexedDB;
62 :
63 : class nsIDOMBlob;
64 :
65 : BEGIN_INDEXEDDB_NAMESPACE
66 :
67 : class FileInfo;
68 :
69 2549 : struct StructuredCloneReadInfo {
70 1712 : void Swap(StructuredCloneReadInfo& aCloneReadInfo) {
71 1712 : mCloneBuffer.swap(aCloneReadInfo.mCloneBuffer);
72 1712 : mFileInfos.SwapElements(aCloneReadInfo.mFileInfos);
73 1712 : }
74 :
75 : JSAutoStructuredCloneBuffer mCloneBuffer;
76 : nsTArray<nsRefPtr<FileInfo> > mFileInfos;
77 : };
78 :
79 7586 : struct StructuredCloneWriteInfo {
80 1837 : void Swap(StructuredCloneWriteInfo& aCloneWriteInfo) {
81 1837 : mCloneBuffer.swap(aCloneWriteInfo.mCloneBuffer);
82 1837 : mBlobs.SwapElements(aCloneWriteInfo.mBlobs);
83 1837 : mOffsetToKeyProp = aCloneWriteInfo.mOffsetToKeyProp;
84 1837 : }
85 :
86 : JSAutoStructuredCloneBuffer mCloneBuffer;
87 : nsTArray<nsCOMPtr<nsIDOMBlob> > mBlobs;
88 : PRUint64 mOffsetToKeyProp;
89 : };
90 :
91 : inline
92 : void
93 165 : AppendConditionClause(const nsACString& aColumnName,
94 : const nsACString& aArgName,
95 : bool aLessThan,
96 : bool aEquals,
97 : nsACString& aResult)
98 : {
99 330 : aResult += NS_LITERAL_CSTRING(" AND ") + aColumnName +
100 495 : NS_LITERAL_CSTRING(" ");
101 :
102 165 : if (aLessThan) {
103 78 : aResult.AppendLiteral("<");
104 : }
105 : else {
106 87 : aResult.AppendLiteral(">");
107 : }
108 :
109 165 : if (aEquals) {
110 109 : aResult.AppendLiteral("=");
111 : }
112 :
113 165 : aResult += NS_LITERAL_CSTRING(" :") + aArgName;
114 165 : }
115 :
116 : END_INDEXEDDB_NAMESPACE
117 :
118 : #endif // mozilla_dom_indexeddb_indexeddatabase_h__
|