| 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 "platform/blob/BlobInfo.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(PassRefPtr<IDBReques
t> request) | 57 PassOwnPtr<WebIDBCallbacksImpl> WebIDBCallbacksImpl::create(PassRefPtr<IDBReques
t> request) |
| 55 { | 58 { |
| 56 return adoptPtr(new WebIDBCallbacksImpl(request)); | 59 return adoptPtr(new WebIDBCallbacksImpl(request)); |
| 57 } | 60 } |
| 58 | 61 |
| 59 WebIDBCallbacksImpl::WebIDBCallbacksImpl(PassRefPtr<IDBRequest> request) | 62 WebIDBCallbacksImpl::WebIDBCallbacksImpl(PassRefPtr<IDBRequest> request) |
| 60 : m_request(request) | 63 : m_request(request) |
| 61 { | 64 { |
| 62 } | 65 } |
| 63 | 66 |
| 64 WebIDBCallbacksImpl::~WebIDBCallbacksImpl() | 67 WebIDBCallbacksImpl::~WebIDBCallbacksImpl() |
| 65 { | 68 { |
| 66 } | 69 } |
| 70 static PassOwnPtr<Vector<BlobInfo> > ConvertBlobInfo(const WebVector<WebBlobInfo
>& webBlobInfo) |
| 71 { |
| 72 OwnPtr<Vector<BlobInfo> > blobInfo = adoptPtr(new Vector<BlobInfo>(webBlobIn
fo.size())); |
| 73 for (size_t i = 0; i < webBlobInfo.size(); ++i) |
| 74 (*blobInfo)[i] = webBlobInfo[i]; |
| 75 return blobInfo.release(); |
| 76 } |
| 67 | 77 |
| 68 void WebIDBCallbacksImpl::onError(const WebIDBDatabaseError& error) | 78 void WebIDBCallbacksImpl::onError(const WebIDBDatabaseError& error) |
| 69 { | 79 { |
| 70 m_request->onError(error); | 80 m_request->onError(error); |
| 71 } | 81 } |
| 72 | 82 |
| 73 void WebIDBCallbacksImpl::onSuccess(const blink::WebVector<blink::WebString>& we
bStringList) | 83 void WebIDBCallbacksImpl::onSuccess(const WebVector<blink::WebString>& webString
List) |
| 74 { | 84 { |
| 75 Vector<String> stringList; | 85 Vector<String> stringList; |
| 76 for (size_t i = 0; i < webStringList.size(); ++i) | 86 for (size_t i = 0; i < webStringList.size(); ++i) |
| 77 stringList.append(webStringList[i]); | 87 stringList.append(webStringList[i]); |
| 78 m_request->onSuccess(stringList); | 88 m_request->onSuccess(stringList); |
| 79 } | 89 } |
| 80 | 90 |
| 81 void WebIDBCallbacksImpl::onSuccess(WebIDBCursor* cursor, const WebIDBKey& key,
const WebIDBKey& primaryKey, const WebData& value) | 91 void WebIDBCallbacksImpl::onSuccess(WebIDBCursor* cursor, const WebIDBKey& key,
const WebIDBKey& primaryKey, const WebData& value, const WebVector<WebBlobInfo>&
webBlobInfo) |
| 82 { | 92 { |
| 83 m_request->onSuccess(adoptPtr(cursor), key, primaryKey, value); | 93 m_request->onSuccess(adoptPtr(cursor), key, primaryKey, value, ConvertBlobIn
fo(webBlobInfo)); |
| 84 } | 94 } |
| 85 | 95 |
| 86 void WebIDBCallbacksImpl::onSuccess(WebIDBDatabase* backend, const WebIDBMetadat
a& metadata) | 96 void WebIDBCallbacksImpl::onSuccess(WebIDBDatabase* backend, const WebIDBMetadat
a& metadata) |
| 87 { | 97 { |
| 88 m_request->onSuccess(adoptPtr(backend), metadata); | 98 m_request->onSuccess(adoptPtr(backend), metadata); |
| 89 } | 99 } |
| 90 | 100 |
| 91 void WebIDBCallbacksImpl::onSuccess(const WebIDBKey& key) | 101 void WebIDBCallbacksImpl::onSuccess(const WebIDBKey& key) |
| 92 { | 102 { |
| 93 m_request->onSuccess(key); | 103 m_request->onSuccess(key); |
| 94 } | 104 } |
| 95 | 105 |
| 96 void WebIDBCallbacksImpl::onSuccess(const WebData& value) | 106 void WebIDBCallbacksImpl::onSuccess(const WebData& value, const WebVector<WebBlo
bInfo>& webBlobInfo) |
| 97 { | 107 { |
| 98 m_request->onSuccess(value); | 108 m_request->onSuccess(value, ConvertBlobInfo(webBlobInfo)); |
| 99 } | 109 } |
| 100 | 110 |
| 101 void WebIDBCallbacksImpl::onSuccess(const WebData& value, const WebIDBKey& key,
const WebIDBKeyPath& keyPath) | 111 void WebIDBCallbacksImpl::onSuccess(const WebData& value, const WebVector<WebBlo
bInfo>& webBlobInfo, const WebIDBKey& key, const WebIDBKeyPath& keyPath) |
| 102 { | 112 { |
| 103 m_request->onSuccess(value, key, keyPath); | 113 m_request->onSuccess(value, ConvertBlobInfo(webBlobInfo), key, keyPath); |
| 104 } | 114 } |
| 105 | 115 |
| 106 void WebIDBCallbacksImpl::onSuccess(long long value) | 116 void WebIDBCallbacksImpl::onSuccess(long long value) |
| 107 { | 117 { |
| 108 m_request->onSuccess(value); | 118 m_request->onSuccess(value); |
| 109 } | 119 } |
| 110 | 120 |
| 111 void WebIDBCallbacksImpl::onSuccess() | 121 void WebIDBCallbacksImpl::onSuccess() |
| 112 { | 122 { |
| 113 m_request->onSuccess(); | 123 m_request->onSuccess(); |
| 114 } | 124 } |
| 115 | 125 |
| 116 void WebIDBCallbacksImpl::onSuccess(const WebIDBKey& key, const WebIDBKey& prima
ryKey, const WebData& value) | 126 void WebIDBCallbacksImpl::onSuccess(const WebIDBKey& key, const WebIDBKey& prima
ryKey, const WebData& value, const WebVector<WebBlobInfo>& webBlobInfo) |
| 117 { | 127 { |
| 118 m_request->onSuccess(key, primaryKey, value); | 128 m_request->onSuccess(key, primaryKey, value, ConvertBlobInfo(webBlobInfo)); |
| 119 } | 129 } |
| 120 | 130 |
| 121 void WebIDBCallbacksImpl::onBlocked(long long oldVersion) | 131 void WebIDBCallbacksImpl::onBlocked(long long oldVersion) |
| 122 { | 132 { |
| 123 m_request->onBlocked(oldVersion); | 133 m_request->onBlocked(oldVersion); |
| 124 } | 134 } |
| 125 | 135 |
| 126 void WebIDBCallbacksImpl::onUpgradeNeeded(long long oldVersion, WebIDBDatabase*
database, const WebIDBMetadata& metadata, unsigned short dataLoss, blink::WebStr
ing dataLossMessage) | 136 void WebIDBCallbacksImpl::onUpgradeNeeded(long long oldVersion, WebIDBDatabase*
database, const WebIDBMetadata& metadata, unsigned short dataLoss, blink::WebStr
ing dataLossMessage) |
| 127 { | 137 { |
| 128 m_request->onUpgradeNeeded(oldVersion, adoptPtr(database), metadata, static_
cast<blink::WebIDBDataLoss>(dataLoss), dataLossMessage); | 138 m_request->onUpgradeNeeded(oldVersion, adoptPtr(database), metadata, static_
cast<blink::WebIDBDataLoss>(dataLoss), dataLossMessage); |
| 129 } | 139 } |
| 130 | 140 |
| 131 } // namespace blink | 141 } // namespace blink |
| OLD | NEW |