OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * | 10 * |
(...skipping 15 matching lines...) Expand all Loading... |
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 */ | 27 */ |
28 | 28 |
29 #include "config.h" | 29 #include "config.h" |
30 #include "modules/indexeddb/WebIDBCallbacksImpl.h" | 30 #include "modules/indexeddb/WebIDBCallbacksImpl.h" |
31 | 31 |
32 #include "core/dom/DOMError.h" | 32 #include "core/dom/DOMError.h" |
33 #include "modules/indexeddb/IDBMetadata.h" | 33 #include "modules/indexeddb/IDBMetadata.h" |
34 #include "modules/indexeddb/IDBRequest.h" | 34 #include "modules/indexeddb/IDBRequest.h" |
35 #include "platform/SharedBuffer.h" | 35 #include "platform/SharedBuffer.h" |
| 36 #include "public/platform/WebBlobInfo.h" |
36 #include "public/platform/WebData.h" | 37 #include "public/platform/WebData.h" |
37 #include "public/platform/WebIDBCursor.h" | 38 #include "public/platform/WebIDBCursor.h" |
38 #include "public/platform/WebIDBDatabase.h" | 39 #include "public/platform/WebIDBDatabase.h" |
39 #include "public/platform/WebIDBDatabaseError.h" | 40 #include "public/platform/WebIDBDatabaseError.h" |
40 #include "public/platform/WebIDBKey.h" | 41 #include "public/platform/WebIDBKey.h" |
41 | 42 |
| 43 using blink::WebBlobInfo; |
42 using blink::WebData; | 44 using blink::WebData; |
43 using blink::WebIDBCursor; | 45 using blink::WebIDBCursor; |
44 using blink::WebIDBDatabase; | 46 using blink::WebIDBDatabase; |
45 using blink::WebIDBDatabaseError; | 47 using blink::WebIDBDatabaseError; |
46 using blink::WebIDBIndex; | 48 using blink::WebIDBIndex; |
47 using blink::WebIDBKey; | 49 using blink::WebIDBKey; |
48 using blink::WebIDBKeyPath; | 50 using blink::WebIDBKeyPath; |
49 using blink::WebIDBMetadata; | 51 using blink::WebIDBMetadata; |
| 52 using blink::WebVector; |
50 | 53 |
51 namespace WebCore { | 54 namespace WebCore { |
52 | 55 |
53 // static | 56 // static |
54 PassOwnPtr<WebIDBCallbacksImpl> WebIDBCallbacksImpl::create(PassRefPtrWillBeRawP
tr<IDBRequest> request) | 57 PassOwnPtr<WebIDBCallbacksImpl> WebIDBCallbacksImpl::create(PassRefPtrWillBeRawP
tr<IDBRequest> request) |
55 { | 58 { |
56 return adoptPtr(new WebIDBCallbacksImpl(request)); | 59 return adoptPtr(new WebIDBCallbacksImpl(request)); |
57 } | 60 } |
58 | 61 |
59 WebIDBCallbacksImpl::WebIDBCallbacksImpl(PassRefPtrWillBeRawPtr<IDBRequest> requ
est) | 62 WebIDBCallbacksImpl::WebIDBCallbacksImpl(PassRefPtrWillBeRawPtr<IDBRequest> requ
est) |
60 : m_request(request) | 63 : m_request(request) |
61 { | 64 { |
62 } | 65 } |
63 | 66 |
64 WebIDBCallbacksImpl::~WebIDBCallbacksImpl() | 67 WebIDBCallbacksImpl::~WebIDBCallbacksImpl() |
65 { | 68 { |
66 } | 69 } |
67 | 70 |
| 71 static PassOwnPtr<Vector<WebBlobInfo> > ConvertBlobInfo(const WebVector<WebBlobI
nfo>& webBlobInfo) |
| 72 { |
| 73 OwnPtr<Vector<WebBlobInfo> > blobInfo = adoptPtr(new Vector<WebBlobInfo>(web
BlobInfo.size())); |
| 74 for (size_t i = 0; i < webBlobInfo.size(); ++i) |
| 75 (*blobInfo)[i] = webBlobInfo[i]; |
| 76 return blobInfo.release(); |
| 77 } |
| 78 |
68 void WebIDBCallbacksImpl::onError(const WebIDBDatabaseError& error) | 79 void WebIDBCallbacksImpl::onError(const WebIDBDatabaseError& error) |
69 { | 80 { |
70 m_request->onError(error); | 81 m_request->onError(error); |
71 } | 82 } |
72 | 83 |
73 void WebIDBCallbacksImpl::onSuccess(const blink::WebVector<blink::WebString>& we
bStringList) | 84 void WebIDBCallbacksImpl::onSuccess(const WebVector<blink::WebString>& webString
List) |
74 { | 85 { |
75 Vector<String> stringList; | 86 Vector<String> stringList; |
76 for (size_t i = 0; i < webStringList.size(); ++i) | 87 for (size_t i = 0; i < webStringList.size(); ++i) |
77 stringList.append(webStringList[i]); | 88 stringList.append(webStringList[i]); |
78 m_request->onSuccess(stringList); | 89 m_request->onSuccess(stringList); |
79 } | 90 } |
80 | 91 |
81 void WebIDBCallbacksImpl::onSuccess(WebIDBCursor* cursor, const WebIDBKey& key,
const WebIDBKey& primaryKey, const WebData& value) | 92 void WebIDBCallbacksImpl::onSuccess(WebIDBCursor* cursor, const WebIDBKey& key,
const WebIDBKey& primaryKey, const WebData& value) |
82 { | 93 { |
83 m_request->onSuccess(adoptPtr(cursor), key, primaryKey, value); | 94 OwnPtr<Vector<blink::WebBlobInfo> > blobInfo(adoptPtr(new Vector<blink::WebB
lobInfo>())); |
| 95 m_request->onSuccess(adoptPtr(cursor), key, primaryKey, value, blobInfo.rele
ase()); |
| 96 } |
| 97 |
| 98 void WebIDBCallbacksImpl::onSuccess(WebIDBCursor* cursor, const WebIDBKey& key,
const WebIDBKey& primaryKey, const WebData& value, const WebVector<WebBlobInfo>&
webBlobInfo) |
| 99 { |
| 100 m_request->onSuccess(adoptPtr(cursor), key, primaryKey, value, ConvertBlobIn
fo(webBlobInfo)); |
84 } | 101 } |
85 | 102 |
86 void WebIDBCallbacksImpl::onSuccess(WebIDBDatabase* backend, const WebIDBMetadat
a& metadata) | 103 void WebIDBCallbacksImpl::onSuccess(WebIDBDatabase* backend, const WebIDBMetadat
a& metadata) |
87 { | 104 { |
88 m_request->onSuccess(adoptPtr(backend), metadata); | 105 m_request->onSuccess(adoptPtr(backend), metadata); |
89 } | 106 } |
90 | 107 |
91 void WebIDBCallbacksImpl::onSuccess(const WebIDBKey& key) | 108 void WebIDBCallbacksImpl::onSuccess(const WebIDBKey& key) |
92 { | 109 { |
93 m_request->onSuccess(key); | 110 m_request->onSuccess(key); |
94 } | 111 } |
95 | 112 |
96 void WebIDBCallbacksImpl::onSuccess(const WebData& value) | 113 void WebIDBCallbacksImpl::onSuccess(const WebData& value) |
97 { | 114 { |
98 m_request->onSuccess(value); | 115 OwnPtr<Vector<blink::WebBlobInfo> > blobInfo(adoptPtr(new Vector<blink::WebB
lobInfo>())); |
| 116 m_request->onSuccess(value, blobInfo.release()); |
| 117 } |
| 118 |
| 119 void WebIDBCallbacksImpl::onSuccess(const WebData& value, const WebVector<WebBlo
bInfo>& webBlobInfo) |
| 120 { |
| 121 m_request->onSuccess(value, ConvertBlobInfo(webBlobInfo)); |
99 } | 122 } |
100 | 123 |
101 void WebIDBCallbacksImpl::onSuccess(const WebData& value, const WebIDBKey& key,
const WebIDBKeyPath& keyPath) | 124 void WebIDBCallbacksImpl::onSuccess(const WebData& value, const WebIDBKey& key,
const WebIDBKeyPath& keyPath) |
102 { | 125 { |
103 m_request->onSuccess(value, key, keyPath); | 126 OwnPtr<Vector<blink::WebBlobInfo> > blobInfo(adoptPtr(new Vector<blink::WebB
lobInfo>())); |
| 127 m_request->onSuccess(value, blobInfo.release(), key, keyPath); |
| 128 } |
| 129 |
| 130 void WebIDBCallbacksImpl::onSuccess(const WebData& value, const WebVector<WebBlo
bInfo>& webBlobInfo, const WebIDBKey& key, const WebIDBKeyPath& keyPath) |
| 131 { |
| 132 m_request->onSuccess(value, ConvertBlobInfo(webBlobInfo), key, keyPath); |
104 } | 133 } |
105 | 134 |
106 void WebIDBCallbacksImpl::onSuccess(long long value) | 135 void WebIDBCallbacksImpl::onSuccess(long long value) |
107 { | 136 { |
108 m_request->onSuccess(value); | 137 m_request->onSuccess(value); |
109 } | 138 } |
110 | 139 |
111 void WebIDBCallbacksImpl::onSuccess() | 140 void WebIDBCallbacksImpl::onSuccess() |
112 { | 141 { |
113 m_request->onSuccess(); | 142 m_request->onSuccess(); |
114 } | 143 } |
115 | 144 |
116 void WebIDBCallbacksImpl::onSuccess(const WebIDBKey& key, const WebIDBKey& prima
ryKey, const WebData& value) | 145 void WebIDBCallbacksImpl::onSuccess(const WebIDBKey& key, const WebIDBKey& prima
ryKey, const WebData& value) |
117 { | 146 { |
118 m_request->onSuccess(key, primaryKey, value); | 147 OwnPtr<Vector<blink::WebBlobInfo> > blobInfo(adoptPtr(new Vector<blink::WebB
lobInfo>())); |
| 148 m_request->onSuccess(key, primaryKey, value, blobInfo.release()); |
| 149 } |
| 150 |
| 151 void WebIDBCallbacksImpl::onSuccess(const WebIDBKey& key, const WebIDBKey& prima
ryKey, const WebData& value, const WebVector<WebBlobInfo>& webBlobInfo) |
| 152 { |
| 153 m_request->onSuccess(key, primaryKey, value, ConvertBlobInfo(webBlobInfo)); |
119 } | 154 } |
120 | 155 |
121 void WebIDBCallbacksImpl::onBlocked(long long oldVersion) | 156 void WebIDBCallbacksImpl::onBlocked(long long oldVersion) |
122 { | 157 { |
123 m_request->onBlocked(oldVersion); | 158 m_request->onBlocked(oldVersion); |
124 } | 159 } |
125 | 160 |
126 void WebIDBCallbacksImpl::onUpgradeNeeded(long long oldVersion, WebIDBDatabase*
database, const WebIDBMetadata& metadata, unsigned short dataLoss, blink::WebStr
ing dataLossMessage) | 161 void WebIDBCallbacksImpl::onUpgradeNeeded(long long oldVersion, WebIDBDatabase*
database, const WebIDBMetadata& metadata, unsigned short dataLoss, blink::WebStr
ing dataLossMessage) |
127 { | 162 { |
128 m_request->onUpgradeNeeded(oldVersion, adoptPtr(database), metadata, static_
cast<blink::WebIDBDataLoss>(dataLoss), dataLossMessage); | 163 m_request->onUpgradeNeeded(oldVersion, adoptPtr(database), metadata, static_
cast<blink::WebIDBDataLoss>(dataLoss), dataLossMessage); |
129 } | 164 } |
130 | 165 |
131 } // namespace blink | 166 } // namespace blink |
OLD | NEW |