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" |
11 #include "content/common/indexed_db/proxy_webidbcursor_impl.h" | 11 #include "content/common/indexed_db/proxy_webidbcursor_impl.h" |
12 #include "content/common/indexed_db/proxy_webidbdatabase_impl.h" | 12 #include "content/common/indexed_db/proxy_webidbdatabase_impl.h" |
13 #include "ipc/ipc_channel.h" | 13 #include "ipc/ipc_channel.h" |
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseCallbac
ks.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseCallbac
ks.h" |
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseError.h
" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseError.h
" |
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseExcepti
on.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseExcepti
on.h" |
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyRange.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyRange.h" |
19 | 19 |
20 using WebKit::WebDOMStringList; | 20 using WebKit::WebDOMStringList; |
| 21 using WebKit::WebData; |
21 using WebKit::WebExceptionCode; | 22 using WebKit::WebExceptionCode; |
22 using WebKit::WebFrame; | 23 using WebKit::WebFrame; |
23 using WebKit::WebIDBCallbacks; | 24 using WebKit::WebIDBCallbacks; |
24 using WebKit::WebIDBDatabase; | 25 using WebKit::WebIDBDatabase; |
25 using WebKit::WebIDBDatabaseCallbacks; | 26 using WebKit::WebIDBDatabaseCallbacks; |
26 using WebKit::WebIDBDatabaseError; | 27 using WebKit::WebIDBDatabaseError; |
27 using WebKit::WebIDBKey; | 28 using WebKit::WebIDBKey; |
28 using WebKit::WebIDBKeyRange; | 29 using WebKit::WebIDBKeyRange; |
29 using WebKit::WebIDBMetadata; | 30 using WebKit::WebIDBMetadata; |
30 using WebKit::WebSerializedScriptValue; | 31 using WebKit::WebSerializedScriptValue; |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 params.ipc_database_id = ipc_database_id; | 381 params.ipc_database_id = ipc_database_id; |
381 params.transaction_id = transaction_id; | 382 params.transaction_id = transaction_id; |
382 params.object_store_id = object_store_id; | 383 params.object_store_id = object_store_id; |
383 params.index_id = index_id; | 384 params.index_id = index_id; |
384 params.key_range = key_range; | 385 params.key_range = key_range; |
385 params.key_only = key_only; | 386 params.key_only = key_only; |
386 Send(new IndexedDBHostMsg_DatabaseGet(params)); | 387 Send(new IndexedDBHostMsg_DatabaseGet(params)); |
387 } | 388 } |
388 | 389 |
389 | 390 |
390 void IndexedDBDispatcher::RequestIDBDatabasePut( | 391 void IndexedDBDispatcher::RequestIDBDatabasePutOld( |
391 int32 ipc_database_id, | 392 int32 ipc_database_id, |
392 int64 transaction_id, | 393 int64 transaction_id, |
393 int64 object_store_id, | 394 int64 object_store_id, |
394 WebKit::WebVector<unsigned char>* value, | 395 WebKit::WebVector<unsigned char>* value, |
395 const IndexedDBKey& key, | 396 const IndexedDBKey& key, |
396 WebKit::WebIDBDatabase::PutMode put_mode, | 397 WebKit::WebIDBDatabase::PutMode put_mode, |
397 WebKit::WebIDBCallbacks* callbacks, | 398 WebKit::WebIDBCallbacks* callbacks, |
398 const WebKit::WebVector<long long>& index_ids, | 399 const WebKit::WebVector<long long>& index_ids, |
399 const WebKit::WebVector<WebKit::WebVector< | 400 const WebKit::WebVector<WebKit::WebVector< |
400 WebKit::WebIDBKey> >& index_keys) { | 401 WebKit::WebIDBKey> >& index_keys) { |
401 ResetCursorPrefetchCaches(); | 402 ResetCursorPrefetchCaches(); |
402 IndexedDBHostMsg_DatabasePut_Params params; | 403 IndexedDBHostMsg_DatabasePutOld_Params params; |
403 init_params(params, callbacks); | 404 init_params(params, callbacks); |
404 params.ipc_database_id = ipc_database_id; | 405 params.ipc_database_id = ipc_database_id; |
405 params.transaction_id = transaction_id; | 406 params.transaction_id = transaction_id; |
406 params.object_store_id = object_store_id; | 407 params.object_store_id = object_store_id; |
407 | 408 |
408 COMPILE_ASSERT(sizeof(params.value[0]) == sizeof((*value)[0]), Cant_copy); | 409 COMPILE_ASSERT(sizeof(params.value[0]) == sizeof((*value)[0]), Cant_copy); |
409 params.value.assign(value->data(), value->data() + value->size()); | 410 params.value.assign(value->data(), value->data() + value->size()); |
410 params.key = key; | 411 params.key = key; |
411 params.put_mode = put_mode; | 412 params.put_mode = put_mode; |
412 | 413 |
413 COMPILE_ASSERT(sizeof(params.index_ids[0]) == | 414 COMPILE_ASSERT(sizeof(params.index_ids[0]) == |
414 sizeof(index_ids[0]), Cant_copy); | 415 sizeof(index_ids[0]), Cant_copy); |
415 params.index_ids.assign(index_ids.data(), | 416 params.index_ids.assign(index_ids.data(), |
416 index_ids.data() + index_ids.size()); | 417 index_ids.data() + index_ids.size()); |
417 | 418 |
418 params.index_keys.resize(index_keys.size()); | 419 params.index_keys.resize(index_keys.size()); |
419 for (size_t i = 0; i < index_keys.size(); ++i) { | 420 for (size_t i = 0; i < index_keys.size(); ++i) { |
420 params.index_keys[i].resize(index_keys[i].size()); | 421 params.index_keys[i].resize(index_keys[i].size()); |
421 for (size_t j = 0; j < index_keys[i].size(); ++j) { | 422 for (size_t j = 0; j < index_keys[i].size(); ++j) { |
422 params.index_keys[i][j] = IndexedDBKey(index_keys[i][j]); | 423 params.index_keys[i][j] = IndexedDBKey(index_keys[i][j]); |
423 } | 424 } |
424 } | 425 } |
| 426 Send(new IndexedDBHostMsg_DatabasePutOld(params)); |
| 427 } |
| 428 |
| 429 void IndexedDBDispatcher::RequestIDBDatabasePut( |
| 430 int32 ipc_database_id, |
| 431 int64 transaction_id, |
| 432 int64 object_store_id, |
| 433 const WebData& value, |
| 434 const IndexedDBKey& key, |
| 435 WebIDBDatabase::PutMode put_mode, |
| 436 WebIDBCallbacks* callbacks, |
| 437 const WebVector<long long>& index_ids, |
| 438 const WebVector<WebKit::WebVector< |
| 439 WebIDBKey> >& index_keys) { |
| 440 ResetCursorPrefetchCaches(); |
| 441 IndexedDBHostMsg_DatabasePut_Params params; |
| 442 init_params(params, callbacks); |
| 443 params.ipc_database_id = ipc_database_id; |
| 444 params.transaction_id = transaction_id; |
| 445 params.object_store_id = object_store_id; |
| 446 |
| 447 params.value.assign(value.data(), value.data() + value.size()); |
| 448 params.key = key; |
| 449 params.put_mode = put_mode; |
| 450 |
| 451 COMPILE_ASSERT(sizeof(params.index_ids[0]) == |
| 452 sizeof(index_ids[0]), Cant_copy); |
| 453 params.index_ids.assign(index_ids.data(), |
| 454 index_ids.data() + index_ids.size()); |
| 455 |
| 456 params.index_keys.resize(index_keys.size()); |
| 457 for (size_t i = 0; i < index_keys.size(); ++i) { |
| 458 params.index_keys[i].resize(index_keys[i].size()); |
| 459 for (size_t j = 0; j < index_keys[i].size(); ++j) { |
| 460 params.index_keys[i][j] = IndexedDBKey(index_keys[i][j]); |
| 461 } |
| 462 } |
425 Send(new IndexedDBHostMsg_DatabasePut(params)); | 463 Send(new IndexedDBHostMsg_DatabasePut(params)); |
426 } | 464 } |
427 | 465 |
428 void IndexedDBDispatcher::RequestIDBDatabaseOpenCursor( | 466 void IndexedDBDispatcher::RequestIDBDatabaseOpenCursor( |
429 int32 ipc_database_id, | 467 int32 ipc_database_id, |
430 int64 transaction_id, | 468 int64 transaction_id, |
431 int64 object_store_id, | 469 int64 object_store_id, |
432 int64 index_id, | 470 int64 index_id, |
433 const IndexedDBKeyRange& key_range, | 471 const IndexedDBKeyRange& key_range, |
434 unsigned short direction, | 472 unsigned short direction, |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 int32 ipc_exception_cursor_id) { | 797 int32 ipc_exception_cursor_id) { |
760 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; | 798 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; |
761 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { | 799 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { |
762 if (i->first == ipc_exception_cursor_id) | 800 if (i->first == ipc_exception_cursor_id) |
763 continue; | 801 continue; |
764 i->second->ResetPrefetchCache(); | 802 i->second->ResetPrefetchCache(); |
765 } | 803 } |
766 } | 804 } |
767 | 805 |
768 } // namespace content | 806 } // namespace content |
OLD | NEW |