Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(336)

Side by Side Diff: Source/web/WebIDBCallbacksImpl.cpp

Issue 18590006: Blob support for IDB [Blink] (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Merge fixes [builds, untested] Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the 11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution. 12 * documentation and/or other materials provided with the distribution.
13 * 13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 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 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 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 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "config.h" 26 #include "config.h"
27 #include "WebIDBCallbacksImpl.h" 27 #include "WebIDBCallbacksImpl.h"
28 28
29 #include "public/platform/WebBlobInfo.h"
29 #include "public/platform/WebData.h" 30 #include "public/platform/WebData.h"
30 #include "public/platform/WebIDBCallbacks.h" 31 #include "public/platform/WebIDBCallbacks.h"
31 #include "public/platform/WebIDBDatabase.h" 32 #include "public/platform/WebIDBDatabase.h"
32 #include "public/platform/WebIDBDatabaseError.h" 33 #include "public/platform/WebIDBDatabaseError.h"
33 #include "public/platform/WebIDBKey.h" 34 #include "public/platform/WebIDBKey.h"
34 #include "IDBCursorBackendProxy.h" 35 #include "IDBCursorBackendProxy.h"
35 #include "IDBDatabaseBackendProxy.h" 36 #include "IDBDatabaseBackendProxy.h"
37 #include "bindings/v8/BlobInfo.h"
36 #include "core/dom/DOMError.h" 38 #include "core/dom/DOMError.h"
37 #include "modules/indexeddb/IDBCallbacks.h" 39 #include "modules/indexeddb/IDBCallbacks.h"
38 #include "modules/indexeddb/IDBKey.h" 40 #include "modules/indexeddb/IDBKey.h"
39 #include "modules/indexeddb/IDBMetadata.h" 41 #include "modules/indexeddb/IDBMetadata.h"
40 42
41 using namespace WebCore; 43 using namespace WebCore;
42 44
43 namespace WebKit { 45 namespace WebKit {
44 46
45 WebIDBCallbacksImpl::WebIDBCallbacksImpl(PassRefPtr<IDBCallbacks> callbacks) 47 WebIDBCallbacksImpl::WebIDBCallbacksImpl(PassRefPtr<IDBCallbacks> callbacks)
46 : m_callbacks(callbacks) 48 : m_callbacks(callbacks)
47 { 49 {
48 } 50 }
49 51
50 WebIDBCallbacksImpl::~WebIDBCallbacksImpl() 52 WebIDBCallbacksImpl::~WebIDBCallbacksImpl()
51 { 53 {
52 } 54 }
53 55
56 static Vector<BlobInfo> ConvertBlobInfo(const WebVector<WebBlobInfo>& webBlobInf o)
57 {
58 Vector<BlobInfo> blobInfo;
59 for (size_t i = 0; i < webBlobInfo.size(); ++i)
60 blobInfo.append(webBlobInfo[i]);
61 return blobInfo;
62 }
63
54 void WebIDBCallbacksImpl::onError(const WebIDBDatabaseError& error) 64 void WebIDBCallbacksImpl::onError(const WebIDBDatabaseError& error)
55 { 65 {
56 m_callbacks->onError(error); 66 m_callbacks->onError(error);
57 } 67 }
58 68
59 void WebIDBCallbacksImpl::onSuccess(const WebVector<WebString>& webStringList) 69 void WebIDBCallbacksImpl::onSuccess(const WebVector<WebString>& webStringList)
60 { 70 {
61 Vector<String> stringList; 71 Vector<String> stringList;
62 for (size_t i = 0; i < webStringList.size(); ++i) 72 for (size_t i = 0; i < webStringList.size(); ++i)
63 stringList.append(webStringList[i]); 73 stringList.append(webStringList[i]);
64 m_callbacks->onSuccess(stringList); 74 m_callbacks->onSuccess(stringList);
65 } 75 }
66 76
67 void WebIDBCallbacksImpl::onSuccess(WebIDBCursor* cursor, const WebIDBKey& key, const WebIDBKey& primaryKey, const WebData& value) 77 void WebIDBCallbacksImpl::onSuccess(WebIDBCursor* cursor, const WebIDBKey& key, const WebIDBKey& primaryKey, const WebData& value, const WebVector<WebBlobInfo>& webBlobInfo)
68 { 78 {
69 m_callbacks->onSuccess(IDBCursorBackendProxy::create(adoptPtr(cursor)), key, primaryKey, value); 79 m_callbacks->onSuccess(IDBCursorBackendProxy::create(adoptPtr(cursor)), key, primaryKey, value, ConvertBlobInfo(webBlobInfo));
70 } 80 }
71 81
72 void WebIDBCallbacksImpl::onSuccess(WebIDBDatabase* webKitInstance, const WebIDB Metadata& metadata) 82 void WebIDBCallbacksImpl::onSuccess(WebIDBDatabase* webKitInstance, const WebIDB Metadata& metadata)
73 { 83 {
74 if (m_databaseProxy) { 84 if (m_databaseProxy) {
75 m_callbacks->onSuccess(m_databaseProxy.release(), metadata); 85 m_callbacks->onSuccess(m_databaseProxy.release(), metadata);
76 return; 86 return;
77 } 87 }
78 RefPtr<IDBDatabaseBackendInterface> localDatabaseProxy = IDBDatabaseBackendP roxy::create(adoptPtr(webKitInstance)); 88 RefPtr<IDBDatabaseBackendInterface> localDatabaseProxy = IDBDatabaseBackendP roxy::create(adoptPtr(webKitInstance));
79 m_callbacks->onSuccess(localDatabaseProxy.release(), metadata); 89 m_callbacks->onSuccess(localDatabaseProxy.release(), metadata);
80 } 90 }
81 91
82 void WebIDBCallbacksImpl::onSuccess(const WebIDBKey& key) 92 void WebIDBCallbacksImpl::onSuccess(const WebIDBKey& key)
83 { 93 {
84 m_callbacks->onSuccess(key); 94 m_callbacks->onSuccess(key);
85 } 95 }
86 96
87 void WebIDBCallbacksImpl::onSuccess(const WebData& value) 97 void WebIDBCallbacksImpl::onSuccess(const WebData& value, const WebVector<WebBlo bInfo>& webBlobInfo)
88 { 98 {
89 m_callbacks->onSuccess(value); 99 m_callbacks->onSuccess(value, ConvertBlobInfo(webBlobInfo));
90 } 100 }
91 101
92 void WebIDBCallbacksImpl::onSuccess(const WebData& value, const WebIDBKey& key, const WebIDBKeyPath& keyPath) 102 void WebIDBCallbacksImpl::onSuccess(const WebData& value, const WebVector<WebBlo bInfo>& webBlobInfo, const WebIDBKey& key, const WebIDBKeyPath& keyPath)
93 { 103 {
94 m_callbacks->onSuccess(value, key, keyPath); 104 m_callbacks->onSuccess(value, ConvertBlobInfo(webBlobInfo), key, keyPath);
95 } 105 }
96 106
97 void WebIDBCallbacksImpl::onSuccess(long long value) 107 void WebIDBCallbacksImpl::onSuccess(long long value)
98 { 108 {
99 m_callbacks->onSuccess(value); 109 m_callbacks->onSuccess(value);
100 } 110 }
101 111
102 void WebIDBCallbacksImpl::onSuccess() 112 void WebIDBCallbacksImpl::onSuccess()
103 { 113 {
104 m_callbacks->onSuccess(); 114 m_callbacks->onSuccess();
105 } 115 }
106 116
107 void WebIDBCallbacksImpl::onSuccess(const WebIDBKey& key, const WebIDBKey& prima ryKey, const WebData& value) 117 void WebIDBCallbacksImpl::onSuccess(const WebIDBKey& key, const WebIDBKey& prima ryKey, const WebData& value, const WebVector<WebBlobInfo>& webBlobInfo)
108 { 118 {
109 m_callbacks->onSuccess(key, primaryKey, value); 119 m_callbacks->onSuccess(key, primaryKey, value, ConvertBlobInfo(webBlobInfo)) ;
110 } 120 }
111 121
112 void WebIDBCallbacksImpl::onBlocked(long long oldVersion) 122 void WebIDBCallbacksImpl::onBlocked(long long oldVersion)
113 { 123 {
114 m_callbacks->onBlocked(oldVersion); 124 m_callbacks->onBlocked(oldVersion);
115 } 125 }
116 126
117 void WebIDBCallbacksImpl::onUpgradeNeeded(long long oldVersion, WebIDBDatabase* database, const WebIDBMetadata& metadata, DataLoss dataLoss) 127 void WebIDBCallbacksImpl::onUpgradeNeeded(long long oldVersion, WebIDBDatabase* database, const WebIDBMetadata& metadata, DataLoss dataLoss)
118 { 128 {
119 m_databaseProxy = IDBDatabaseBackendProxy::create(adoptPtr(database)); 129 m_databaseProxy = IDBDatabaseBackendProxy::create(adoptPtr(database));
120 m_callbacks->onUpgradeNeeded(oldVersion, m_databaseProxy, metadata, dataLoss ); 130 m_callbacks->onUpgradeNeeded(oldVersion, m_databaseProxy, metadata, dataLoss );
121 } 131 }
122 132
123 } // namespace WebKit 133 } // namespace WebKit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698