• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 Google Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * 1.  Redistributions of source code must retain the above copyright
9  *     notice, this list of conditions and the following disclaimer.
10  * 2.  Redistributions in binary form must reproduce the above copyright
11  *     notice, this list of conditions and the following disclaimer in the
12  *     documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
15  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17  * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
18  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #include "config.h"
27 #include "IDBAny.h"
28 
29 #if ENABLE(INDEXED_DATABASE)
30 
31 #include "IDBCursorWithValue.h"
32 #include "IDBDatabase.h"
33 #include "IDBFactory.h"
34 #include "IDBIndex.h"
35 #include "IDBObjectStore.h"
36 #include "SerializedScriptValue.h"
37 
38 namespace WebCore {
39 
createInvalid()40 PassRefPtr<IDBAny> IDBAny::createInvalid()
41 {
42     return adoptRef(new IDBAny());
43 }
44 
createNull()45 PassRefPtr<IDBAny> IDBAny::createNull()
46 {
47     RefPtr<IDBAny> idbAny = adoptRef(new IDBAny());
48     idbAny->setNull();
49     return idbAny.release();
50 }
51 
IDBAny()52 IDBAny::IDBAny()
53     : m_type(UndefinedType)
54 {
55 }
56 
~IDBAny()57 IDBAny::~IDBAny()
58 {
59 }
60 
idbCursor()61 PassRefPtr<IDBCursor> IDBAny::idbCursor()
62 {
63     ASSERT(m_type == IDBCursorType);
64     return m_idbCursor;
65 }
66 
67 
idbCursorWithValue()68 PassRefPtr<IDBCursorWithValue> IDBAny::idbCursorWithValue()
69 {
70     ASSERT(m_type == IDBCursorWithValueType);
71     return m_idbCursorWithValue;
72 }
73 
idbDatabase()74 PassRefPtr<IDBDatabase> IDBAny::idbDatabase()
75 {
76     ASSERT(m_type == IDBDatabaseType);
77     return m_idbDatabase;
78 }
79 
idbFactory()80 PassRefPtr<IDBFactory> IDBAny::idbFactory()
81 {
82     ASSERT(m_type == IDBFactoryType);
83     return m_idbFactory;
84 }
85 
idbIndex()86 PassRefPtr<IDBIndex> IDBAny::idbIndex()
87 {
88     ASSERT(m_type == IDBIndexType);
89     return m_idbIndex;
90 }
91 
idbKey()92 PassRefPtr<IDBKey> IDBAny::idbKey()
93 {
94     ASSERT(m_type == IDBKeyType);
95     return m_idbKey;
96 }
97 
idbObjectStore()98 PassRefPtr<IDBObjectStore> IDBAny::idbObjectStore()
99 {
100     ASSERT(m_type == IDBObjectStoreType);
101     return m_idbObjectStore;
102 }
103 
idbTransaction()104 PassRefPtr<IDBTransaction> IDBAny::idbTransaction()
105 {
106     ASSERT(m_type == IDBTransactionType);
107     return m_idbTransaction;
108 }
109 
serializedScriptValue()110 PassRefPtr<SerializedScriptValue> IDBAny::serializedScriptValue()
111 {
112     ASSERT(m_type == SerializedScriptValueType);
113     return m_serializedScriptValue;
114 }
115 
setNull()116 void IDBAny::setNull()
117 {
118     ASSERT(m_type == UndefinedType);
119     m_type = NullType;
120 }
121 
set(PassRefPtr<IDBCursorWithValue> value)122 void IDBAny::set(PassRefPtr<IDBCursorWithValue> value)
123 {
124     ASSERT(m_type == UndefinedType);
125     m_type = IDBCursorWithValueType;
126     m_idbCursorWithValue = value;
127 }
128 
set(PassRefPtr<IDBCursor> value)129 void IDBAny::set(PassRefPtr<IDBCursor> value)
130 {
131     ASSERT(m_type == UndefinedType);
132     m_type = IDBCursorType;
133     m_idbCursor = value;
134 }
135 
set(PassRefPtr<IDBDatabase> value)136 void IDBAny::set(PassRefPtr<IDBDatabase> value)
137 {
138     ASSERT(m_type == UndefinedType);
139     m_type = IDBDatabaseType;
140     m_idbDatabase = value;
141 }
142 
set(PassRefPtr<IDBFactory> value)143 void IDBAny::set(PassRefPtr<IDBFactory> value)
144 {
145     ASSERT(m_type == UndefinedType);
146     m_type = IDBFactoryType;
147     m_idbFactory = value;
148 }
149 
set(PassRefPtr<IDBIndex> value)150 void IDBAny::set(PassRefPtr<IDBIndex> value)
151 {
152     ASSERT(m_type == UndefinedType);
153     m_type = IDBIndexType;
154     m_idbIndex = value;
155 }
156 
set(PassRefPtr<IDBKey> value)157 void IDBAny::set(PassRefPtr<IDBKey> value)
158 {
159     ASSERT(m_type == UndefinedType);
160     m_type = IDBKeyType;
161     m_idbKey = value;
162 }
163 
set(PassRefPtr<IDBTransaction> value)164 void IDBAny::set(PassRefPtr<IDBTransaction> value)
165 {
166     ASSERT(m_type == UndefinedType);
167     m_type = IDBTransactionType;
168     m_idbTransaction = value;
169 }
170 
set(PassRefPtr<IDBObjectStore> value)171 void IDBAny::set(PassRefPtr<IDBObjectStore> value)
172 {
173     ASSERT(m_type == UndefinedType);
174     m_type = IDBObjectStoreType;
175     m_idbObjectStore = value;
176 }
177 
set(PassRefPtr<SerializedScriptValue> value)178 void IDBAny::set(PassRefPtr<SerializedScriptValue> value)
179 {
180     ASSERT(m_type == UndefinedType);
181     m_type = SerializedScriptValueType;
182     m_serializedScriptValue = value;
183 }
184 
185 } // namespace WebCore
186 
187 #endif
188