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/common/indexed_db/proxy_webidbobjectstore_impl.h" | 5 #include "content/common/indexed_db/proxy_webidbobjectstore_impl.h" |
6 | 6 |
| 7 #include <vector> |
| 8 |
7 #include "content/common/indexed_db/indexed_db_messages.h" | 9 #include "content/common/indexed_db/indexed_db_messages.h" |
8 #include "content/public/common/serialized_script_value.h" | 10 #include "content/public/common/serialized_script_value.h" |
9 #include "content/common/indexed_db/indexed_db_dispatcher.h" | 11 #include "content/common/indexed_db/indexed_db_dispatcher.h" |
10 #include "content/common/indexed_db/proxy_webidbindex_impl.h" | 12 #include "content/common/indexed_db/proxy_webidbindex_impl.h" |
11 #include "content/common/indexed_db/proxy_webidbtransaction_impl.h" | 13 #include "content/common/indexed_db/proxy_webidbtransaction_impl.h" |
12 #include "content/common/child_thread.h" | 14 #include "content/common/child_thread.h" |
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMStringList.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMStringList.h" |
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKey.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKey.h" |
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyPath.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyPath.h" |
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyRange.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyRange.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 IndexedDBKeyRange(key_range), callbacks, | 62 IndexedDBKeyRange(key_range), callbacks, |
61 idb_object_store_id_, transaction, &ec); | 63 idb_object_store_id_, transaction, &ec); |
62 } | 64 } |
63 | 65 |
64 void RendererWebIDBObjectStoreImpl::putWithIndexKeys( | 66 void RendererWebIDBObjectStoreImpl::putWithIndexKeys( |
65 const WebSerializedScriptValue& value, | 67 const WebSerializedScriptValue& value, |
66 const WebIDBKey& key, | 68 const WebIDBKey& key, |
67 PutMode put_mode, | 69 PutMode put_mode, |
68 WebIDBCallbacks* callbacks, | 70 WebIDBCallbacks* callbacks, |
69 const WebIDBTransaction& transaction, | 71 const WebIDBTransaction& transaction, |
70 const WebVector<WebString>& indexNames, | 72 const WebVector<WebString>& index_names, |
71 const WebVector<WebVector<WebIDBKey> >& indexKeys, | 73 const WebVector<WebVector<WebIDBKey> >& index_keys, |
72 WebExceptionCode& ec) { | 74 WebExceptionCode& ec) { |
73 IndexedDBDispatcher* dispatcher = | 75 IndexedDBDispatcher* dispatcher = |
74 IndexedDBDispatcher::ThreadSpecificInstance(); | 76 IndexedDBDispatcher::ThreadSpecificInstance(); |
75 dispatcher->RequestIDBObjectStorePut( | 77 dispatcher->RequestIDBObjectStorePut( |
76 SerializedScriptValue(value), IndexedDBKey(key), | 78 SerializedScriptValue(value), IndexedDBKey(key), |
77 put_mode, callbacks, idb_object_store_id_, transaction, | 79 put_mode, callbacks, idb_object_store_id_, transaction, |
78 indexNames, indexKeys, &ec); | 80 index_names, index_keys, &ec); |
79 } | 81 } |
80 | 82 |
| 83 void RendererWebIDBObjectStoreImpl::setIndexKeys( |
| 84 const WebKit::WebIDBKey& primaryKey, |
| 85 const WebKit::WebVector<WebKit::WebString>& index_names, |
| 86 const WebKit::WebVector<WebIndexKeys>& index_keys, |
| 87 const WebKit::WebIDBTransaction& transaction) { |
| 88 std::vector<string16> index_names_list(index_names.size()); |
| 89 for (size_t i = 0; i < index_names.size(); ++i) { |
| 90 index_names_list[i] = index_names[i]; |
| 91 } |
| 92 |
| 93 std::vector<std::vector<content::IndexedDBKey> > |
| 94 index_keys_list(index_keys.size()); |
| 95 for (size_t i = 0; i < index_keys.size(); ++i) { |
| 96 index_keys_list[i].resize(index_keys[i].size()); |
| 97 for (size_t j = 0; j < index_keys[i].size(); ++j) { |
| 98 index_keys_list[i][j] = content::IndexedDBKey(index_keys[i][j]); |
| 99 } |
| 100 } |
| 101 IndexedDBDispatcher::Send(new IndexedDBHostMsg_ObjectStoreSetIndexKeys( |
| 102 idb_object_store_id_, |
| 103 IndexedDBKey(primaryKey), |
| 104 index_names_list, |
| 105 index_keys_list, |
| 106 IndexedDBDispatcher::TransactionId(transaction))); |
| 107 } |
| 108 |
| 109 void RendererWebIDBObjectStoreImpl::setIndexesReady( |
| 110 const WebKit::WebVector<WebKit::WebString>& index_names, |
| 111 const WebKit::WebIDBTransaction& transaction) { |
| 112 |
| 113 std::vector<string16> index_name_list(index_names.size()); |
| 114 for (size_t i = 0; i < index_names.size(); ++i) { |
| 115 index_name_list[i] = index_names[i]; |
| 116 } |
| 117 |
| 118 IndexedDBDispatcher::Send(new IndexedDBHostMsg_ObjectStoreSetIndexesReady( |
| 119 idb_object_store_id_, |
| 120 index_name_list, IndexedDBDispatcher::TransactionId(transaction))); |
| 121 } |
| 122 |
| 123 |
81 void RendererWebIDBObjectStoreImpl::deleteFunction( | 124 void RendererWebIDBObjectStoreImpl::deleteFunction( |
82 const WebIDBKeyRange& key_range, | 125 const WebIDBKeyRange& key_range, |
83 WebIDBCallbacks* callbacks, | 126 WebIDBCallbacks* callbacks, |
84 const WebIDBTransaction& transaction, | 127 const WebIDBTransaction& transaction, |
85 WebExceptionCode& ec) { | 128 WebExceptionCode& ec) { |
86 IndexedDBDispatcher* dispatcher = | 129 IndexedDBDispatcher* dispatcher = |
87 IndexedDBDispatcher::ThreadSpecificInstance(); | 130 IndexedDBDispatcher::ThreadSpecificInstance(); |
88 dispatcher->RequestIDBObjectStoreDelete( | 131 dispatcher->RequestIDBObjectStoreDelete( |
89 IndexedDBKeyRange(key_range), callbacks, idb_object_store_id_, | 132 IndexedDBKeyRange(key_range), callbacks, idb_object_store_id_, |
90 transaction, &ec); | 133 transaction, &ec); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 const WebIDBTransaction& transaction, | 183 const WebIDBTransaction& transaction, |
141 WebExceptionCode& ec) { | 184 WebExceptionCode& ec) { |
142 IndexedDBDispatcher::Send( | 185 IndexedDBDispatcher::Send( |
143 new IndexedDBHostMsg_ObjectStoreDeleteIndex( | 186 new IndexedDBHostMsg_ObjectStoreDeleteIndex( |
144 idb_object_store_id_, name, | 187 idb_object_store_id_, name, |
145 IndexedDBDispatcher::TransactionId(transaction), &ec)); | 188 IndexedDBDispatcher::TransactionId(transaction), &ec)); |
146 } | 189 } |
147 | 190 |
148 void RendererWebIDBObjectStoreImpl::openCursor( | 191 void RendererWebIDBObjectStoreImpl::openCursor( |
149 const WebIDBKeyRange& idb_key_range, | 192 const WebIDBKeyRange& idb_key_range, |
| 193 WebKit::WebIDBCursor::Direction direction, WebIDBCallbacks* callbacks, |
| 194 WebKit::WebIDBTransaction::TaskType task_type, |
| 195 const WebIDBTransaction& transaction, |
| 196 WebExceptionCode& ec) { |
| 197 IndexedDBDispatcher* dispatcher = |
| 198 IndexedDBDispatcher::ThreadSpecificInstance(); |
| 199 dispatcher->RequestIDBObjectStoreOpenCursor( |
| 200 idb_key_range, direction, callbacks, idb_object_store_id_, |
| 201 task_type, transaction, &ec); |
| 202 } |
| 203 |
| 204 void RendererWebIDBObjectStoreImpl::openCursor( |
| 205 const WebIDBKeyRange& idb_key_range, |
150 unsigned short direction, WebIDBCallbacks* callbacks, | 206 unsigned short direction, WebIDBCallbacks* callbacks, |
151 const WebIDBTransaction& transaction, | 207 const WebIDBTransaction& transaction, |
152 WebExceptionCode& ec) { | 208 WebExceptionCode& ec) { |
153 IndexedDBDispatcher* dispatcher = | 209 IndexedDBDispatcher* dispatcher = |
154 IndexedDBDispatcher::ThreadSpecificInstance(); | 210 IndexedDBDispatcher::ThreadSpecificInstance(); |
155 dispatcher->RequestIDBObjectStoreOpenCursor( | 211 dispatcher->RequestIDBObjectStoreOpenCursor( |
156 idb_key_range, direction, callbacks, idb_object_store_id_, | 212 idb_key_range, static_cast<WebKit::WebIDBCursor::Direction>(direction), |
157 transaction, &ec); | 213 callbacks, idb_object_store_id_, |
| 214 WebKit::WebIDBTransaction::NormalTask, transaction, &ec); |
158 } | 215 } |
159 | 216 |
160 void RendererWebIDBObjectStoreImpl::count( | 217 void RendererWebIDBObjectStoreImpl::count( |
161 const WebIDBKeyRange& idb_key_range, | 218 const WebIDBKeyRange& idb_key_range, |
162 WebIDBCallbacks* callbacks, | 219 WebIDBCallbacks* callbacks, |
163 const WebIDBTransaction& transaction, | 220 const WebIDBTransaction& transaction, |
164 WebExceptionCode& ec) { | 221 WebExceptionCode& ec) { |
165 IndexedDBDispatcher* dispatcher = | 222 IndexedDBDispatcher* dispatcher = |
166 IndexedDBDispatcher::ThreadSpecificInstance(); | 223 IndexedDBDispatcher::ThreadSpecificInstance(); |
167 dispatcher->RequestIDBObjectStoreCount( | 224 dispatcher->RequestIDBObjectStoreCount( |
168 idb_key_range, callbacks, idb_object_store_id_, | 225 idb_key_range, callbacks, idb_object_store_id_, |
169 transaction, &ec); | 226 transaction, &ec); |
170 } | 227 } |
OLD | NEW |