Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: content/child/indexed_db/indexed_db_dispatcher.cc

Issue 18075008: IndexedDB: Switch key/value handling from vector<char> to std::string (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove C++11ism Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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())
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.begin(), value.size());
519 callbacks->onSuccess(web_value, primary_key, key_path); 519 callbacks->onSuccess(web_value, primary_key, key_path);
520 pending_callbacks_.Remove(ipc_callbacks_id); 520 pending_callbacks_.Remove(ipc_callbacks_id);
521 } 521 }
522 522
523 void IndexedDBDispatcher::OnSuccessInteger(int32 ipc_thread_id, 523 void IndexedDBDispatcher::OnSuccessInteger(int32 ipc_thread_id,
524 int32 ipc_callbacks_id, 524 int32 ipc_callbacks_id,
525 int64 value) { 525 int64 value) {
526 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); 526 DCHECK_EQ(ipc_thread_id, CurrentWorkerId());
527 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); 527 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id);
528 if (!callbacks) 528 if (!callbacks)
(...skipping 14 matching lines...) Expand all
543 543
544 void IndexedDBDispatcher::OnSuccessOpenCursor( 544 void IndexedDBDispatcher::OnSuccessOpenCursor(
545 const IndexedDBMsg_CallbacksSuccessIDBCursor_Params& p) { 545 const IndexedDBMsg_CallbacksSuccessIDBCursor_Params& p) {
546 DCHECK_EQ(p.ipc_thread_id, CurrentWorkerId()); 546 DCHECK_EQ(p.ipc_thread_id, CurrentWorkerId());
547 int32 ipc_callbacks_id = p.ipc_callbacks_id; 547 int32 ipc_callbacks_id = p.ipc_callbacks_id;
548 int32 ipc_object_id = p.ipc_cursor_id; 548 int32 ipc_object_id = p.ipc_cursor_id;
549 const IndexedDBKey& key = p.key; 549 const IndexedDBKey& key = p.key;
550 const IndexedDBKey& primary_key = p.primary_key; 550 const IndexedDBKey& primary_key = p.primary_key;
551 WebData web_value; 551 WebData web_value;
552 if (p.value.size()) 552 if (p.value.size())
553 web_value.assign(&p.value.front(), p.value.size()); 553 web_value.assign(&*p.value.begin(), p.value.size());
554 554
555 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); 555 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id);
556 if (!callbacks) 556 if (!callbacks)
557 return; 557 return;
558 558
559 RendererWebIDBCursorImpl* cursor = 559 RendererWebIDBCursorImpl* cursor =
560 new RendererWebIDBCursorImpl(ipc_object_id, thread_safe_sender_.get()); 560 new RendererWebIDBCursorImpl(ipc_object_id, thread_safe_sender_.get());
561 cursors_[ipc_object_id] = cursor; 561 cursors_[ipc_object_id] = cursor;
562 callbacks->onSuccess(cursor, key, primary_key, web_value); 562 callbacks->onSuccess(cursor, key, primary_key, web_value);
563 563
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;
596 const std::vector<IndexedDBKey>& keys = p.keys; 596 const std::vector<IndexedDBKey>& keys = p.keys;
597 const std::vector<IndexedDBKey>& primary_keys = p.primary_keys; 597 const std::vector<IndexedDBKey>& primary_keys = p.primary_keys;
598 std::vector<WebData> values(p.values.size()); 598 std::vector<WebData> values(p.values.size());
599 for (size_t i = 0; i < p.values.size(); ++i) { 599 for (size_t i = 0; i < p.values.size(); ++i) {
600 if (p.values[i].size()) 600 if (p.values[i].size())
601 values[i].assign(&p.values[i].front(), p.values[i].size()); 601 values[i].assign(&*p.values[i].begin(), p.values[i].size());
602 } 602 }
603 RendererWebIDBCursorImpl* cursor = cursors_[ipc_cursor_id]; 603 RendererWebIDBCursorImpl* cursor = cursors_[ipc_cursor_id];
604 DCHECK(cursor); 604 DCHECK(cursor);
605 cursor->SetPrefetchData(keys, primary_keys, values); 605 cursor->SetPrefetchData(keys, primary_keys, values);
606 606
607 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); 607 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id);
608 DCHECK(callbacks); 608 DCHECK(callbacks);
609 cursor->CachedContinue(callbacks); 609 cursor->CachedContinue(callbacks);
610 pending_callbacks_.Remove(ipc_callbacks_id); 610 pending_callbacks_.Remove(ipc_callbacks_id);
611 } 611 }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « content/child/indexed_db/indexed_db_dispatcher.h ('k') | content/common/indexed_db/indexed_db_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698