| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/in_process_webkit/indexed_db_callbacks.h" | 5 #include "content/browser/in_process_webkit/indexed_db_callbacks.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "content/common/indexed_db/indexed_db_messages.h" | 9 #include "content/common/indexed_db/indexed_db_messages.h" |
| 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSerializedScriptVa
lue.h" |
| 10 #include "webkit/quota/quota_manager.h" | 11 #include "webkit/quota/quota_manager.h" |
| 11 | 12 |
| 12 namespace content { | 13 namespace content { |
| 13 | 14 |
| 14 namespace { | 15 namespace { |
| 15 const int32 kDatabaseNotAdded = -1; | 16 const int32 kDatabaseNotAdded = -1; |
| 16 } | 17 } |
| 17 | 18 |
| 18 IndexedDBCallbacksBase::IndexedDBCallbacksBase( | 19 IndexedDBCallbacksBase::IndexedDBCallbacksBase( |
| 19 IndexedDBDispatcherHost* dispatcher_host, | 20 IndexedDBDispatcherHost* dispatcher_host, |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 old_version, | 87 old_version, |
| 87 idb_metadata)); | 88 idb_metadata)); |
| 88 } | 89 } |
| 89 | 90 |
| 90 void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccess( | 91 void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccess( |
| 91 WebKit::WebIDBCursor* idb_cursor, | 92 WebKit::WebIDBCursor* idb_cursor, |
| 92 const WebKit::WebIDBKey& key, | 93 const WebKit::WebIDBKey& key, |
| 93 const WebKit::WebIDBKey& primaryKey, | 94 const WebKit::WebIDBKey& primaryKey, |
| 94 const WebKit::WebSerializedScriptValue& value) { | 95 const WebKit::WebSerializedScriptValue& value) { |
| 95 int32 ipc_object_id = dispatcher_host()->Add(idb_cursor); | 96 int32 ipc_object_id = dispatcher_host()->Add(idb_cursor); |
| 97 IndexedDBMsg_CallbacksSuccessIDBCursorOld_Params params; |
| 98 params.ipc_thread_id = ipc_thread_id(); |
| 99 params.ipc_response_id = ipc_response_id(); |
| 100 params.ipc_cursor_id = ipc_object_id; |
| 101 params.key = IndexedDBKey(key); |
| 102 params.primary_key = IndexedDBKey(primaryKey); |
| 103 params.serialized_value = SerializedScriptValue(value); |
| 104 dispatcher_host()->Send( |
| 105 new IndexedDBMsg_CallbacksSuccessIDBCursorOld(params)); |
| 106 } |
| 107 |
| 108 void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccess( |
| 109 WebKit::WebIDBCursor* idb_cursor, |
| 110 const WebKit::WebIDBKey& key, |
| 111 const WebKit::WebIDBKey& primaryKey, |
| 112 const WebKit::WebData& value) { |
| 113 int32 ipc_object_id = dispatcher_host()->Add(idb_cursor); |
| 96 IndexedDBMsg_CallbacksSuccessIDBCursor_Params params; | 114 IndexedDBMsg_CallbacksSuccessIDBCursor_Params params; |
| 97 params.ipc_thread_id = ipc_thread_id(); | 115 params.ipc_thread_id = ipc_thread_id(); |
| 98 params.ipc_response_id = ipc_response_id(); | 116 params.ipc_response_id = ipc_response_id(); |
| 99 params.ipc_cursor_id = ipc_object_id; | 117 params.ipc_cursor_id = ipc_object_id; |
| 100 params.key = IndexedDBKey(key); | 118 params.key = IndexedDBKey(key); |
| 101 params.primary_key = IndexedDBKey(primaryKey); | 119 params.primary_key = IndexedDBKey(primaryKey); |
| 102 params.serialized_value = SerializedScriptValue(value); | 120 params.value.assign(value.data(), value.data() + value.size()); |
| 103 dispatcher_host()->Send(new IndexedDBMsg_CallbacksSuccessIDBCursor(params)); | 121 dispatcher_host()->Send(new IndexedDBMsg_CallbacksSuccessIDBCursor(params)); |
| 104 } | 122 } |
| 105 | 123 |
| 106 void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccess( | 124 void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccess( |
| 107 const WebKit::WebSerializedScriptValue& value) { | 125 const WebKit::WebSerializedScriptValue& value) { |
| 108 dispatcher_host()->Send( | 126 dispatcher_host()->Send( |
| 109 new IndexedDBMsg_CallbacksSuccessSerializedScriptValue( | 127 new IndexedDBMsg_CallbacksSuccessSerializedScriptValue( |
| 110 ipc_thread_id(), ipc_response_id(), SerializedScriptValue(value))); | 128 ipc_thread_id(), ipc_response_id(), SerializedScriptValue(value))); |
| 111 } | 129 } |
| 112 | 130 |
| 113 void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccess( | 131 void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccess( |
| 132 const WebKit::WebData& webValue) { |
| 133 std::vector<char> value(webValue.data(), webValue.data() + webValue.size()); |
| 134 dispatcher_host()->Send( |
| 135 new IndexedDBMsg_CallbacksSuccessValue( |
| 136 ipc_thread_id(), ipc_response_id(), value)); |
| 137 } |
| 138 |
| 139 void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccess( |
| 114 const WebKit::WebIDBKey& key, | 140 const WebKit::WebIDBKey& key, |
| 115 const WebKit::WebIDBKey& primaryKey, | 141 const WebKit::WebIDBKey& primaryKey, |
| 116 const WebKit::WebSerializedScriptValue& value) { | 142 const WebKit::WebSerializedScriptValue& value) { |
| 117 DCHECK_NE(ipc_cursor_id_, -1); | 143 DCHECK_NE(ipc_cursor_id_, -1); |
| 118 WebKit::WebIDBCursor* idb_cursor = dispatcher_host()->GetCursorFromId( | 144 WebKit::WebIDBCursor* idb_cursor = dispatcher_host()->GetCursorFromId( |
| 119 ipc_cursor_id_); | 145 ipc_cursor_id_); |
| 120 | 146 |
| 121 DCHECK(idb_cursor); | 147 DCHECK(idb_cursor); |
| 122 if (!idb_cursor) | 148 if (!idb_cursor) |
| 123 return; | 149 return; |
| 124 IndexedDBMsg_CallbacksSuccessCursorContinue_Params params; | 150 IndexedDBMsg_CallbacksSuccessCursorContinueOld_Params params; |
| 125 params.ipc_thread_id = ipc_thread_id(); | 151 params.ipc_thread_id = ipc_thread_id(); |
| 126 params.ipc_response_id = ipc_response_id(); | 152 params.ipc_response_id = ipc_response_id(); |
| 127 params.ipc_cursor_id = ipc_cursor_id_; | 153 params.ipc_cursor_id = ipc_cursor_id_; |
| 128 params.key = IndexedDBKey(key); | 154 params.key = IndexedDBKey(key); |
| 129 params.primary_key = IndexedDBKey(primaryKey); | 155 params.primary_key = IndexedDBKey(primaryKey); |
| 130 params.serialized_value = SerializedScriptValue(value); | 156 params.serialized_value = SerializedScriptValue(value); |
| 131 dispatcher_host()->Send( | 157 dispatcher_host()->Send( |
| 158 new IndexedDBMsg_CallbacksSuccessCursorContinueOld(params)); |
| 159 } |
| 160 |
| 161 void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccess( |
| 162 const WebKit::WebIDBKey& key, |
| 163 const WebKit::WebIDBKey& primaryKey, |
| 164 const WebKit::WebData& value) { |
| 165 DCHECK_NE(ipc_cursor_id_, -1); |
| 166 WebKit::WebIDBCursor* idb_cursor = dispatcher_host()->GetCursorFromId( |
| 167 ipc_cursor_id_); |
| 168 |
| 169 DCHECK(idb_cursor); |
| 170 if (!idb_cursor) |
| 171 return; |
| 172 IndexedDBMsg_CallbacksSuccessCursorContinue_Params params; |
| 173 params.ipc_thread_id = ipc_thread_id(); |
| 174 params.ipc_response_id = ipc_response_id(); |
| 175 params.ipc_cursor_id = ipc_cursor_id_; |
| 176 params.key = IndexedDBKey(key); |
| 177 params.primary_key = IndexedDBKey(primaryKey); |
| 178 params.value.assign(value.data(), value.data() + value.size()); |
| 179 dispatcher_host()->Send( |
| 132 new IndexedDBMsg_CallbacksSuccessCursorContinue(params)); | 180 new IndexedDBMsg_CallbacksSuccessCursorContinue(params)); |
| 133 } | 181 } |
| 134 | 182 |
| 135 void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccessWithPrefetch( | 183 void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccessWithPrefetch( |
| 136 const WebKit::WebVector<WebKit::WebIDBKey>& keys, | 184 const WebKit::WebVector<WebKit::WebIDBKey>& keys, |
| 137 const WebKit::WebVector<WebKit::WebIDBKey>& primaryKeys, | 185 const WebKit::WebVector<WebKit::WebIDBKey>& primaryKeys, |
| 138 const WebKit::WebVector<WebKit::WebSerializedScriptValue>& values) { | 186 const WebKit::WebVector<WebKit::WebSerializedScriptValue>& values) { |
| 139 DCHECK_NE(ipc_cursor_id_, -1); | 187 DCHECK_NE(ipc_cursor_id_, -1); |
| 140 | 188 |
| 141 std::vector<IndexedDBKey> msgKeys; | 189 std::vector<IndexedDBKey> msgKeys; |
| 142 std::vector<IndexedDBKey> msgPrimaryKeys; | 190 std::vector<IndexedDBKey> msgPrimaryKeys; |
| 143 std::vector<SerializedScriptValue> msgValues; | 191 std::vector<SerializedScriptValue> msgValues; |
| 144 | 192 |
| 145 for (size_t i = 0; i < keys.size(); ++i) { | 193 for (size_t i = 0; i < keys.size(); ++i) { |
| 146 msgKeys.push_back(IndexedDBKey(keys[i])); | 194 msgKeys.push_back(IndexedDBKey(keys[i])); |
| 147 msgPrimaryKeys.push_back(IndexedDBKey(primaryKeys[i])); | 195 msgPrimaryKeys.push_back(IndexedDBKey(primaryKeys[i])); |
| 148 msgValues.push_back(SerializedScriptValue(values[i])); | 196 msgValues.push_back(SerializedScriptValue(values[i])); |
| 149 } | 197 } |
| 150 | 198 |
| 199 IndexedDBMsg_CallbacksSuccessCursorPrefetchOld_Params params; |
| 200 params.ipc_thread_id = ipc_thread_id(); |
| 201 params.ipc_response_id = ipc_response_id(); |
| 202 params.ipc_cursor_id = ipc_cursor_id_; |
| 203 params.keys = msgKeys; |
| 204 params.primary_keys = msgPrimaryKeys; |
| 205 params.values = msgValues; |
| 206 dispatcher_host()->Send( |
| 207 new IndexedDBMsg_CallbacksSuccessCursorPrefetchOld(params)); |
| 208 } |
| 209 |
| 210 void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccessWithPrefetch( |
| 211 const WebKit::WebVector<WebKit::WebIDBKey>& keys, |
| 212 const WebKit::WebVector<WebKit::WebIDBKey>& primaryKeys, |
| 213 const WebKit::WebVector<WebKit::WebData>& values) { |
| 214 DCHECK_NE(ipc_cursor_id_, -1); |
| 215 |
| 216 std::vector<IndexedDBKey> msgKeys; |
| 217 std::vector<IndexedDBKey> msgPrimaryKeys; |
| 218 std::vector<std::vector<char> > msgValues; |
| 219 |
| 220 for (size_t i = 0; i < keys.size(); ++i) { |
| 221 msgKeys.push_back(IndexedDBKey(keys[i])); |
| 222 msgPrimaryKeys.push_back(IndexedDBKey(primaryKeys[i])); |
| 223 msgValues.push_back( |
| 224 std::vector<char>(values[i].data(), |
| 225 values[i].data() + values[i].size())); |
| 226 } |
| 227 |
| 151 IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params params; | 228 IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params params; |
| 152 params.ipc_thread_id = ipc_thread_id(); | 229 params.ipc_thread_id = ipc_thread_id(); |
| 153 params.ipc_response_id = ipc_response_id(); | 230 params.ipc_response_id = ipc_response_id(); |
| 154 params.ipc_cursor_id = ipc_cursor_id_; | 231 params.ipc_cursor_id = ipc_cursor_id_; |
| 155 params.keys = msgKeys; | 232 params.keys = msgKeys; |
| 156 params.primary_keys = msgPrimaryKeys; | 233 params.primary_keys = msgPrimaryKeys; |
| 157 params.values = msgValues; | 234 params.values = msgValues; |
| 158 dispatcher_host()->Send( | 235 dispatcher_host()->Send( |
| 159 new IndexedDBMsg_CallbacksSuccessCursorPrefetch(params)); | 236 new IndexedDBMsg_CallbacksSuccessCursorPrefetch(params)); |
| 160 } | 237 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 171 | 248 |
| 172 std::vector<string16> list; | 249 std::vector<string16> list; |
| 173 for (unsigned i = 0; i < value.length(); ++i) | 250 for (unsigned i = 0; i < value.length(); ++i) |
| 174 list.push_back(value.item(i)); | 251 list.push_back(value.item(i)); |
| 175 | 252 |
| 176 dispatcher_host()->Send( | 253 dispatcher_host()->Send( |
| 177 new IndexedDBMsg_CallbacksSuccessStringList( | 254 new IndexedDBMsg_CallbacksSuccessStringList( |
| 178 ipc_thread_id(), ipc_response_id(), list)); | 255 ipc_thread_id(), ipc_response_id(), list)); |
| 179 } | 256 } |
| 180 | 257 |
| 181 void IndexedDBCallbacks<WebKit::WebSerializedScriptValue>::onSuccess( | 258 void IndexedDBCallbacks<WebKit::WebData>::onSuccess( |
| 182 const WebKit::WebSerializedScriptValue& value) { | 259 const WebKit::WebSerializedScriptValue& value) { |
| 183 dispatcher_host()->Send( | 260 dispatcher_host()->Send( |
| 184 new IndexedDBMsg_CallbacksSuccessSerializedScriptValue( | 261 new IndexedDBMsg_CallbacksSuccessSerializedScriptValue( |
| 185 ipc_thread_id(), ipc_response_id(), SerializedScriptValue(value))); | 262 ipc_thread_id(), ipc_response_id(), SerializedScriptValue(value))); |
| 186 } | 263 } |
| 187 | 264 |
| 188 void IndexedDBCallbacks<WebKit::WebSerializedScriptValue>::onSuccess( | 265 void IndexedDBCallbacks<WebKit::WebData>::onSuccess( |
| 266 const WebKit::WebData& value) { |
| 267 dispatcher_host()->Send( |
| 268 new IndexedDBMsg_CallbacksSuccessValue( |
| 269 ipc_thread_id(), ipc_response_id(), |
| 270 std::vector<char>(value.data(), value.data() + value.size()))); |
| 271 } |
| 272 |
| 273 void IndexedDBCallbacks<WebKit::WebData>::onSuccess( |
| 189 const WebKit::WebSerializedScriptValue& value, | 274 const WebKit::WebSerializedScriptValue& value, |
| 190 const WebKit::WebIDBKey& primaryKey, | 275 const WebKit::WebIDBKey& primaryKey, |
| 191 const WebKit::WebIDBKeyPath& keyPath) { | 276 const WebKit::WebIDBKeyPath& keyPath) { |
| 192 dispatcher_host()->Send( | 277 dispatcher_host()->Send( |
| 193 new IndexedDBMsg_CallbacksSuccessSerializedScriptValueWithKey( | 278 new IndexedDBMsg_CallbacksSuccessSerializedScriptValueWithKey( |
| 194 ipc_thread_id(), ipc_response_id(), SerializedScriptValue(value), | 279 ipc_thread_id(), ipc_response_id(), SerializedScriptValue(value), |
| 195 IndexedDBKey(primaryKey), IndexedDBKeyPath(keyPath))); | 280 IndexedDBKey(primaryKey), IndexedDBKeyPath(keyPath))); |
| 196 } | 281 } |
| 197 | 282 |
| 198 void IndexedDBCallbacks<WebKit::WebSerializedScriptValue>::onSuccess( | 283 void IndexedDBCallbacks<WebKit::WebData>::onSuccess( |
| 284 const WebKit::WebData& value, |
| 285 const WebKit::WebIDBKey& primaryKey, |
| 286 const WebKit::WebIDBKeyPath& keyPath) { |
| 287 dispatcher_host()->Send( |
| 288 new IndexedDBMsg_CallbacksSuccessValueWithKey( |
| 289 ipc_thread_id(), ipc_response_id(), |
| 290 std::vector<char>(value.data(), value.data() + value.size()), |
| 291 IndexedDBKey(primaryKey), IndexedDBKeyPath(keyPath))); |
| 292 } |
| 293 |
| 294 void IndexedDBCallbacks<WebKit::WebData>::onSuccess( |
| 199 long long value) { | 295 long long value) { |
| 200 dispatcher_host()->Send( | 296 dispatcher_host()->Send( |
| 201 new IndexedDBMsg_CallbacksSuccessInteger(ipc_thread_id(), | 297 new IndexedDBMsg_CallbacksSuccessInteger(ipc_thread_id(), |
| 202 ipc_response_id(), | 298 ipc_response_id(), |
| 203 value)); | 299 value)); |
| 204 } | 300 } |
| 205 | 301 |
| 206 void IndexedDBCallbacks<WebKit::WebSerializedScriptValue>::onSuccess() { | 302 void IndexedDBCallbacks<WebKit::WebData>::onSuccess() { |
| 207 dispatcher_host()->Send( | 303 dispatcher_host()->Send( |
| 208 new IndexedDBMsg_CallbacksSuccessUndefined(ipc_thread_id(), | 304 new IndexedDBMsg_CallbacksSuccessUndefined(ipc_thread_id(), |
| 209 ipc_response_id())); | 305 ipc_response_id())); |
| 210 } | 306 } |
| 211 | 307 |
| 212 void IndexedDBCallbacks<WebKit::WebSerializedScriptValue>::onSuccess( | 308 void IndexedDBCallbacks<WebKit::WebData>::onSuccess( |
| 213 const WebKit::WebIDBKey& value) { | 309 const WebKit::WebIDBKey& value) { |
| 214 dispatcher_host()->Send( | 310 dispatcher_host()->Send( |
| 215 new IndexedDBMsg_CallbacksSuccessIndexedDBKey( | 311 new IndexedDBMsg_CallbacksSuccessIndexedDBKey( |
| 216 ipc_thread_id(), ipc_response_id(), IndexedDBKey(value))); | 312 ipc_thread_id(), ipc_response_id(), IndexedDBKey(value))); |
| 217 } | 313 } |
| 218 | 314 |
| 219 } // namespace content | 315 } // namespace content |
| OLD | NEW |