Chromium Code Reviews| 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 "base/format_macros.h" | 7 #include "base/format_macros.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/threading/thread_local.h" | 10 #include "base/threading/thread_local.h" |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 484 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); | 484 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); |
| 485 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); | 485 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); |
| 486 if (!callbacks) | 486 if (!callbacks) |
| 487 return; | 487 return; |
| 488 callbacks->onSuccess(WebVector<WebString>(value)); | 488 callbacks->onSuccess(WebVector<WebString>(value)); |
| 489 pending_callbacks_.Remove(ipc_callbacks_id); | 489 pending_callbacks_.Remove(ipc_callbacks_id); |
| 490 } | 490 } |
| 491 | 491 |
| 492 void IndexedDBDispatcher::OnSuccessValue(int32 ipc_thread_id, | 492 void IndexedDBDispatcher::OnSuccessValue(int32 ipc_thread_id, |
| 493 int32 ipc_callbacks_id, | 493 int32 ipc_callbacks_id, |
| 494 const std::vector<char>& value) { | 494 const std::string& value) { |
| 495 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); | 495 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); |
| 496 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); | 496 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); |
| 497 if (!callbacks) | 497 if (!callbacks) |
| 498 return; | 498 return; |
| 499 WebData web_value; | 499 WebData web_value; |
| 500 if (value.size()) | 500 if (value.size()) |
|
alecflett
2013/07/09 18:26:30
I think you can skip the if (value.size()) now? Or
jsbell
2013/07/09 19:41:46
Affects strings too.
| |
| 501 web_value.assign(&value.front(), value.size()); | 501 web_value.assign(&*value.begin(), value.size()); |
| 502 callbacks->onSuccess(web_value); | 502 callbacks->onSuccess(web_value); |
| 503 pending_callbacks_.Remove(ipc_callbacks_id); | 503 pending_callbacks_.Remove(ipc_callbacks_id); |
| 504 } | 504 } |
| 505 | 505 |
| 506 void IndexedDBDispatcher::OnSuccessValueWithKey( | 506 void IndexedDBDispatcher::OnSuccessValueWithKey( |
| 507 int32 ipc_thread_id, | 507 int32 ipc_thread_id, |
| 508 int32 ipc_callbacks_id, | 508 int32 ipc_callbacks_id, |
| 509 const std::vector<char>& value, | 509 const std::string& value, |
| 510 const IndexedDBKey& primary_key, | 510 const IndexedDBKey& primary_key, |
| 511 const IndexedDBKeyPath& key_path) { | 511 const IndexedDBKeyPath& key_path) { |
| 512 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); | 512 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); |
| 513 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); | 513 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); |
| 514 if (!callbacks) | 514 if (!callbacks) |
| 515 return; | 515 return; |
| 516 WebData web_value; | 516 WebData web_value; |
| 517 if (value.size()) | 517 if (value.size()) |
| 518 web_value.assign(&value.front(), value.size()); | 518 web_value.assign(&value.front(), value.size()); |
| 519 callbacks->onSuccess(web_value, primary_key, key_path); | 519 callbacks->onSuccess(web_value, primary_key, key_path); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 564 pending_callbacks_.Remove(ipc_callbacks_id); | 564 pending_callbacks_.Remove(ipc_callbacks_id); |
| 565 } | 565 } |
| 566 | 566 |
| 567 void IndexedDBDispatcher::OnSuccessCursorContinue( | 567 void IndexedDBDispatcher::OnSuccessCursorContinue( |
| 568 const IndexedDBMsg_CallbacksSuccessCursorContinue_Params& p) { | 568 const IndexedDBMsg_CallbacksSuccessCursorContinue_Params& p) { |
| 569 DCHECK_EQ(p.ipc_thread_id, CurrentWorkerId()); | 569 DCHECK_EQ(p.ipc_thread_id, CurrentWorkerId()); |
| 570 int32 ipc_callbacks_id = p.ipc_callbacks_id; | 570 int32 ipc_callbacks_id = p.ipc_callbacks_id; |
| 571 int32 ipc_cursor_id = p.ipc_cursor_id; | 571 int32 ipc_cursor_id = p.ipc_cursor_id; |
| 572 const IndexedDBKey& key = p.key; | 572 const IndexedDBKey& key = p.key; |
| 573 const IndexedDBKey& primary_key = p.primary_key; | 573 const IndexedDBKey& primary_key = p.primary_key; |
| 574 const std::vector<char>& value = p.value; | 574 const std::string& value = p.value; |
| 575 | 575 |
| 576 RendererWebIDBCursorImpl* cursor = cursors_[ipc_cursor_id]; | 576 RendererWebIDBCursorImpl* cursor = cursors_[ipc_cursor_id]; |
| 577 DCHECK(cursor); | 577 DCHECK(cursor); |
| 578 | 578 |
| 579 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); | 579 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); |
| 580 if (!callbacks) | 580 if (!callbacks) |
| 581 return; | 581 return; |
| 582 | 582 |
| 583 WebData web_value; | 583 WebData web_value; |
| 584 if (value.size()) | 584 if (value.size()) |
| 585 web_value.assign(&value.front(), value.size()); | 585 web_value.assign(&*value.begin(), value.size()); |
| 586 callbacks->onSuccess(key, primary_key, web_value); | 586 callbacks->onSuccess(key, primary_key, web_value); |
| 587 | 587 |
| 588 pending_callbacks_.Remove(ipc_callbacks_id); | 588 pending_callbacks_.Remove(ipc_callbacks_id); |
| 589 } | 589 } |
| 590 | 590 |
| 591 void IndexedDBDispatcher::OnSuccessCursorPrefetch( | 591 void IndexedDBDispatcher::OnSuccessCursorPrefetch( |
| 592 const IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params& p) { | 592 const IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params& p) { |
| 593 DCHECK_EQ(p.ipc_thread_id, CurrentWorkerId()); | 593 DCHECK_EQ(p.ipc_thread_id, CurrentWorkerId()); |
| 594 int32 ipc_callbacks_id = p.ipc_callbacks_id; | 594 int32 ipc_callbacks_id = p.ipc_callbacks_id; |
| 595 int32 ipc_cursor_id = p.ipc_cursor_id; | 595 int32 ipc_cursor_id = p.ipc_cursor_id; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 707 int32 ipc_exception_cursor_id) { | 707 int32 ipc_exception_cursor_id) { |
| 708 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; | 708 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; |
| 709 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { | 709 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { |
| 710 if (i->first == ipc_exception_cursor_id) | 710 if (i->first == ipc_exception_cursor_id) |
| 711 continue; | 711 continue; |
| 712 i->second->ResetPrefetchCache(); | 712 i->second->ResetPrefetchCache(); |
| 713 } | 713 } |
| 714 } | 714 } |
| 715 | 715 |
| 716 } // namespace content | 716 } // namespace content |
| OLD | NEW |