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/indexed_db_dispatcher.h" | 5 #include "content/child/indexed_db/indexed_db_dispatcher.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
494 int32 ipc_callbacks_id, | 494 int32 ipc_callbacks_id, |
495 const std::vector<base::string16>& value) { | 495 const std::vector<base::string16>& value) { |
496 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); | 496 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); |
497 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); | 497 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); |
498 if (!callbacks) | 498 if (!callbacks) |
499 return; | 499 return; |
500 callbacks->onSuccess(WebVector<WebString>(value)); | 500 callbacks->onSuccess(WebVector<WebString>(value)); |
501 pending_callbacks_.Remove(ipc_callbacks_id); | 501 pending_callbacks_.Remove(ipc_callbacks_id); |
502 } | 502 } |
503 | 503 |
504 void IndexedDBDispatcher::OnSuccessValue(int32 ipc_thread_id, | 504 void IndexedDBDispatcher::OnSuccessValue( |
505 int32 ipc_callbacks_id, | 505 const IndexedDBMsg_CallbacksSuccessValue_Params& p) { |
506 const std::string& value) { | 506 DCHECK_EQ(p.ipc_thread_id, CurrentWorkerId()); |
507 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); | 507 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(p.ipc_callbacks_id); |
508 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); | |
509 if (!callbacks) | 508 if (!callbacks) |
510 return; | 509 return; |
511 WebData web_value; | 510 WebData web_value; |
512 if (value.size()) | 511 if (p.value.size()) |
cmumford
2014/04/08 21:47:26
Nit: was here before, but size() is O(n), but empt
ericu
2014/04/08 22:07:11
As discussed in person, size() is likely O(1), but
| |
513 web_value.assign(&*value.begin(), value.size()); | 512 web_value.assign(&*p.value.begin(), p.value.size()); |
514 callbacks->onSuccess(web_value); | 513 callbacks->onSuccess(web_value); |
515 pending_callbacks_.Remove(ipc_callbacks_id); | 514 pending_callbacks_.Remove(p.ipc_callbacks_id); |
516 cursor_transaction_ids_.erase(ipc_callbacks_id); | 515 cursor_transaction_ids_.erase(p.ipc_callbacks_id); |
517 } | 516 } |
518 | 517 |
519 void IndexedDBDispatcher::OnSuccessValueWithKey( | 518 void IndexedDBDispatcher::OnSuccessValueWithKey( |
520 int32 ipc_thread_id, | 519 const IndexedDBMsg_CallbacksSuccessValueWithKey_Params& p) { |
521 int32 ipc_callbacks_id, | 520 DCHECK_EQ(p.ipc_thread_id, CurrentWorkerId()); |
522 const std::string& value, | 521 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(p.ipc_callbacks_id); |
523 const IndexedDBKey& primary_key, | |
524 const IndexedDBKeyPath& key_path) { | |
525 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); | |
526 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); | |
527 if (!callbacks) | 522 if (!callbacks) |
528 return; | 523 return; |
529 WebData web_value; | 524 WebData web_value; |
530 if (value.size()) | 525 if (p.value.size()) |
531 web_value.assign(&*value.begin(), value.size()); | 526 web_value.assign(&*p.value.begin(), p.value.size()); |
532 callbacks->onSuccess(web_value, | 527 callbacks->onSuccess(web_value, |
533 WebIDBKeyBuilder::Build(primary_key), | 528 WebIDBKeyBuilder::Build(p.primary_key), |
534 WebIDBKeyPathBuilder::Build(key_path)); | 529 WebIDBKeyPathBuilder::Build(p.key_path)); |
535 pending_callbacks_.Remove(ipc_callbacks_id); | 530 pending_callbacks_.Remove(p.ipc_callbacks_id); |
536 } | 531 } |
537 | 532 |
538 void IndexedDBDispatcher::OnSuccessInteger(int32 ipc_thread_id, | 533 void IndexedDBDispatcher::OnSuccessInteger(int32 ipc_thread_id, |
539 int32 ipc_callbacks_id, | 534 int32 ipc_callbacks_id, |
540 int64 value) { | 535 int64 value) { |
541 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); | 536 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); |
542 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); | 537 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); |
543 if (!callbacks) | 538 if (!callbacks) |
544 return; | 539 return; |
545 callbacks->onSuccess(value); | 540 callbacks->onSuccess(value); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
733 typedef std::map<int32, WebIDBCursorImpl*>::iterator Iterator; | 728 typedef std::map<int32, WebIDBCursorImpl*>::iterator Iterator; |
734 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { | 729 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { |
735 if (i->first == ipc_exception_cursor_id || | 730 if (i->first == ipc_exception_cursor_id || |
736 i->second->transaction_id() != transaction_id) | 731 i->second->transaction_id() != transaction_id) |
737 continue; | 732 continue; |
738 i->second->ResetPrefetchCache(); | 733 i->second->ResetPrefetchCache(); |
739 } | 734 } |
740 } | 735 } |
741 | 736 |
742 } // namespace content | 737 } // namespace content |
OLD | NEW |