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

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

Issue 10272018: Move IndexedDBKey, IndexedDBKeyRange into content namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use "using content::*" aliasing for IDB/SSV types Created 8 years, 7 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 (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 "content/common/indexed_db/proxy_webidbindex_impl.h" 13 #include "content/common/indexed_db/proxy_webidbindex_impl.h"
14 #include "content/common/indexed_db/proxy_webidbobjectstore_impl.h" 14 #include "content/common/indexed_db/proxy_webidbobjectstore_impl.h"
15 #include "content/common/indexed_db/proxy_webidbtransaction_impl.h" 15 #include "content/common/indexed_db/proxy_webidbtransaction_impl.h"
16 #include "ipc/ipc_channel.h" 16 #include "ipc/ipc_channel.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseCallbac ks.h" 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseCallbac ks.h"
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseError.h " 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseError.h "
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseExcepti on.h" 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseExcepti on.h"
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyRange.h" 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyRange.h"
22 22
23 using base::ThreadLocalPointer; 23 using base::ThreadLocalPointer;
24 using content::IndexedDBKey;
25 using content::IndexedDBKeyRange;
26 using content::SerializedScriptValue;
24 using WebKit::WebDOMStringList; 27 using WebKit::WebDOMStringList;
25 using WebKit::WebExceptionCode; 28 using WebKit::WebExceptionCode;
26 using WebKit::WebFrame; 29 using WebKit::WebFrame;
27 using WebKit::WebIDBCallbacks; 30 using WebKit::WebIDBCallbacks;
28 using WebKit::WebIDBKeyRange; 31 using WebKit::WebIDBKeyRange;
29 using WebKit::WebIDBDatabase; 32 using WebKit::WebIDBDatabase;
30 using WebKit::WebIDBDatabaseCallbacks; 33 using WebKit::WebIDBDatabaseCallbacks;
31 using WebKit::WebIDBDatabaseError; 34 using WebKit::WebIDBDatabaseError;
32 using WebKit::WebIDBTransaction; 35 using WebKit::WebIDBTransaction;
33 using WebKit::WebIDBTransactionCallbacks; 36 using WebKit::WebIDBTransactionCallbacks;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 bool IndexedDBDispatcher::Send(IPC::Message* msg) { 115 bool IndexedDBDispatcher::Send(IPC::Message* msg) {
113 if (CurrentWorkerId()) { 116 if (CurrentWorkerId()) {
114 scoped_refptr<IPC::SyncMessageFilter> filter( 117 scoped_refptr<IPC::SyncMessageFilter> filter(
115 ChildThread::current()->sync_message_filter()); 118 ChildThread::current()->sync_message_filter());
116 return filter->Send(msg); 119 return filter->Send(msg);
117 } 120 }
118 return ChildThread::current()->Send(msg); 121 return ChildThread::current()->Send(msg);
119 } 122 }
120 123
121 void IndexedDBDispatcher::RequestIDBCursorUpdate( 124 void IndexedDBDispatcher::RequestIDBCursorUpdate(
122 const content::SerializedScriptValue& value, 125 const SerializedScriptValue& value,
123 WebIDBCallbacks* callbacks_ptr, 126 WebIDBCallbacks* callbacks_ptr,
124 int32 idb_cursor_id, 127 int32 idb_cursor_id,
125 WebExceptionCode* ec) { 128 WebExceptionCode* ec) {
126 ResetCursorPrefetchCaches(); 129 ResetCursorPrefetchCaches();
127 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); 130 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
128 if (!value.is_null() && 131 if (!value.is_null() &&
129 (value.data().length() * sizeof(char16)) > kMaxIDBValueSizeInBytes) { 132 (value.data().length() * sizeof(char16)) > kMaxIDBValueSizeInBytes) {
130 *ec = WebKit::WebIDBDatabaseExceptionDataError; 133 *ec = WebKit::WebIDBDatabaseExceptionDataError;
131 return; 134 return;
132 } 135 }
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 408
406 int32 response_id = pending_callbacks_.Add(callbacks.release()); 409 int32 response_id = pending_callbacks_.Add(callbacks.release());
407 Send(new IndexedDBHostMsg_ObjectStoreGet( 410 Send(new IndexedDBHostMsg_ObjectStoreGet(
408 idb_object_store_id, CurrentWorkerId(), response_id, 411 idb_object_store_id, CurrentWorkerId(), response_id,
409 key_range, TransactionId(transaction), ec)); 412 key_range, TransactionId(transaction), ec));
410 if (*ec) 413 if (*ec)
411 pending_callbacks_.Remove(response_id); 414 pending_callbacks_.Remove(response_id);
412 } 415 }
413 416
414 void IndexedDBDispatcher::RequestIDBObjectStorePut( 417 void IndexedDBDispatcher::RequestIDBObjectStorePut(
415 const content::SerializedScriptValue& value, 418 const SerializedScriptValue& value,
416 const IndexedDBKey& key, 419 const IndexedDBKey& key,
417 WebKit::WebIDBObjectStore::PutMode put_mode, 420 WebKit::WebIDBObjectStore::PutMode put_mode,
418 WebIDBCallbacks* callbacks_ptr, 421 WebIDBCallbacks* callbacks_ptr,
419 int32 idb_object_store_id, 422 int32 idb_object_store_id,
420 const WebIDBTransaction& transaction, 423 const WebIDBTransaction& transaction,
421 WebExceptionCode* ec) { 424 WebExceptionCode* ec) {
422 ResetCursorPrefetchCaches(); 425 ResetCursorPrefetchCaches();
423 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); 426 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
424 if (!value.is_null() && 427 if (!value.is_null() &&
425 (value.data().length() * sizeof(char16)) > kMaxIDBValueSizeInBytes) { 428 (value.data().length() * sizeof(char16)) > kMaxIDBValueSizeInBytes) {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 int32 response_id, 553 int32 response_id,
551 int32 object_id) { 554 int32 object_id) {
552 DCHECK_EQ(thread_id, CurrentWorkerId()); 555 DCHECK_EQ(thread_id, CurrentWorkerId());
553 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); 556 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
554 if (!callbacks) 557 if (!callbacks)
555 return; 558 return;
556 callbacks->onSuccess(new RendererWebIDBDatabaseImpl(object_id)); 559 callbacks->onSuccess(new RendererWebIDBDatabaseImpl(object_id));
557 pending_callbacks_.Remove(response_id); 560 pending_callbacks_.Remove(response_id);
558 } 561 }
559 562
560 void IndexedDBDispatcher::OnSuccessIndexedDBKey(int32 thread_id, 563 void IndexedDBDispatcher::OnSuccessIndexedDBKey(
561 int32 response_id, 564 int32 thread_id,
562 const IndexedDBKey& key) { 565 int32 response_id,
566 const IndexedDBKey& key) {
563 DCHECK_EQ(thread_id, CurrentWorkerId()); 567 DCHECK_EQ(thread_id, CurrentWorkerId());
564 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); 568 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
565 if (!callbacks) 569 if (!callbacks)
566 return; 570 return;
567 callbacks->onSuccess(key); 571 callbacks->onSuccess(key);
568 pending_callbacks_.Remove(response_id); 572 pending_callbacks_.Remove(response_id);
569 } 573 }
570 574
571 void IndexedDBDispatcher::OnSuccessIDBTransaction(int32 thread_id, 575 void IndexedDBDispatcher::OnSuccessIDBTransaction(int32 thread_id,
572 int32 response_id, 576 int32 response_id,
(...skipping 15 matching lines...) Expand all
588 WebDOMStringList string_list; 592 WebDOMStringList string_list;
589 for (std::vector<string16>::const_iterator it = value.begin(); 593 for (std::vector<string16>::const_iterator it = value.begin();
590 it != value.end(); ++it) 594 it != value.end(); ++it)
591 string_list.append(*it); 595 string_list.append(*it);
592 callbacks->onSuccess(string_list); 596 callbacks->onSuccess(string_list);
593 pending_callbacks_.Remove(response_id); 597 pending_callbacks_.Remove(response_id);
594 } 598 }
595 599
596 void IndexedDBDispatcher::OnSuccessSerializedScriptValue( 600 void IndexedDBDispatcher::OnSuccessSerializedScriptValue(
597 int32 thread_id, int32 response_id, 601 int32 thread_id, int32 response_id,
598 const content::SerializedScriptValue& value) { 602 const SerializedScriptValue& value) {
599 DCHECK_EQ(thread_id, CurrentWorkerId()); 603 DCHECK_EQ(thread_id, CurrentWorkerId());
600 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); 604 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
601 if (!callbacks) 605 if (!callbacks)
602 return; 606 return;
603 callbacks->onSuccess(value); 607 callbacks->onSuccess(value);
604 pending_callbacks_.Remove(response_id); 608 pending_callbacks_.Remove(response_id);
605 } 609 }
606 610
607 void IndexedDBDispatcher::OnSuccessOpenCursor( 611 void IndexedDBDispatcher::OnSuccessOpenCursor(
608 const IndexedDBMsg_CallbacksSuccessIDBCursor_Params& p) { 612 const IndexedDBMsg_CallbacksSuccessIDBCursor_Params& p) {
609 DCHECK_EQ(p.thread_id, CurrentWorkerId()); 613 DCHECK_EQ(p.thread_id, CurrentWorkerId());
610 int32 response_id = p.response_id; 614 int32 response_id = p.response_id;
611 int32 object_id = p.cursor_id; 615 int32 object_id = p.cursor_id;
612 const IndexedDBKey& key = p.key; 616 const IndexedDBKey& key = p.key;
613 const IndexedDBKey& primary_key = p.primary_key; 617 const IndexedDBKey& primary_key = p.primary_key;
614 const content::SerializedScriptValue& value = p.serialized_value; 618 const SerializedScriptValue& value = p.serialized_value;
615 619
616 WebIDBCallbacks* callbacks = 620 WebIDBCallbacks* callbacks =
617 pending_callbacks_.Lookup(response_id); 621 pending_callbacks_.Lookup(response_id);
618 if (!callbacks) 622 if (!callbacks)
619 return; 623 return;
620 624
621 RendererWebIDBCursorImpl* cursor = new RendererWebIDBCursorImpl(object_id); 625 RendererWebIDBCursorImpl* cursor = new RendererWebIDBCursorImpl(object_id);
622 cursors_[object_id] = cursor; 626 cursors_[object_id] = cursor;
623 cursor->SetKeyAndValue(key, primary_key, value); 627 cursor->SetKeyAndValue(key, primary_key, value);
624 callbacks->onSuccess(cursor); 628 callbacks->onSuccess(cursor);
625 629
626 pending_callbacks_.Remove(response_id); 630 pending_callbacks_.Remove(response_id);
627 } 631 }
628 632
629 void IndexedDBDispatcher::OnSuccessCursorContinue( 633 void IndexedDBDispatcher::OnSuccessCursorContinue(
630 const IndexedDBMsg_CallbacksSuccessCursorContinue_Params& p) { 634 const IndexedDBMsg_CallbacksSuccessCursorContinue_Params& p) {
631 DCHECK_EQ(p.thread_id, CurrentWorkerId()); 635 DCHECK_EQ(p.thread_id, CurrentWorkerId());
632 int32 response_id = p.response_id; 636 int32 response_id = p.response_id;
633 int32 cursor_id = p.cursor_id; 637 int32 cursor_id = p.cursor_id;
634 const IndexedDBKey& key = p.key; 638 const IndexedDBKey& key = p.key;
635 const IndexedDBKey& primary_key = p.primary_key; 639 const IndexedDBKey& primary_key = p.primary_key;
636 const content::SerializedScriptValue& value = p.serialized_value; 640 const SerializedScriptValue& value = p.serialized_value;
637 641
638 RendererWebIDBCursorImpl* cursor = cursors_[cursor_id]; 642 RendererWebIDBCursorImpl* cursor = cursors_[cursor_id];
639 DCHECK(cursor); 643 DCHECK(cursor);
640 cursor->SetKeyAndValue(key, primary_key, value); 644 cursor->SetKeyAndValue(key, primary_key, value);
641 645
642 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); 646 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
643 if (!callbacks) 647 if (!callbacks)
644 return; 648 return;
645 callbacks->onSuccessWithContinuation(); 649 callbacks->onSuccessWithContinuation();
646 650
647 pending_callbacks_.Remove(response_id); 651 pending_callbacks_.Remove(response_id);
648 } 652 }
649 653
650 void IndexedDBDispatcher::OnSuccessCursorPrefetch( 654 void IndexedDBDispatcher::OnSuccessCursorPrefetch(
651 const IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params& p) { 655 const IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params& p) {
652 DCHECK_EQ(p.thread_id, CurrentWorkerId()); 656 DCHECK_EQ(p.thread_id, CurrentWorkerId());
653 int32 response_id = p.response_id; 657 int32 response_id = p.response_id;
654 int32 cursor_id = p.cursor_id; 658 int32 cursor_id = p.cursor_id;
655 const std::vector<IndexedDBKey>& keys = p.keys; 659 const std::vector<IndexedDBKey>& keys = p.keys;
656 const std::vector<IndexedDBKey>& primary_keys = p.primary_keys; 660 const std::vector<IndexedDBKey>& primary_keys = p.primary_keys;
657 const std::vector<content::SerializedScriptValue>& values = p.values; 661 const std::vector<SerializedScriptValue>& values = p.values;
658 RendererWebIDBCursorImpl* cursor = cursors_[cursor_id]; 662 RendererWebIDBCursorImpl* cursor = cursors_[cursor_id];
659 DCHECK(cursor); 663 DCHECK(cursor);
660 cursor->SetPrefetchData(keys, primary_keys, values); 664 cursor->SetPrefetchData(keys, primary_keys, values);
661 665
662 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); 666 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
663 DCHECK(callbacks); 667 DCHECK(callbacks);
664 cursor->CachedContinue(callbacks); 668 cursor->CachedContinue(callbacks);
665 pending_callbacks_.Remove(response_id); 669 pending_callbacks_.Remove(response_id);
666 } 670 }
667 671
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 } 720 }
717 721
718 void IndexedDBDispatcher::ResetCursorPrefetchCaches(int32 exception_cursor_id) { 722 void IndexedDBDispatcher::ResetCursorPrefetchCaches(int32 exception_cursor_id) {
719 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; 723 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator;
720 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { 724 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) {
721 if (i->first == exception_cursor_id) 725 if (i->first == exception_cursor_id)
722 continue; 726 continue;
723 i->second->ResetPrefetchCache(); 727 i->second->ResetPrefetchCache();
724 } 728 }
725 } 729 }
OLDNEW
« no previous file with comments | « content/common/indexed_db/indexed_db_dispatcher.h ('k') | content/common/indexed_db/indexed_db_dispatcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698