| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/common/indexed_db/indexed_db_messages.h" | 7 #include "content/common/indexed_db/indexed_db_messages.h" |
| 8 #include "webkit/quota/quota_manager.h" | 8 #include "webkit/quota/quota_manager.h" |
| 9 | 9 |
| 10 using content::IndexedDBKey; |
| 11 using content::SerializedScriptValue; |
| 12 |
| 10 IndexedDBCallbacksBase::IndexedDBCallbacksBase( | 13 IndexedDBCallbacksBase::IndexedDBCallbacksBase( |
| 11 IndexedDBDispatcherHost* dispatcher_host, | 14 IndexedDBDispatcherHost* dispatcher_host, |
| 12 int32 thread_id, | 15 int32 thread_id, |
| 13 int32 response_id) | 16 int32 response_id) |
| 14 : dispatcher_host_(dispatcher_host), | 17 : dispatcher_host_(dispatcher_host), |
| 15 response_id_(response_id), | 18 response_id_(response_id), |
| 16 thread_id_(thread_id) { | 19 thread_id_(thread_id) { |
| 17 } | 20 } |
| 18 | 21 |
| 19 IndexedDBCallbacksBase::~IndexedDBCallbacksBase() {} | 22 IndexedDBCallbacksBase::~IndexedDBCallbacksBase() {} |
| (...skipping 10 matching lines...) Expand all Loading... |
| 30 | 33 |
| 31 void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccess( | 34 void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccess( |
| 32 WebKit::WebIDBCursor* idb_object) { | 35 WebKit::WebIDBCursor* idb_object) { |
| 33 int32 object_id = dispatcher_host()->Add(idb_object); | 36 int32 object_id = dispatcher_host()->Add(idb_object); |
| 34 IndexedDBMsg_CallbacksSuccessIDBCursor_Params params; | 37 IndexedDBMsg_CallbacksSuccessIDBCursor_Params params; |
| 35 params.thread_id = thread_id(); | 38 params.thread_id = thread_id(); |
| 36 params.response_id = response_id(); | 39 params.response_id = response_id(); |
| 37 params.cursor_id = object_id; | 40 params.cursor_id = object_id; |
| 38 params.key = IndexedDBKey(idb_object->key()); | 41 params.key = IndexedDBKey(idb_object->key()); |
| 39 params.primary_key = IndexedDBKey(idb_object->primaryKey()); | 42 params.primary_key = IndexedDBKey(idb_object->primaryKey()); |
| 40 params.serialized_value = content::SerializedScriptValue(idb_object->value()); | 43 params.serialized_value = SerializedScriptValue(idb_object->value()); |
| 41 dispatcher_host()->Send(new IndexedDBMsg_CallbacksSuccessIDBCursor(params)); | 44 dispatcher_host()->Send(new IndexedDBMsg_CallbacksSuccessIDBCursor(params)); |
| 42 } | 45 } |
| 43 | 46 |
| 44 void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccess( | 47 void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccess( |
| 45 const WebKit::WebSerializedScriptValue& value) { | 48 const WebKit::WebSerializedScriptValue& value) { |
| 46 dispatcher_host()->Send( | 49 dispatcher_host()->Send( |
| 47 new IndexedDBMsg_CallbacksSuccessSerializedScriptValue( | 50 new IndexedDBMsg_CallbacksSuccessSerializedScriptValue( |
| 48 thread_id(), response_id(), content::SerializedScriptValue(value))); | 51 thread_id(), response_id(), SerializedScriptValue(value))); |
| 49 } | 52 } |
| 50 | 53 |
| 51 void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccessWithContinuation() { | 54 void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccessWithContinuation() { |
| 52 DCHECK(cursor_id_ != -1); | 55 DCHECK(cursor_id_ != -1); |
| 53 WebKit::WebIDBCursor* idb_cursor = dispatcher_host()->GetCursorFromId( | 56 WebKit::WebIDBCursor* idb_cursor = dispatcher_host()->GetCursorFromId( |
| 54 cursor_id_); | 57 cursor_id_); |
| 55 | 58 |
| 56 DCHECK(idb_cursor); | 59 DCHECK(idb_cursor); |
| 57 if (!idb_cursor) | 60 if (!idb_cursor) |
| 58 return; | 61 return; |
| 59 IndexedDBMsg_CallbacksSuccessCursorContinue_Params params; | 62 IndexedDBMsg_CallbacksSuccessCursorContinue_Params params; |
| 60 params.thread_id = thread_id(); | 63 params.thread_id = thread_id(); |
| 61 params.response_id = response_id(); | 64 params.response_id = response_id(); |
| 62 params.cursor_id = cursor_id_; | 65 params.cursor_id = cursor_id_; |
| 63 params.key = IndexedDBKey(idb_cursor->key()); | 66 params.key = IndexedDBKey(idb_cursor->key()); |
| 64 params.primary_key = IndexedDBKey(idb_cursor->primaryKey()); | 67 params.primary_key = IndexedDBKey(idb_cursor->primaryKey()); |
| 65 params.serialized_value = content::SerializedScriptValue(idb_cursor->value()); | 68 params.serialized_value = SerializedScriptValue(idb_cursor->value()); |
| 66 | 69 |
| 67 dispatcher_host()->Send( | 70 dispatcher_host()->Send( |
| 68 new IndexedDBMsg_CallbacksSuccessCursorContinue(params)); | 71 new IndexedDBMsg_CallbacksSuccessCursorContinue(params)); |
| 69 } | 72 } |
| 70 | 73 |
| 71 void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccessWithPrefetch( | 74 void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccessWithPrefetch( |
| 72 const WebKit::WebVector<WebKit::WebIDBKey>& keys, | 75 const WebKit::WebVector<WebKit::WebIDBKey>& keys, |
| 73 const WebKit::WebVector<WebKit::WebIDBKey>& primaryKeys, | 76 const WebKit::WebVector<WebKit::WebIDBKey>& primaryKeys, |
| 74 const WebKit::WebVector<WebKit::WebSerializedScriptValue>& values) { | 77 const WebKit::WebVector<WebKit::WebSerializedScriptValue>& values) { |
| 75 DCHECK(cursor_id_ != -1); | 78 DCHECK(cursor_id_ != -1); |
| 76 | 79 |
| 77 std::vector<IndexedDBKey> msgKeys; | 80 std::vector<IndexedDBKey> msgKeys; |
| 78 std::vector<IndexedDBKey> msgPrimaryKeys; | 81 std::vector<IndexedDBKey> msgPrimaryKeys; |
| 79 std::vector<content::SerializedScriptValue> msgValues; | 82 std::vector<SerializedScriptValue> msgValues; |
| 80 | 83 |
| 81 for (size_t i = 0; i < keys.size(); ++i) { | 84 for (size_t i = 0; i < keys.size(); ++i) { |
| 82 msgKeys.push_back(IndexedDBKey(keys[i])); | 85 msgKeys.push_back(IndexedDBKey(keys[i])); |
| 83 msgPrimaryKeys.push_back(IndexedDBKey(primaryKeys[i])); | 86 msgPrimaryKeys.push_back(IndexedDBKey(primaryKeys[i])); |
| 84 msgValues.push_back(content::SerializedScriptValue(values[i])); | 87 msgValues.push_back(SerializedScriptValue(values[i])); |
| 85 } | 88 } |
| 86 | 89 |
| 87 IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params params; | 90 IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params params; |
| 88 params.thread_id = thread_id(); | 91 params.thread_id = thread_id(); |
| 89 params.response_id = response_id(); | 92 params.response_id = response_id(); |
| 90 params.cursor_id = cursor_id_; | 93 params.cursor_id = cursor_id_; |
| 91 params.keys = msgKeys; | 94 params.keys = msgKeys; |
| 92 params.primary_keys = msgPrimaryKeys; | 95 params.primary_keys = msgPrimaryKeys; |
| 93 params.values = msgValues; | 96 params.values = msgValues; |
| 94 dispatcher_host()->Send( | 97 dispatcher_host()->Send( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 111 | 114 |
| 112 dispatcher_host()->Send( | 115 dispatcher_host()->Send( |
| 113 new IndexedDBMsg_CallbacksSuccessStringList( | 116 new IndexedDBMsg_CallbacksSuccessStringList( |
| 114 thread_id(), response_id(), list)); | 117 thread_id(), response_id(), list)); |
| 115 } | 118 } |
| 116 | 119 |
| 117 void IndexedDBCallbacks<WebKit::WebSerializedScriptValue>::onSuccess( | 120 void IndexedDBCallbacks<WebKit::WebSerializedScriptValue>::onSuccess( |
| 118 const WebKit::WebSerializedScriptValue& value) { | 121 const WebKit::WebSerializedScriptValue& value) { |
| 119 dispatcher_host()->Send( | 122 dispatcher_host()->Send( |
| 120 new IndexedDBMsg_CallbacksSuccessSerializedScriptValue( | 123 new IndexedDBMsg_CallbacksSuccessSerializedScriptValue( |
| 121 thread_id(), response_id(), content::SerializedScriptValue(value))); | 124 thread_id(), response_id(), SerializedScriptValue(value))); |
| 122 } | 125 } |
| OLD | NEW |