|
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 "IDBObjectStoreProxy.h" |
|
28 |
|
29 #include "DOMStringList.h" |
|
30 #include "IDBCallbacks.h" |
|
31 #include "IDBIndexProxy.h" |
|
32 #include "WebIDBCallbacksImpl.h" |
|
33 #include "WebIDBIndex.h" |
|
34 #include "WebIDBKey.h" |
|
35 #include "WebIDBObjectStore.h" |
|
36 #include "WebSerializedScriptValue.h" |
|
37 |
|
38 #if ENABLE(INDEXED_DATABASE) |
|
39 |
|
40 namespace WebCore { |
|
41 |
|
42 PassRefPtr<IDBObjectStore> IDBObjectStoreProxy::create(PassOwnPtr<WebKit::WebIDBObjectStore> objectStore) |
|
43 { |
|
44 return adoptRef(new IDBObjectStoreProxy(objectStore)); |
|
45 } |
|
46 |
|
47 IDBObjectStoreProxy::IDBObjectStoreProxy(PassOwnPtr<WebKit::WebIDBObjectStore> objectStore) |
|
48 : m_webIDBObjectStore(objectStore) |
|
49 { |
|
50 } |
|
51 |
|
52 IDBObjectStoreProxy::~IDBObjectStoreProxy() |
|
53 { |
|
54 } |
|
55 |
|
56 String IDBObjectStoreProxy::name() const |
|
57 { |
|
58 return m_webIDBObjectStore->name(); |
|
59 } |
|
60 |
|
61 String IDBObjectStoreProxy::keyPath() const |
|
62 { |
|
63 return m_webIDBObjectStore->keyPath(); |
|
64 } |
|
65 |
|
66 PassRefPtr<DOMStringList> IDBObjectStoreProxy::indexNames() const |
|
67 { |
|
68 return m_webIDBObjectStore->indexNames(); |
|
69 } |
|
70 |
|
71 void IDBObjectStoreProxy::get(PassRefPtr<IDBKey> key, PassRefPtr<IDBCallbacks> callbacks) |
|
72 { |
|
73 m_webIDBObjectStore->get(key, new WebIDBCallbacksImpl(callbacks)); |
|
74 } |
|
75 |
|
76 void IDBObjectStoreProxy::put(PassRefPtr<SerializedScriptValue> value, PassRefPtr<IDBKey> key, bool addOnly, PassRefPtr<IDBCallbacks> callbacks) |
|
77 { |
|
78 m_webIDBObjectStore->put(value, key, addOnly, new WebIDBCallbacksImpl(callbacks)); |
|
79 } |
|
80 |
|
81 void IDBObjectStoreProxy::remove(PassRefPtr<IDBKey> key, PassRefPtr<IDBCallbacks> callbacks) |
|
82 { |
|
83 m_webIDBObjectStore->remove(key, new WebIDBCallbacksImpl(callbacks)); |
|
84 } |
|
85 |
|
86 void IDBObjectStoreProxy::createIndex(const String& name, const String& keyPath, bool unique, PassRefPtr<IDBCallbacks> callbacks) |
|
87 { |
|
88 m_webIDBObjectStore->createIndex(name, keyPath, unique, new WebIDBCallbacksImpl(callbacks)); |
|
89 } |
|
90 |
|
91 PassRefPtr<IDBIndex> IDBObjectStoreProxy::index(const String& name) |
|
92 { |
|
93 WebKit::WebIDBIndex* index = m_webIDBObjectStore->index(name); |
|
94 if (!index) |
|
95 return 0; |
|
96 return IDBIndexProxy::create(index); |
|
97 } |
|
98 |
|
99 void IDBObjectStoreProxy::removeIndex(const String& name, PassRefPtr<IDBCallbacks> callbacks) |
|
100 { |
|
101 m_webIDBObjectStore->removeIndex(name, new WebIDBCallbacksImpl(callbacks)); |
|
102 } |
|
103 |
|
104 } // namespace WebCore |
|
105 |
|
106 #endif // ENABLE(INDEXED_DATABASE) |