OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (C) 2013 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 are | |
6 * met: | |
7 * | |
8 * 1. Redistributions of source code must retain the above copyright | |
9 * notice, this list of conditions and the following disclaimer. | |
10 * | |
11 * 2. Redistributions in binary form must reproduce the above | |
12 * copyright notice, this list of conditions and the following disclaimer | |
13 * in the documentation and/or other materials provided with the | |
14 * distribution. | |
15 * | |
16 * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. AND ITS CONTRIBUTORS | |
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. | |
20 * OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
27 */ | |
28 | |
29 #include "config.h" | |
30 #include "public/platform/WebIDBCallbacks.h" | |
31 | |
32 #include "core/dom/DOMError.h" | |
33 #include "modules/indexeddb/IDBKey.h" | |
34 #include "modules/indexeddb/IDBMetadata.h" | |
35 #include "modules/indexeddb/IDBRequest.h" | |
36 #include "platform/SharedBuffer.h" | |
37 #include "public/platform/WebData.h" | |
38 #include "public/platform/WebIDBCursor.h" | |
39 #include "public/platform/WebIDBDatabase.h" | |
40 #include "public/platform/WebIDBDatabaseError.h" | |
41 #include "public/platform/WebIDBKey.h" | |
42 | |
43 using namespace WebCore; | |
44 | |
45 namespace blink { | |
46 | |
47 WebIDBCallbacks::WebIDBCallbacks(PassRefPtr<WebCore::IDBRequest> callbacks) | |
48 : m_private(callbacks) | |
49 , m_upgradeNeededCalled(false) | |
50 { | |
51 } | |
52 | |
53 WebIDBCallbacks::~WebIDBCallbacks() | |
54 { | |
55 m_private.reset(); | |
56 } | |
57 | |
58 void WebIDBCallbacks::onError(const WebIDBDatabaseError& error) | |
59 { | |
60 m_private->onError(error); | |
61 } | |
62 | |
63 void WebIDBCallbacks::onSuccess(const WebVector<WebString>& webStringList) | |
64 { | |
65 Vector<String> stringList; | |
66 for (size_t i = 0; i < webStringList.size(); ++i) | |
67 stringList.append(webStringList[i]); | |
68 m_private->onSuccess(stringList); | |
69 } | |
70 | |
71 void WebIDBCallbacks::onSuccess(WebIDBCursor* cursor, const WebIDBKey& key, cons
t WebIDBKey& primaryKey, const WebData& value) | |
72 { | |
73 m_private->onSuccess(adoptPtr(cursor), key, primaryKey, value); | |
74 } | |
75 | |
76 void WebIDBCallbacks::onSuccess(WebIDBDatabase* database, const WebIDBMetadata&
metadata) | |
77 { | |
78 // FIXME: Update Chromium to not pass |database| in onSuccess if onUpgradeNe
eded | |
79 // was previously called. It's not used and is not an ownership transfer. | |
80 if (m_upgradeNeededCalled) | |
81 database = 0; | |
82 m_private->onSuccess(adoptPtr(database), metadata); | |
83 } | |
84 | |
85 void WebIDBCallbacks::onSuccess(const WebIDBKey& key) | |
86 { | |
87 m_private->onSuccess(key); | |
88 } | |
89 | |
90 void WebIDBCallbacks::onSuccess(const WebData& value) | |
91 { | |
92 m_private->onSuccess(value); | |
93 } | |
94 | |
95 void WebIDBCallbacks::onSuccess(const WebData& value, const WebIDBKey& key, cons
t WebIDBKeyPath& keyPath) | |
96 { | |
97 m_private->onSuccess(value, key, keyPath); | |
98 } | |
99 | |
100 void WebIDBCallbacks::onSuccess(long long value) | |
101 { | |
102 m_private->onSuccess(value); | |
103 } | |
104 | |
105 void WebIDBCallbacks::onSuccess() | |
106 { | |
107 m_private->onSuccess(); | |
108 } | |
109 | |
110 void WebIDBCallbacks::onSuccess(const WebIDBKey& key, const WebIDBKey& primaryKe
y, const WebData& value) | |
111 { | |
112 m_private->onSuccess(key, primaryKey, value); | |
113 } | |
114 | |
115 void WebIDBCallbacks::onBlocked(long long oldVersion) | |
116 { | |
117 m_private->onBlocked(oldVersion); | |
118 } | |
119 | |
120 void WebIDBCallbacks::onUpgradeNeeded(long long oldVersion, WebIDBDatabase* data
base, const WebIDBMetadata& metadata, unsigned short dataLoss, WebString dataLos
sMessage) | |
121 { | |
122 m_upgradeNeededCalled = true; | |
123 m_private->onUpgradeNeeded(oldVersion, adoptPtr(database), metadata, static_
cast<WebIDBDataLoss>(dataLoss), dataLossMessage); | |
124 } | |
125 | |
126 } // namespace blink | |
OLD | NEW |