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/indexed_db_dispatcher.h" | 5 #include "content/common/indexed_db/indexed_db_dispatcher.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/threading/thread_local.h" | 8 #include "base/threading/thread_local.h" |
9 #include "content/common/child_thread.h" | 9 #include "content/common/child_thread.h" |
10 #include "content/common/indexed_db/indexed_db_messages.h" | 10 #include "content/common/indexed_db/indexed_db_messages.h" |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 | 298 |
299 void IndexedDBDispatcher::RequestIDBDatabaseClose(int32 ipc_database_id) { | 299 void IndexedDBDispatcher::RequestIDBDatabaseClose(int32 ipc_database_id) { |
300 ResetCursorPrefetchCaches(); | 300 ResetCursorPrefetchCaches(); |
301 Send(new IndexedDBHostMsg_DatabaseClose(ipc_database_id)); | 301 Send(new IndexedDBHostMsg_DatabaseClose(ipc_database_id)); |
302 // There won't be pending database callbacks if the transaction was aborted in | 302 // There won't be pending database callbacks if the transaction was aborted in |
303 // the initial upgradeneeded event handler. | 303 // the initial upgradeneeded event handler. |
304 if (pending_database_callbacks_.Lookup(ipc_database_id)) | 304 if (pending_database_callbacks_.Lookup(ipc_database_id)) |
305 pending_database_callbacks_.Remove(ipc_database_id); | 305 pending_database_callbacks_.Remove(ipc_database_id); |
306 } | 306 } |
307 | 307 |
| 308 void IndexedDBDispatcher::RequestIDBDatabaseGet( |
| 309 int32 ipc_database_id, |
| 310 int64 transaction_id, |
| 311 int64 object_store_id, |
| 312 int64 index_id, |
| 313 const IndexedDBKeyRange& key_range, |
| 314 bool key_only, |
| 315 WebIDBCallbacks* callbacks) { |
| 316 ResetCursorPrefetchCaches(); |
| 317 IndexedDBHostMsg_DatabaseGet_Params params; |
| 318 init_params(params, callbacks); |
| 319 params.ipc_database_id = ipc_database_id; |
| 320 params.transaction_id = transaction_id; |
| 321 params.object_store_id = object_store_id; |
| 322 params.index_id = index_id; |
| 323 params.key_range = key_range; |
| 324 params.key_only = key_only; |
| 325 Send(new IndexedDBHostMsg_DatabaseGet(params)); |
| 326 } |
| 327 |
| 328 |
| 329 void IndexedDBDispatcher::RequestIDBDatabasePut( |
| 330 int32 ipc_database_id, |
| 331 int64 transaction_id, |
| 332 int64 object_store_id, |
| 333 WebKit::WebVector<unsigned char>* value, |
| 334 const IndexedDBKey& key, |
| 335 WebKit::WebIDBDatabase::PutMode put_mode, |
| 336 WebKit::WebIDBCallbacks* callbacks, |
| 337 const WebKit::WebVector<long long>& index_ids, |
| 338 const WebKit::WebVector<WebKit::WebVector< |
| 339 WebKit::WebIDBKey> >& index_keys) { |
| 340 ResetCursorPrefetchCaches(); |
| 341 IndexedDBHostMsg_DatabasePut_Params params; |
| 342 init_params(params, callbacks); |
| 343 params.ipc_database_id = ipc_database_id; |
| 344 params.transaction_id = transaction_id; |
| 345 params.object_store_id = object_store_id; |
| 346 |
| 347 COMPILE_ASSERT(sizeof(params.value[0]) == sizeof((*value)[0]), Cant_copy); |
| 348 params.value.assign(value->data(), value->data() + value->size()); |
| 349 params.key = key; |
| 350 params.put_mode = put_mode; |
| 351 |
| 352 COMPILE_ASSERT(sizeof(params.index_ids[0]) == |
| 353 sizeof(index_ids[0]), Cant_copy); |
| 354 params.index_ids.assign(index_ids.data(), |
| 355 index_ids.data() + index_ids.size()); |
| 356 |
| 357 params.index_keys.resize(index_keys.size()); |
| 358 for (size_t i = 0; i < index_keys.size(); ++i) { |
| 359 params.index_keys[i].resize(index_keys[i].size()); |
| 360 for (size_t j = 0; j < index_keys[i].size(); ++j) { |
| 361 params.index_keys[i][j] = IndexedDBKey(index_keys[i][j]); |
| 362 } |
| 363 } |
| 364 Send(new IndexedDBHostMsg_DatabasePut(params)); |
| 365 } |
| 366 |
| 367 void IndexedDBDispatcher::RequestIDBDatabaseOpenCursor( |
| 368 int32 ipc_database_id, |
| 369 int64 transaction_id, |
| 370 int64 object_store_id, |
| 371 int64 index_id, |
| 372 const IndexedDBKeyRange& key_range, |
| 373 unsigned short direction, |
| 374 bool key_only, |
| 375 WebKit::WebIDBDatabase::TaskType task_type, |
| 376 WebIDBCallbacks* callbacks) { |
| 377 ResetCursorPrefetchCaches(); |
| 378 IndexedDBHostMsg_DatabaseOpenCursor_Params params; |
| 379 init_params(params, callbacks); |
| 380 params.ipc_database_id = ipc_database_id; |
| 381 params.transaction_id = transaction_id; |
| 382 params.object_store_id = object_store_id; |
| 383 params.index_id = index_id; |
| 384 params.key_range = IndexedDBKeyRange(key_range); |
| 385 params.direction = direction; |
| 386 params.key_only = key_only; |
| 387 params.task_type = task_type; |
| 388 Send(new IndexedDBHostMsg_DatabaseOpenCursor(params)); |
| 389 } |
| 390 |
| 391 void IndexedDBDispatcher::RequestIDBDatabaseCount( |
| 392 int32 ipc_database_id, |
| 393 int64 transaction_id, |
| 394 int64 object_store_id, |
| 395 int64 index_id, |
| 396 const IndexedDBKeyRange& key_range, |
| 397 WebKit::WebIDBCallbacks* callbacks) { |
| 398 ResetCursorPrefetchCaches(); |
| 399 IndexedDBHostMsg_DatabaseCount_Params params; |
| 400 init_params(params, callbacks); |
| 401 params.ipc_database_id = ipc_database_id; |
| 402 params.transaction_id = transaction_id; |
| 403 params.object_store_id = object_store_id; |
| 404 params.index_id = index_id; |
| 405 params.key_range = IndexedDBKeyRange(key_range); |
| 406 Send(new IndexedDBHostMsg_DatabaseCount(params)); |
| 407 } |
| 408 |
| 409 void IndexedDBDispatcher::RequestIDBDatabaseDeleteRange( |
| 410 int32 ipc_database_id, |
| 411 int64 transaction_id, |
| 412 int64 object_store_id, |
| 413 const IndexedDBKeyRange& key_range, |
| 414 WebKit::WebIDBCallbacks* callbacks) |
| 415 { |
| 416 ResetCursorPrefetchCaches(); |
| 417 IndexedDBHostMsg_DatabaseDeleteRange_Params params; |
| 418 init_params(params, callbacks); |
| 419 params.ipc_database_id = ipc_database_id; |
| 420 params.transaction_id = transaction_id; |
| 421 params.object_store_id = object_store_id; |
| 422 params.key_range = key_range; |
| 423 Send(new IndexedDBHostMsg_DatabaseDeleteRange(params)); |
| 424 } |
| 425 |
| 426 void IndexedDBDispatcher::RequestIDBDatabaseClear( |
| 427 int32 ipc_database_id, |
| 428 int64 transaction_id, |
| 429 int64 object_store_id, |
| 430 WebKit::WebIDBCallbacks* callbacks_ptr) { |
| 431 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 432 int32 ipc_response_id = pending_callbacks_.Add(callbacks.release()); |
| 433 Send(new IndexedDBHostMsg_DatabaseClear( |
| 434 CurrentWorkerId(), ipc_response_id, ipc_database_id, |
| 435 transaction_id, object_store_id)); |
| 436 } |
| 437 |
308 void IndexedDBDispatcher::RequestIDBIndexOpenObjectCursor( | 438 void IndexedDBDispatcher::RequestIDBIndexOpenObjectCursor( |
309 const WebIDBKeyRange& idb_key_range, | 439 const WebIDBKeyRange& idb_key_range, |
310 unsigned short direction, | 440 unsigned short direction, |
311 WebIDBCallbacks* callbacks_ptr, | 441 WebIDBCallbacks* callbacks_ptr, |
312 int32 ipc_index_id, | 442 int32 ipc_index_id, |
313 const WebIDBTransaction& transaction, | 443 const WebIDBTransaction& transaction, |
314 WebExceptionCode* ec) { | 444 WebExceptionCode* ec) { |
315 ResetCursorPrefetchCaches(); | 445 ResetCursorPrefetchCaches(); |
316 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 446 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
317 IndexedDBHostMsg_IndexOpenCursor_Params params; | 447 IndexedDBHostMsg_IndexOpenCursor_Params params; |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 int32 ipc_exception_cursor_id) { | 912 int32 ipc_exception_cursor_id) { |
783 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; | 913 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; |
784 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { | 914 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { |
785 if (i->first == ipc_exception_cursor_id) | 915 if (i->first == ipc_exception_cursor_id) |
786 continue; | 916 continue; |
787 i->second->ResetPrefetchCache(); | 917 i->second->ResetPrefetchCache(); |
788 } | 918 } |
789 } | 919 } |
790 | 920 |
791 } // namespace content | 921 } // namespace content |
OLD | NEW |