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 : *
26 : * Alternatively, the contents of this file may be used under the terms of
27 : * either the GNU General Public License Version 2 or later (the "GPL"), or
28 : * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 : * in which case the provisions of the GPL or the LGPL are applicable instead
30 : * of those above. If you wish to allow use of your version of this file only
31 : * under the terms of either the GPL or the LGPL, and not to allow others to
32 : * use your version of this file under the terms of the MPL, indicate your
33 : * decision by deleting the provisions above and replace them with the notice
34 : * and other provisions required by the GPL or the LGPL. If you do not delete
35 : * the provisions above, a recipient may use your version of this file under
36 : * the terms of any one of the MPL, the GPL or the LGPL.
37 : *
38 : * ***** END LICENSE BLOCK ***** */
39 :
40 : #ifndef mozilla_dom_indexeddb_idbindex_h__
41 : #define mozilla_dom_indexeddb_idbindex_h__
42 :
43 : #include "mozilla/dom/indexedDB/IndexedDatabase.h"
44 :
45 : #include "nsIIDBIndex.h"
46 :
47 : #include "nsCycleCollectionParticipant.h"
48 :
49 : class nsIScriptContext;
50 : class nsPIDOMWindow;
51 :
52 : BEGIN_INDEXEDDB_NAMESPACE
53 :
54 : class AsyncConnectionHelper;
55 : class IDBObjectStore;
56 : struct IndexInfo;
57 :
58 : class IDBIndex : public nsIIDBIndex
59 : {
60 : public:
61 105 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
62 : NS_DECL_NSIIDBINDEX
63 :
64 6161 : NS_DECL_CYCLE_COLLECTION_CLASS(IDBIndex)
65 :
66 : static already_AddRefed<IDBIndex>
67 : Create(IDBObjectStore* aObjectStore,
68 : const IndexInfo* aIndexInfo);
69 :
70 592 : IDBObjectStore* ObjectStore()
71 : {
72 592 : return mObjectStore;
73 : }
74 :
75 1145 : const PRInt64 Id() const
76 : {
77 1145 : return mId;
78 : }
79 :
80 267 : const nsString& Name() const
81 : {
82 267 : return mName;
83 : }
84 :
85 468 : bool IsUnique() const
86 : {
87 468 : return mUnique;
88 : }
89 :
90 222 : bool IsMultiEntry() const
91 : {
92 222 : return mMultiEntry;
93 : }
94 :
95 222 : const nsString& KeyPath() const
96 : {
97 222 : return mKeyPath;
98 : }
99 :
100 100 : bool UsesKeyPathArray() const
101 : {
102 100 : return !mKeyPathArray.IsEmpty();
103 : }
104 :
105 137 : const nsTArray<nsString>& KeyPathArray() const
106 : {
107 137 : return mKeyPathArray;
108 : }
109 :
110 : private:
111 : IDBIndex();
112 : ~IDBIndex();
113 :
114 : nsRefPtr<IDBObjectStore> mObjectStore;
115 :
116 : PRInt64 mId;
117 : nsString mName;
118 : nsString mKeyPath;
119 : nsTArray<nsString> mKeyPathArray;
120 : bool mUnique;
121 : bool mMultiEntry;
122 : };
123 :
124 : END_INDEXEDDB_NAMESPACE
125 :
126 : #endif // mozilla_dom_indexeddb_idbindex_h__
|