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/browser/indexed_db/indexed_db_dispatcher_host.h" | 5 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 return transaction_id | (static_cast<uint64>(pid) << 32); | 154 return transaction_id | (static_cast<uint64>(pid) << 32); |
155 } | 155 } |
156 | 156 |
157 int64 IndexedDBDispatcherHost::RendererTransactionId( | 157 int64 IndexedDBDispatcherHost::RendererTransactionId( |
158 int64 host_transaction_id) { | 158 int64 host_transaction_id) { |
159 DCHECK(host_transaction_id >> 32 == base::GetProcId(peer_handle())) | 159 DCHECK(host_transaction_id >> 32 == base::GetProcId(peer_handle())) |
160 << "Invalid renderer target for transaction id"; | 160 << "Invalid renderer target for transaction id"; |
161 return host_transaction_id & 0xffffffff; | 161 return host_transaction_id & 0xffffffff; |
162 } | 162 } |
163 | 163 |
164 IndexedDBCursor* IndexedDBDispatcherHost::GetCursorFromId( | 164 IndexedDBCursor* IndexedDBDispatcherHost::GetCursorFromId(int32 ipc_cursor_id) { |
165 int32 ipc_cursor_id) { | |
166 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 165 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
167 return cursor_dispatcher_host_->map_.Lookup(ipc_cursor_id); | 166 return cursor_dispatcher_host_->map_.Lookup(ipc_cursor_id); |
168 } | 167 } |
169 | 168 |
170 ::IndexedDBDatabaseMetadata IndexedDBDispatcherHost::ConvertMetadata( | 169 ::IndexedDBDatabaseMetadata IndexedDBDispatcherHost::ConvertMetadata( |
171 const content::IndexedDBDatabaseMetadata& web_metadata) { | 170 const content::IndexedDBDatabaseMetadata& web_metadata) { |
172 ::IndexedDBDatabaseMetadata metadata; | 171 ::IndexedDBDatabaseMetadata metadata; |
173 metadata.id = web_metadata.id; | 172 metadata.id = web_metadata.id; |
174 metadata.name = web_metadata.name; | 173 metadata.name = web_metadata.name; |
175 metadata.version = web_metadata.version; | 174 metadata.version = web_metadata.version; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 } | 207 } |
209 return metadata; | 208 return metadata; |
210 } | 209 } |
211 | 210 |
212 void IndexedDBDispatcherHost::OnIDBFactoryGetDatabaseNames( | 211 void IndexedDBDispatcherHost::OnIDBFactoryGetDatabaseNames( |
213 const IndexedDBHostMsg_FactoryGetDatabaseNames_Params& params) { | 212 const IndexedDBHostMsg_FactoryGetDatabaseNames_Params& params) { |
214 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 213 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
215 base::FilePath indexed_db_path = indexed_db_context_->data_path(); | 214 base::FilePath indexed_db_path = indexed_db_context_->data_path(); |
216 | 215 |
217 Context()->GetIDBFactory()->GetDatabaseNames( | 216 Context()->GetIDBFactory()->GetDatabaseNames( |
218 IndexedDBCallbacksWrapper::Create( | 217 IndexedDBCallbacks::Create( |
219 new IndexedDBCallbacks<std::vector<string16> >( | 218 this, params.ipc_thread_id, params.ipc_callbacks_id), |
220 this, params.ipc_thread_id, params.ipc_callbacks_id)), | |
221 base::UTF8ToUTF16(params.database_identifier), | 219 base::UTF8ToUTF16(params.database_identifier), |
222 indexed_db_path); | 220 indexed_db_path); |
223 } | 221 } |
224 | 222 |
225 void IndexedDBDispatcherHost::OnIDBFactoryOpen( | 223 void IndexedDBDispatcherHost::OnIDBFactoryOpen( |
226 const IndexedDBHostMsg_FactoryOpen_Params& params) { | 224 const IndexedDBHostMsg_FactoryOpen_Params& params) { |
227 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 225 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
228 base::FilePath indexed_db_path = indexed_db_context_->data_path(); | 226 base::FilePath indexed_db_path = indexed_db_context_->data_path(); |
229 | 227 |
230 GURL origin_url = | 228 GURL origin_url = |
231 webkit_database::GetOriginFromIdentifier(params.database_identifier); | 229 webkit_database::GetOriginFromIdentifier(params.database_identifier); |
232 | 230 |
233 int64 host_transaction_id = HostTransactionId(params.transaction_id); | 231 int64 host_transaction_id = HostTransactionId(params.transaction_id); |
234 | 232 |
235 // TODO(dgrogan): Don't let a non-existing database be opened (and therefore | 233 // TODO(dgrogan): Don't let a non-existing database be opened (and therefore |
236 // created) if this origin is already over quota. | 234 // created) if this origin is already over quota. |
237 scoped_refptr<IndexedDBCallbacksWrapper> callbacks_proxy = | 235 scoped_refptr<IndexedDBCallbacks> callbacks = |
238 IndexedDBCallbacksWrapper::Create( | 236 IndexedDBCallbacks::Create(this, |
239 new IndexedDBCallbacksDatabase(this, | 237 params.ipc_thread_id, |
240 params.ipc_thread_id, | 238 params.ipc_callbacks_id, |
241 params.ipc_callbacks_id, | 239 params.ipc_database_callbacks_id, |
242 params.ipc_database_callbacks_id, | 240 host_transaction_id, |
243 host_transaction_id, | 241 origin_url); |
244 origin_url)); | 242 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks = |
245 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks_proxy = | |
246 IndexedDBDatabaseCallbacks::Create( | 243 IndexedDBDatabaseCallbacks::Create( |
247 this, params.ipc_thread_id, params.ipc_database_callbacks_id); | 244 this, params.ipc_thread_id, params.ipc_database_callbacks_id); |
248 callbacks_proxy->SetDatabaseCallbacks(database_callbacks_proxy); | 245 callbacks->SetDatabaseCallbacks(database_callbacks); |
249 Context()->GetIDBFactory()-> | 246 Context()->GetIDBFactory()-> |
250 Open(params.name, | 247 Open(params.name, |
251 params.version, | 248 params.version, |
252 host_transaction_id, | 249 host_transaction_id, |
253 callbacks_proxy, | 250 callbacks, |
254 database_callbacks_proxy, | 251 database_callbacks, |
255 base::UTF8ToUTF16(params.database_identifier), | 252 base::UTF8ToUTF16(params.database_identifier), |
256 indexed_db_path); | 253 indexed_db_path); |
257 } | 254 } |
258 | 255 |
259 void IndexedDBDispatcherHost::OnIDBFactoryDeleteDatabase( | 256 void IndexedDBDispatcherHost::OnIDBFactoryDeleteDatabase( |
260 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& params) { | 257 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& params) { |
261 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 258 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
262 base::FilePath indexed_db_path = indexed_db_context_->data_path(); | 259 base::FilePath indexed_db_path = indexed_db_context_->data_path(); |
263 Context()->GetIDBFactory()->DeleteDatabase( | 260 Context()->GetIDBFactory()->DeleteDatabase( |
264 params.name, | 261 params.name, |
265 IndexedDBCallbacksWrapper::Create( | 262 IndexedDBCallbacks::Create( |
266 new IndexedDBCallbacks<std::vector<char> >( | 263 this, params.ipc_thread_id, params.ipc_callbacks_id), |
267 this, params.ipc_thread_id, params.ipc_callbacks_id)), | |
268 base::UTF8ToUTF16(params.database_identifier), | 264 base::UTF8ToUTF16(params.database_identifier), |
269 indexed_db_path); | 265 indexed_db_path); |
270 } | 266 } |
271 | 267 |
272 void IndexedDBDispatcherHost::FinishTransaction(int64 host_transaction_id, | 268 void IndexedDBDispatcherHost::FinishTransaction(int64 host_transaction_id, |
273 bool committed) { | 269 bool committed) { |
274 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 270 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
275 TransactionIDToURLMap& transaction_url_map = | 271 TransactionIDToURLMap& transaction_url_map = |
276 database_dispatcher_host_->transaction_url_map_; | 272 database_dispatcher_host_->transaction_url_map_; |
277 TransactionIDToSizeMap& transaction_size_map = | 273 TransactionIDToSizeMap& transaction_size_map = |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 if (!return_object) { | 318 if (!return_object) { |
323 NOTREACHED() << "Uh oh, couldn't find object with id " | 319 NOTREACHED() << "Uh oh, couldn't find object with id " |
324 << ipc_return_object_id; | 320 << ipc_return_object_id; |
325 RecordAction(UserMetricsAction("BadMessageTerminate_IDBMF")); | 321 RecordAction(UserMetricsAction("BadMessageTerminate_IDBMF")); |
326 BadMessageReceived(); | 322 BadMessageReceived(); |
327 } | 323 } |
328 return return_object; | 324 return return_object; |
329 } | 325 } |
330 | 326 |
331 template <typename MapType> | 327 template <typename MapType> |
332 void IndexedDBDispatcherHost::DestroyObject( | 328 void IndexedDBDispatcherHost::DestroyObject(MapType* map, int32 ipc_object_id) { |
333 MapType* map, | |
334 int32 ipc_object_id) { | |
335 GetOrTerminateProcess(map, ipc_object_id); | 329 GetOrTerminateProcess(map, ipc_object_id); |
336 map->Remove(ipc_object_id); | 330 map->Remove(ipc_object_id); |
337 } | 331 } |
338 | 332 |
339 ////////////////////////////////////////////////////////////////////// | 333 ////////////////////////////////////////////////////////////////////// |
340 // IndexedDBDispatcherHost::DatabaseDispatcherHost | 334 // IndexedDBDispatcherHost::DatabaseDispatcherHost |
341 // | 335 // |
342 | 336 |
343 IndexedDBDispatcherHost::DatabaseDispatcherHost::DatabaseDispatcherHost( | 337 IndexedDBDispatcherHost::DatabaseDispatcherHost::DatabaseDispatcherHost( |
344 IndexedDBDispatcherHost* parent) | 338 IndexedDBDispatcherHost* parent) |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 DCHECK( | 460 DCHECK( |
467 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 461 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
468 WebIDBDatabaseImpl* database = | 462 WebIDBDatabaseImpl* database = |
469 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); | 463 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); |
470 if (!database) | 464 if (!database) |
471 return; | 465 return; |
472 | 466 |
473 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); | 467 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); |
474 | 468 |
475 database->createTransaction( | 469 database->createTransaction( |
476 host_transaction_id, | 470 host_transaction_id, params.object_store_ids, params.mode); |
477 params.object_store_ids, | |
478 params.mode); | |
479 transaction_database_map_[host_transaction_id] = params.ipc_database_id; | 471 transaction_database_map_[host_transaction_id] = params.ipc_database_id; |
480 parent_->RegisterTransactionId(host_transaction_id, | 472 parent_->RegisterTransactionId(host_transaction_id, |
481 database_url_map_[params.ipc_database_id]); | 473 database_url_map_[params.ipc_database_id]); |
482 } | 474 } |
483 | 475 |
484 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnClose( | 476 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnClose( |
485 int32 ipc_database_id) { | 477 int32 ipc_database_id) { |
486 DCHECK( | 478 DCHECK( |
487 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 479 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
488 WebIDBDatabaseImpl* database = | 480 WebIDBDatabaseImpl* database = |
(...skipping 16 matching lines...) Expand all Loading... |
505 | 497 |
506 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnGet( | 498 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnGet( |
507 const IndexedDBHostMsg_DatabaseGet_Params& params) { | 499 const IndexedDBHostMsg_DatabaseGet_Params& params) { |
508 DCHECK( | 500 DCHECK( |
509 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 501 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
510 WebIDBDatabaseImpl* database = | 502 WebIDBDatabaseImpl* database = |
511 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); | 503 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); |
512 if (!database) | 504 if (!database) |
513 return; | 505 return; |
514 | 506 |
515 scoped_ptr<IndexedDBCallbacksBase> callbacks( | 507 scoped_refptr<IndexedDBCallbacks> callbacks(IndexedDBCallbacks::Create( |
516 new IndexedDBCallbacks<std::vector<char> >( | 508 parent_, params.ipc_thread_id, params.ipc_callbacks_id)); |
517 parent_, params.ipc_thread_id, params.ipc_callbacks_id)); | |
518 database->get(parent_->HostTransactionId(params.transaction_id), | 509 database->get(parent_->HostTransactionId(params.transaction_id), |
519 params.object_store_id, | 510 params.object_store_id, |
520 params.index_id, | 511 params.index_id, |
521 params.key_range, | 512 params.key_range, |
522 params.key_only, | 513 params.key_only, |
523 callbacks.release()); | 514 callbacks); |
524 } | 515 } |
525 | 516 |
526 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnPut( | 517 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnPut( |
527 const IndexedDBHostMsg_DatabasePut_Params& params) { | 518 const IndexedDBHostMsg_DatabasePut_Params& params) { |
528 DCHECK( | 519 DCHECK( |
529 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 520 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
530 | 521 |
531 WebIDBDatabaseImpl* database = | 522 WebIDBDatabaseImpl* database = |
532 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); | 523 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); |
533 if (!database) | 524 if (!database) |
534 return; | 525 return; |
535 scoped_ptr<IndexedDBCallbacksBase> callbacks( | 526 scoped_refptr<IndexedDBCallbacks> callbacks(IndexedDBCallbacks::Create( |
536 new IndexedDBCallbacks<IndexedDBKey>( | 527 parent_, params.ipc_thread_id, params.ipc_callbacks_id)); |
537 parent_, params.ipc_thread_id, params.ipc_callbacks_id)); | |
538 | 528 |
539 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); | 529 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); |
540 // TODO(alecflett): Avoid a copy here. | 530 // TODO(alecflett): Avoid a copy here. |
541 std::vector<char> value_copy = params.value; | 531 std::vector<char> value_copy = params.value; |
542 database->put(host_transaction_id, | 532 database->put(host_transaction_id, |
543 params.object_store_id, | 533 params.object_store_id, |
544 &value_copy, | 534 &value_copy, |
545 params.key, | 535 params.key, |
546 params.put_mode, | 536 params.put_mode, |
547 callbacks.release(), | 537 callbacks, |
548 params.index_ids, | 538 params.index_ids, |
549 params.index_keys); | 539 params.index_keys); |
550 TransactionIDToSizeMap* map = | 540 TransactionIDToSizeMap* map = |
551 &parent_->database_dispatcher_host_->transaction_size_map_; | 541 &parent_->database_dispatcher_host_->transaction_size_map_; |
552 // Size can't be big enough to overflow because it represents the | 542 // Size can't be big enough to overflow because it represents the |
553 // actual bytes passed through IPC. | 543 // actual bytes passed through IPC. |
554 (*map)[host_transaction_id] += params.value.size(); | 544 (*map)[host_transaction_id] += params.value.size(); |
555 } | 545 } |
556 | 546 |
557 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnSetIndexKeys( | 547 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnSetIndexKeys( |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 | 588 |
599 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnOpenCursor( | 589 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnOpenCursor( |
600 const IndexedDBHostMsg_DatabaseOpenCursor_Params& params) { | 590 const IndexedDBHostMsg_DatabaseOpenCursor_Params& params) { |
601 DCHECK( | 591 DCHECK( |
602 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 592 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
603 WebIDBDatabaseImpl* database = | 593 WebIDBDatabaseImpl* database = |
604 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); | 594 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); |
605 if (!database) | 595 if (!database) |
606 return; | 596 return; |
607 | 597 |
608 scoped_ptr<IndexedDBCallbacksBase> callbacks( | 598 scoped_refptr<IndexedDBCallbacks> callbacks(IndexedDBCallbacks::Create( |
609 new IndexedDBCallbacks<IndexedDBCursor>( | 599 parent_, params.ipc_thread_id, params.ipc_callbacks_id, -1)); |
610 parent_, params.ipc_thread_id, params.ipc_callbacks_id, -1)); | |
611 database->openCursor(parent_->HostTransactionId(params.transaction_id), | 600 database->openCursor(parent_->HostTransactionId(params.transaction_id), |
612 params.object_store_id, | 601 params.object_store_id, |
613 params.index_id, | 602 params.index_id, |
614 params.key_range, | 603 params.key_range, |
615 params.direction, | 604 params.direction, |
616 params.key_only, | 605 params.key_only, |
617 params.task_type, | 606 params.task_type, |
618 callbacks.release()); | 607 callbacks); |
619 } | 608 } |
620 | 609 |
621 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCount( | 610 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCount( |
622 const IndexedDBHostMsg_DatabaseCount_Params& params) { | 611 const IndexedDBHostMsg_DatabaseCount_Params& params) { |
623 DCHECK( | 612 DCHECK( |
624 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 613 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
625 WebIDBDatabaseImpl* database = | 614 WebIDBDatabaseImpl* database = |
626 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); | 615 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); |
627 if (!database) | 616 if (!database) |
628 return; | 617 return; |
629 | 618 |
630 scoped_ptr<IndexedDBCallbacksBase> callbacks( | 619 scoped_refptr<IndexedDBCallbacks> callbacks(IndexedDBCallbacks::Create( |
631 new IndexedDBCallbacks<std::vector<char> >( | 620 parent_, params.ipc_thread_id, params.ipc_callbacks_id)); |
632 parent_, params.ipc_thread_id, params.ipc_callbacks_id)); | |
633 database->count(parent_->HostTransactionId(params.transaction_id), | 621 database->count(parent_->HostTransactionId(params.transaction_id), |
634 params.object_store_id, | 622 params.object_store_id, |
635 params.index_id, | 623 params.index_id, |
636 params.key_range, | 624 params.key_range, |
637 callbacks.release()); | 625 callbacks); |
638 } | 626 } |
639 | 627 |
640 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteRange( | 628 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteRange( |
641 const IndexedDBHostMsg_DatabaseDeleteRange_Params& params) { | 629 const IndexedDBHostMsg_DatabaseDeleteRange_Params& params) { |
642 DCHECK( | 630 DCHECK( |
643 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 631 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
644 WebIDBDatabaseImpl* database = | 632 WebIDBDatabaseImpl* database = |
645 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); | 633 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); |
646 if (!database) | 634 if (!database) |
647 return; | 635 return; |
648 | 636 |
649 scoped_ptr<IndexedDBCallbacksBase> callbacks( | 637 scoped_refptr<IndexedDBCallbacks> callbacks(IndexedDBCallbacks::Create( |
650 new IndexedDBCallbacks<std::vector<char> >( | 638 parent_, params.ipc_thread_id, params.ipc_callbacks_id)); |
651 parent_, params.ipc_thread_id, params.ipc_callbacks_id)); | |
652 database->deleteRange(parent_->HostTransactionId(params.transaction_id), | 639 database->deleteRange(parent_->HostTransactionId(params.transaction_id), |
653 params.object_store_id, | 640 params.object_store_id, |
654 params.key_range, | 641 params.key_range, |
655 callbacks.release()); | 642 callbacks); |
656 } | 643 } |
657 | 644 |
658 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnClear( | 645 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnClear( |
659 int32 ipc_thread_id, | 646 int32 ipc_thread_id, |
660 int32 ipc_callbacks_id, | 647 int32 ipc_callbacks_id, |
661 int32 ipc_database_id, | 648 int32 ipc_database_id, |
662 int64 transaction_id, | 649 int64 transaction_id, |
663 int64 object_store_id) { | 650 int64 object_store_id) { |
664 DCHECK( | 651 DCHECK( |
665 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 652 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
666 WebIDBDatabaseImpl* database = | 653 WebIDBDatabaseImpl* database = |
667 parent_->GetOrTerminateProcess(&map_, ipc_database_id); | 654 parent_->GetOrTerminateProcess(&map_, ipc_database_id); |
668 if (!database) | 655 if (!database) |
669 return; | 656 return; |
670 | 657 |
671 scoped_ptr<IndexedDBCallbacksBase> callbacks( | 658 scoped_refptr<IndexedDBCallbacks> callbacks( |
672 new IndexedDBCallbacks<std::vector<char> >( | 659 IndexedDBCallbacks::Create(parent_, ipc_thread_id, ipc_callbacks_id)); |
673 parent_, ipc_thread_id, ipc_callbacks_id)); | |
674 | 660 |
675 database->clear(parent_->HostTransactionId(transaction_id), | 661 database->clear( |
676 object_store_id, | 662 parent_->HostTransactionId(transaction_id), object_store_id, callbacks); |
677 callbacks.release()); | |
678 } | 663 } |
679 | 664 |
680 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnAbort( | 665 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnAbort( |
681 int32 ipc_database_id, | 666 int32 ipc_database_id, |
682 int64 transaction_id) { | 667 int64 transaction_id) { |
683 DCHECK( | 668 DCHECK( |
684 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 669 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
685 WebIDBDatabaseImpl* database = | 670 WebIDBDatabaseImpl* database = |
686 parent_->GetOrTerminateProcess(&map_, ipc_database_id); | 671 parent_->GetOrTerminateProcess(&map_, ipc_database_id); |
687 if (!database) | 672 if (!database) |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 unsigned long count) { | 783 unsigned long count) { |
799 DCHECK( | 784 DCHECK( |
800 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 785 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
801 IndexedDBCursor* idb_cursor = | 786 IndexedDBCursor* idb_cursor = |
802 parent_->GetOrTerminateProcess(&map_, ipc_cursor_id); | 787 parent_->GetOrTerminateProcess(&map_, ipc_cursor_id); |
803 if (!idb_cursor) | 788 if (!idb_cursor) |
804 return; | 789 return; |
805 | 790 |
806 idb_cursor->Advance( | 791 idb_cursor->Advance( |
807 count, | 792 count, |
808 IndexedDBCallbacksWrapper::Create(new IndexedDBCallbacks<IndexedDBCursor>( | 793 IndexedDBCallbacks::Create( |
809 parent_, ipc_thread_id, ipc_callbacks_id, ipc_cursor_id))); | 794 parent_, ipc_thread_id, ipc_callbacks_id, ipc_cursor_id)); |
810 } | 795 } |
811 | 796 |
812 void IndexedDBDispatcherHost::CursorDispatcherHost::OnContinue( | 797 void IndexedDBDispatcherHost::CursorDispatcherHost::OnContinue( |
813 int32 ipc_cursor_id, | 798 int32 ipc_cursor_id, |
814 int32 ipc_thread_id, | 799 int32 ipc_thread_id, |
815 int32 ipc_callbacks_id, | 800 int32 ipc_callbacks_id, |
816 const IndexedDBKey& key) { | 801 const IndexedDBKey& key) { |
817 DCHECK( | 802 DCHECK( |
818 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 803 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
819 IndexedDBCursor* idb_cursor = | 804 IndexedDBCursor* idb_cursor = |
820 parent_->GetOrTerminateProcess(&map_, ipc_cursor_id); | 805 parent_->GetOrTerminateProcess(&map_, ipc_cursor_id); |
821 if (!idb_cursor) | 806 if (!idb_cursor) |
822 return; | 807 return; |
823 | 808 |
824 idb_cursor->ContinueFunction( | 809 idb_cursor->ContinueFunction( |
825 make_scoped_ptr(new IndexedDBKey(key)), | 810 make_scoped_ptr(new IndexedDBKey(key)), |
826 IndexedDBCallbacksWrapper::Create(new IndexedDBCallbacks<IndexedDBCursor>( | 811 IndexedDBCallbacks::Create( |
827 parent_, ipc_thread_id, ipc_callbacks_id, ipc_cursor_id))); | 812 parent_, ipc_thread_id, ipc_callbacks_id, ipc_cursor_id)); |
828 } | 813 } |
829 | 814 |
830 void IndexedDBDispatcherHost::CursorDispatcherHost::OnPrefetch( | 815 void IndexedDBDispatcherHost::CursorDispatcherHost::OnPrefetch( |
831 int32 ipc_cursor_id, | 816 int32 ipc_cursor_id, |
832 int32 ipc_thread_id, | 817 int32 ipc_thread_id, |
833 int32 ipc_callbacks_id, | 818 int32 ipc_callbacks_id, |
834 int n) { | 819 int n) { |
835 DCHECK( | 820 DCHECK( |
836 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 821 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
837 IndexedDBCursor* idb_cursor = | 822 IndexedDBCursor* idb_cursor = |
838 parent_->GetOrTerminateProcess(&map_, ipc_cursor_id); | 823 parent_->GetOrTerminateProcess(&map_, ipc_cursor_id); |
839 if (!idb_cursor) | 824 if (!idb_cursor) |
840 return; | 825 return; |
841 | 826 |
842 idb_cursor->PrefetchContinue( | 827 idb_cursor->PrefetchContinue( |
843 n, | 828 n, |
844 IndexedDBCallbacksWrapper::Create(new IndexedDBCallbacks<IndexedDBCursor>( | 829 IndexedDBCallbacks::Create( |
845 parent_, ipc_thread_id, ipc_callbacks_id, ipc_cursor_id))); | 830 parent_, ipc_thread_id, ipc_callbacks_id, ipc_cursor_id)); |
846 } | 831 } |
847 | 832 |
848 void IndexedDBDispatcherHost::CursorDispatcherHost::OnPrefetchReset( | 833 void IndexedDBDispatcherHost::CursorDispatcherHost::OnPrefetchReset( |
849 int32 ipc_cursor_id, | 834 int32 ipc_cursor_id, |
850 int used_prefetches, | 835 int used_prefetches, |
851 int unused_prefetches) { | 836 int unused_prefetches) { |
852 DCHECK( | 837 DCHECK( |
853 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 838 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
854 IndexedDBCursor* idb_cursor = | 839 IndexedDBCursor* idb_cursor = |
855 parent_->GetOrTerminateProcess(&map_, ipc_cursor_id); | 840 parent_->GetOrTerminateProcess(&map_, ipc_cursor_id); |
856 if (!idb_cursor) | 841 if (!idb_cursor) |
857 return; | 842 return; |
858 | 843 |
859 idb_cursor->PrefetchReset(used_prefetches, unused_prefetches); | 844 idb_cursor->PrefetchReset(used_prefetches, unused_prefetches); |
860 } | 845 } |
861 | 846 |
862 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( | 847 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( |
863 int32 ipc_object_id) { | 848 int32 ipc_object_id) { |
864 DCHECK( | 849 DCHECK( |
865 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 850 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
866 parent_->DestroyObject(&map_, ipc_object_id); | 851 parent_->DestroyObject(&map_, ipc_object_id); |
867 } | 852 } |
868 | 853 |
869 } // namespace content | 854 } // namespace content |
OLD | NEW |