| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/child/indexed_db/proxy_webidbdatabase_impl.h" | 5 #include "content/child/indexed_db/proxy_webidbdatabase_impl.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "content/child/thread_safe_sender.h" | 9 #include "content/child/thread_safe_sender.h" |
| 10 #include "content/child/indexed_db/indexed_db_dispatcher.h" | 10 #include "content/child/indexed_db/indexed_db_dispatcher.h" |
| 11 #include "content/child/indexed_db/indexed_db_key_builders.h" |
| 11 #include "content/common/indexed_db/indexed_db_messages.h" | 12 #include "content/common/indexed_db/indexed_db_messages.h" |
| 12 #include "third_party/WebKit/public/platform/WebIDBKeyPath.h" | 13 #include "third_party/WebKit/public/platform/WebIDBKeyPath.h" |
| 13 #include "third_party/WebKit/public/platform/WebIDBMetadata.h" | 14 #include "third_party/WebKit/public/platform/WebIDBMetadata.h" |
| 14 #include "third_party/WebKit/public/platform/WebString.h" | 15 #include "third_party/WebKit/public/platform/WebString.h" |
| 15 #include "third_party/WebKit/public/platform/WebVector.h" | 16 #include "third_party/WebKit/public/platform/WebVector.h" |
| 16 #include "webkit/child/worker_task_runner.h" | 17 #include "webkit/child/worker_task_runner.h" |
| 17 | 18 |
| 18 using WebKit::WebIDBCallbacks; | 19 using WebKit::WebIDBCallbacks; |
| 19 using WebKit::WebIDBDatabaseCallbacks; | 20 using WebKit::WebIDBDatabaseCallbacks; |
| 20 using WebKit::WebIDBMetadata; | 21 using WebKit::WebIDBMetadata; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 51 long long transaction_id, | 52 long long transaction_id, |
| 52 long long object_store_id, | 53 long long object_store_id, |
| 53 const WebString& name, | 54 const WebString& name, |
| 54 const WebIDBKeyPath& key_path, | 55 const WebIDBKeyPath& key_path, |
| 55 bool auto_increment) { | 56 bool auto_increment) { |
| 56 IndexedDBHostMsg_DatabaseCreateObjectStore_Params params; | 57 IndexedDBHostMsg_DatabaseCreateObjectStore_Params params; |
| 57 params.ipc_database_id = ipc_database_id_; | 58 params.ipc_database_id = ipc_database_id_; |
| 58 params.transaction_id = transaction_id; | 59 params.transaction_id = transaction_id; |
| 59 params.object_store_id = object_store_id; | 60 params.object_store_id = object_store_id; |
| 60 params.name = name; | 61 params.name = name; |
| 61 params.key_path = IndexedDBKeyPath(key_path); | 62 params.key_path = IndexedDBKeyPathBuilder::Build(key_path); |
| 62 params.auto_increment = auto_increment; | 63 params.auto_increment = auto_increment; |
| 63 | 64 |
| 64 thread_safe_sender_->Send( | 65 thread_safe_sender_->Send( |
| 65 new IndexedDBHostMsg_DatabaseCreateObjectStore(params)); | 66 new IndexedDBHostMsg_DatabaseCreateObjectStore(params)); |
| 66 } | 67 } |
| 67 | 68 |
| 68 void RendererWebIDBDatabaseImpl::deleteObjectStore( | 69 void RendererWebIDBDatabaseImpl::deleteObjectStore( |
| 69 long long transaction_id, | 70 long long transaction_id, |
| 70 long long object_store_id) { | 71 long long object_store_id) { |
| 71 thread_safe_sender_->Send( | 72 thread_safe_sender_->Send( |
| (...skipping 23 matching lines...) Expand all Loading... |
| 95 | 96 |
| 96 void RendererWebIDBDatabaseImpl::get( | 97 void RendererWebIDBDatabaseImpl::get( |
| 97 long long transaction_id, | 98 long long transaction_id, |
| 98 long long object_store_id, | 99 long long object_store_id, |
| 99 long long index_id, | 100 long long index_id, |
| 100 const WebIDBKeyRange& key_range, | 101 const WebIDBKeyRange& key_range, |
| 101 bool key_only, | 102 bool key_only, |
| 102 WebIDBCallbacks* callbacks) { | 103 WebIDBCallbacks* callbacks) { |
| 103 IndexedDBDispatcher* dispatcher = | 104 IndexedDBDispatcher* dispatcher = |
| 104 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); | 105 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); |
| 105 dispatcher->RequestIDBDatabaseGet(ipc_database_id_, | 106 dispatcher->RequestIDBDatabaseGet( |
| 106 transaction_id, | 107 ipc_database_id_, |
| 107 object_store_id, | 108 transaction_id, |
| 108 index_id, | 109 object_store_id, |
| 109 IndexedDBKeyRange(key_range), | 110 index_id, |
| 110 key_only, | 111 IndexedDBKeyRangeBuilder::Build(key_range), |
| 111 callbacks); | 112 key_only, |
| 113 callbacks); |
| 112 } | 114 } |
| 113 | 115 |
| 114 void RendererWebIDBDatabaseImpl::put( | 116 void RendererWebIDBDatabaseImpl::put( |
| 115 long long transaction_id, | 117 long long transaction_id, |
| 116 long long object_store_id, | 118 long long object_store_id, |
| 117 const WebKit::WebData& value, | 119 const WebKit::WebData& value, |
| 118 const WebIDBKey& key, | 120 const WebIDBKey& key, |
| 119 PutMode put_mode, | 121 PutMode put_mode, |
| 120 WebIDBCallbacks* callbacks, | 122 WebIDBCallbacks* callbacks, |
| 121 const WebVector<long long>& web_index_ids, | 123 const WebVector<long long>& web_index_ids, |
| 122 const WebVector<WebIndexKeys>& web_index_keys) { | 124 const WebVector<WebIndexKeys>& web_index_keys) { |
| 123 IndexedDBDispatcher* dispatcher = | 125 IndexedDBDispatcher* dispatcher = |
| 124 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); | 126 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); |
| 125 dispatcher->RequestIDBDatabasePut(ipc_database_id_, | 127 dispatcher->RequestIDBDatabasePut(ipc_database_id_, |
| 126 transaction_id, | 128 transaction_id, |
| 127 object_store_id, | 129 object_store_id, |
| 128 value, | 130 value, |
| 129 IndexedDBKey(key), | 131 IndexedDBKeyBuilder::Build(key), |
| 130 put_mode, | 132 put_mode, |
| 131 callbacks, | 133 callbacks, |
| 132 web_index_ids, | 134 web_index_ids, |
| 133 web_index_keys); | 135 web_index_keys); |
| 134 } | 136 } |
| 135 | 137 |
| 136 void RendererWebIDBDatabaseImpl::setIndexKeys( | 138 void RendererWebIDBDatabaseImpl::setIndexKeys( |
| 137 long long transaction_id, | 139 long long transaction_id, |
| 138 long long object_store_id, | 140 long long object_store_id, |
| 139 const WebIDBKey& primary_key, | 141 const WebIDBKey& primary_key, |
| 140 const WebVector<long long>& index_ids, | 142 const WebVector<long long>& index_ids, |
| 141 const WebVector<WebIndexKeys>& index_keys) { | 143 const WebVector<WebIndexKeys>& index_keys) { |
| 142 IndexedDBHostMsg_DatabaseSetIndexKeys_Params params; | 144 IndexedDBHostMsg_DatabaseSetIndexKeys_Params params; |
| 143 params.ipc_database_id = ipc_database_id_; | 145 params.ipc_database_id = ipc_database_id_; |
| 144 params.transaction_id = transaction_id; | 146 params.transaction_id = transaction_id; |
| 145 params.object_store_id = object_store_id; | 147 params.object_store_id = object_store_id; |
| 146 params.primary_key = IndexedDBKey(primary_key); | 148 params.primary_key = IndexedDBKeyBuilder::Build(primary_key); |
| 147 COMPILE_ASSERT(sizeof(params.index_ids[0]) == | 149 COMPILE_ASSERT(sizeof(params.index_ids[0]) == |
| 148 sizeof(index_ids[0]), Cant_copy); | 150 sizeof(index_ids[0]), Cant_copy); |
| 149 params.index_ids.assign(index_ids.data(), | 151 params.index_ids.assign(index_ids.data(), |
| 150 index_ids.data() + index_ids.size()); | 152 index_ids.data() + index_ids.size()); |
| 151 | 153 |
| 152 params.index_keys.resize(index_keys.size()); | 154 params.index_keys.resize(index_keys.size()); |
| 153 for (size_t i = 0; i < index_keys.size(); ++i) { | 155 for (size_t i = 0; i < index_keys.size(); ++i) { |
| 154 params.index_keys[i].resize(index_keys[i].size()); | 156 params.index_keys[i].resize(index_keys[i].size()); |
| 155 for (size_t j = 0; j < index_keys[i].size(); ++j) { | 157 for (size_t j = 0; j < index_keys[i].size(); ++j) { |
| 156 params.index_keys[i][j] = content::IndexedDBKey(index_keys[i][j]); | 158 params.index_keys[i][j] = IndexedDBKeyBuilder::Build(index_keys[i][j]); |
| 157 } | 159 } |
| 158 } | 160 } |
| 159 thread_safe_sender_->Send(new IndexedDBHostMsg_DatabaseSetIndexKeys(params)); | 161 thread_safe_sender_->Send(new IndexedDBHostMsg_DatabaseSetIndexKeys(params)); |
| 160 } | 162 } |
| 161 | 163 |
| 162 void RendererWebIDBDatabaseImpl::setIndexesReady( | 164 void RendererWebIDBDatabaseImpl::setIndexesReady( |
| 163 long long transaction_id, | 165 long long transaction_id, |
| 164 long long object_store_id, | 166 long long object_store_id, |
| 165 const WebVector<long long>& web_index_ids) { | 167 const WebVector<long long>& web_index_ids) { |
| 166 std::vector<int64> index_ids(web_index_ids.data(), | 168 std::vector<int64> index_ids(web_index_ids.data(), |
| 167 web_index_ids.data() + web_index_ids.size()); | 169 web_index_ids.data() + web_index_ids.size()); |
| 168 thread_safe_sender_->Send(new IndexedDBHostMsg_DatabaseSetIndexesReady( | 170 thread_safe_sender_->Send(new IndexedDBHostMsg_DatabaseSetIndexesReady( |
| 169 ipc_database_id_, transaction_id, object_store_id, index_ids)); | 171 ipc_database_id_, transaction_id, object_store_id, index_ids)); |
| 170 } | 172 } |
| 171 | 173 |
| 172 void RendererWebIDBDatabaseImpl::openCursor( | 174 void RendererWebIDBDatabaseImpl::openCursor( |
| 173 long long transaction_id, | 175 long long transaction_id, |
| 174 long long object_store_id, | 176 long long object_store_id, |
| 175 long long index_id, | 177 long long index_id, |
| 176 const WebIDBKeyRange& key_range, | 178 const WebIDBKeyRange& key_range, |
| 177 unsigned short direction, | 179 unsigned short direction, |
| 178 bool key_only, | 180 bool key_only, |
| 179 TaskType task_type, | 181 TaskType task_type, |
| 180 WebIDBCallbacks* callbacks) { | 182 WebIDBCallbacks* callbacks) { |
| 181 IndexedDBDispatcher* dispatcher = | 183 IndexedDBDispatcher* dispatcher = |
| 182 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); | 184 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); |
| 183 dispatcher->RequestIDBDatabaseOpenCursor(ipc_database_id_, | 185 dispatcher->RequestIDBDatabaseOpenCursor( |
| 184 transaction_id, | 186 ipc_database_id_, |
| 185 object_store_id, | 187 transaction_id, |
| 186 index_id, | 188 object_store_id, |
| 187 IndexedDBKeyRange(key_range), | 189 index_id, |
| 188 direction, | 190 IndexedDBKeyRangeBuilder::Build(key_range), |
| 189 key_only, | 191 direction, |
| 190 task_type, | 192 key_only, |
| 191 callbacks); | 193 task_type, |
| 194 callbacks); |
| 192 } | 195 } |
| 193 | 196 |
| 194 void RendererWebIDBDatabaseImpl::count( | 197 void RendererWebIDBDatabaseImpl::count( |
| 195 long long transaction_id, | 198 long long transaction_id, |
| 196 long long object_store_id, | 199 long long object_store_id, |
| 197 long long index_id, | 200 long long index_id, |
| 198 const WebIDBKeyRange& key_range, | 201 const WebIDBKeyRange& key_range, |
| 199 WebIDBCallbacks* callbacks) { | 202 WebIDBCallbacks* callbacks) { |
| 200 IndexedDBDispatcher* dispatcher = | 203 IndexedDBDispatcher* dispatcher = |
| 201 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); | 204 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); |
| 202 dispatcher->RequestIDBDatabaseCount(ipc_database_id_, | 205 dispatcher->RequestIDBDatabaseCount( |
| 203 transaction_id, | 206 ipc_database_id_, |
| 204 object_store_id, | 207 transaction_id, |
| 205 index_id, | 208 object_store_id, |
| 206 IndexedDBKeyRange(key_range), | 209 index_id, |
| 207 callbacks); | 210 IndexedDBKeyRangeBuilder::Build(key_range), |
| 211 callbacks); |
| 208 } | 212 } |
| 209 | 213 |
| 210 void RendererWebIDBDatabaseImpl::deleteRange( | 214 void RendererWebIDBDatabaseImpl::deleteRange( |
| 211 long long transaction_id, | 215 long long transaction_id, |
| 212 long long object_store_id, | 216 long long object_store_id, |
| 213 const WebIDBKeyRange& key_range, | 217 const WebIDBKeyRange& key_range, |
| 214 WebIDBCallbacks* callbacks) { | 218 WebIDBCallbacks* callbacks) { |
| 215 IndexedDBDispatcher* dispatcher = | 219 IndexedDBDispatcher* dispatcher = |
| 216 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); | 220 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); |
| 217 dispatcher->RequestIDBDatabaseDeleteRange(ipc_database_id_, | 221 dispatcher->RequestIDBDatabaseDeleteRange( |
| 218 transaction_id, | 222 ipc_database_id_, |
| 219 object_store_id, | 223 transaction_id, |
| 220 IndexedDBKeyRange(key_range), | 224 object_store_id, |
| 221 callbacks); | 225 IndexedDBKeyRangeBuilder::Build(key_range), |
| 226 callbacks); |
| 222 } | 227 } |
| 223 | 228 |
| 224 void RendererWebIDBDatabaseImpl::clear( | 229 void RendererWebIDBDatabaseImpl::clear( |
| 225 long long transaction_id, | 230 long long transaction_id, |
| 226 long long object_store_id, | 231 long long object_store_id, |
| 227 WebIDBCallbacks* callbacks) { | 232 WebIDBCallbacks* callbacks) { |
| 228 IndexedDBDispatcher* dispatcher = | 233 IndexedDBDispatcher* dispatcher = |
| 229 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); | 234 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); |
| 230 dispatcher->RequestIDBDatabaseClear( | 235 dispatcher->RequestIDBDatabaseClear( |
| 231 ipc_database_id_, transaction_id, object_store_id, callbacks); | 236 ipc_database_id_, transaction_id, object_store_id, callbacks); |
| 232 } | 237 } |
| 233 | 238 |
| 234 void RendererWebIDBDatabaseImpl::createIndex( | 239 void RendererWebIDBDatabaseImpl::createIndex( |
| 235 long long transaction_id, | 240 long long transaction_id, |
| 236 long long object_store_id, | 241 long long object_store_id, |
| 237 long long index_id, | 242 long long index_id, |
| 238 const WebString& name, | 243 const WebString& name, |
| 239 const WebIDBKeyPath& key_path, | 244 const WebIDBKeyPath& key_path, |
| 240 bool unique, | 245 bool unique, |
| 241 bool multi_entry) | 246 bool multi_entry) |
| 242 { | 247 { |
| 243 IndexedDBHostMsg_DatabaseCreateIndex_Params params; | 248 IndexedDBHostMsg_DatabaseCreateIndex_Params params; |
| 244 params.ipc_database_id = ipc_database_id_; | 249 params.ipc_database_id = ipc_database_id_; |
| 245 params.transaction_id = transaction_id; | 250 params.transaction_id = transaction_id; |
| 246 params.object_store_id = object_store_id; | 251 params.object_store_id = object_store_id; |
| 247 params.index_id = index_id; | 252 params.index_id = index_id; |
| 248 params.name = name; | 253 params.name = name; |
| 249 params.key_path = IndexedDBKeyPath(key_path); | 254 params.key_path = IndexedDBKeyPathBuilder::Build(key_path); |
| 250 params.unique = unique; | 255 params.unique = unique; |
| 251 params.multi_entry = multi_entry; | 256 params.multi_entry = multi_entry; |
| 252 | 257 |
| 253 thread_safe_sender_->Send(new IndexedDBHostMsg_DatabaseCreateIndex(params)); | 258 thread_safe_sender_->Send(new IndexedDBHostMsg_DatabaseCreateIndex(params)); |
| 254 } | 259 } |
| 255 | 260 |
| 256 void RendererWebIDBDatabaseImpl::deleteIndex( | 261 void RendererWebIDBDatabaseImpl::deleteIndex( |
| 257 long long transaction_id, | 262 long long transaction_id, |
| 258 long long object_store_id, | 263 long long object_store_id, |
| 259 long long index_id) | 264 long long index_id) |
| 260 { | 265 { |
| 261 thread_safe_sender_->Send( | 266 thread_safe_sender_->Send( |
| 262 new IndexedDBHostMsg_DatabaseDeleteIndex( | 267 new IndexedDBHostMsg_DatabaseDeleteIndex( |
| 263 ipc_database_id_, | 268 ipc_database_id_, |
| 264 transaction_id, | 269 transaction_id, |
| 265 object_store_id, index_id)); | 270 object_store_id, index_id)); |
| 266 } | 271 } |
| 267 | 272 |
| 268 void RendererWebIDBDatabaseImpl::abort(long long transaction_id) { | 273 void RendererWebIDBDatabaseImpl::abort(long long transaction_id) { |
| 269 thread_safe_sender_->Send(new IndexedDBHostMsg_DatabaseAbort( | 274 thread_safe_sender_->Send(new IndexedDBHostMsg_DatabaseAbort( |
| 270 ipc_database_id_, transaction_id)); | 275 ipc_database_id_, transaction_id)); |
| 271 } | 276 } |
| 272 | 277 |
| 273 void RendererWebIDBDatabaseImpl::commit(long long transaction_id) { | 278 void RendererWebIDBDatabaseImpl::commit(long long transaction_id) { |
| 274 thread_safe_sender_->Send(new IndexedDBHostMsg_DatabaseCommit( | 279 thread_safe_sender_->Send(new IndexedDBHostMsg_DatabaseCommit( |
| 275 ipc_database_id_, transaction_id)); | 280 ipc_database_id_, transaction_id)); |
| 276 } | 281 } |
| 277 | 282 |
| 278 } // namespace content | 283 } // namespace content |
| OLD | NEW |