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

Side by Side Diff: content/browser/in_process_webkit/indexed_db_dispatcher_host.cc

Issue 10831138: Remove a ton of IPC from landing putWithIndexKeys (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Additional stuff found with lint Created 8 years, 4 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
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/browser/in_process_webkit/indexed_db_dispatcher_host.h" 5 #include "content/browser/in_process_webkit/indexed_db_dispatcher_host.h"
6 6
7 #include <vector>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/command_line.h" 10 #include "base/command_line.h"
9 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
10 #include "content/browser/in_process_webkit/indexed_db_callbacks.h" 12 #include "content/browser/in_process_webkit/indexed_db_callbacks.h"
11 #include "content/browser/in_process_webkit/indexed_db_context_impl.h" 13 #include "content/browser/in_process_webkit/indexed_db_context_impl.h"
12 #include "content/browser/in_process_webkit/indexed_db_database_callbacks.h" 14 #include "content/browser/in_process_webkit/indexed_db_database_callbacks.h"
13 #include "content/browser/in_process_webkit/indexed_db_transaction_callbacks.h" 15 #include "content/browser/in_process_webkit/indexed_db_transaction_callbacks.h"
14 #include "content/browser/renderer_host/render_message_filter.h" 16 #include "content/browser/renderer_host/render_message_filter.h"
15 #include "content/common/indexed_db/indexed_db_messages.h" 17 #include "content/common/indexed_db/indexed_db_messages.h"
16 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 using WebKit::WebVector; 56 using WebKit::WebVector;
55 57
56 namespace { 58 namespace {
57 59
58 template <class T> 60 template <class T>
59 void DeleteOnWebKitThread(T* obj) { 61 void DeleteOnWebKitThread(T* obj) {
60 if (!BrowserThread::DeleteSoon(BrowserThread::WEBKIT_DEPRECATED, 62 if (!BrowserThread::DeleteSoon(BrowserThread::WEBKIT_DEPRECATED,
61 FROM_HERE, obj)) 63 FROM_HERE, obj))
62 delete obj; 64 delete obj;
63 } 65 }
64
dgrogan 2012/08/02 20:27:32 Lint told you to remove this line? Should line 57
alecflett 2012/08/02 21:25:05 I think it's because it is at the END of a scope..
65 } 66 }
66 67
67 IndexedDBDispatcherHost::IndexedDBDispatcherHost( 68 IndexedDBDispatcherHost::IndexedDBDispatcherHost(
68 int process_id, IndexedDBContextImpl* indexed_db_context) 69 int process_id, IndexedDBContextImpl* indexed_db_context)
69 : indexed_db_context_(indexed_db_context), 70 : indexed_db_context_(indexed_db_context),
70 ALLOW_THIS_IN_INITIALIZER_LIST(database_dispatcher_host_( 71 ALLOW_THIS_IN_INITIALIZER_LIST(database_dispatcher_host_(
71 new DatabaseDispatcherHost(this))), 72 new DatabaseDispatcherHost(this))),
72 ALLOW_THIS_IN_INITIALIZER_LIST(index_dispatcher_host_( 73 ALLOW_THIS_IN_INITIALIZER_LIST(index_dispatcher_host_(
73 new IndexDispatcherHost(this))), 74 new IndexDispatcherHost(this))),
74 ALLOW_THIS_IN_INITIALIZER_LIST(object_store_dispatcher_host_( 75 ALLOW_THIS_IN_INITIALIZER_LIST(object_store_dispatcher_host_(
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 272 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
272 ObjectType* return_object = map->Lookup(return_object_id); 273 ObjectType* return_object = map->Lookup(return_object_id);
273 if (!return_object) { 274 if (!return_object) {
274 NOTREACHED() << "Uh oh, couldn't find object with id " << return_object_id; 275 NOTREACHED() << "Uh oh, couldn't find object with id " << return_object_id;
275 content::RecordAction(UserMetricsAction("BadMessageTerminate_IDBMF")); 276 content::RecordAction(UserMetricsAction("BadMessageTerminate_IDBMF"));
276 BadMessageReceived(); 277 BadMessageReceived();
277 } 278 }
278 return return_object; 279 return return_object;
279 } 280 }
280 281
281 template <typename ReplyType, typename MapObjectType, typename Method>
282 void IndexedDBDispatcherHost::SyncGetter(
283 IDMap<MapObjectType, IDMapOwnPointer>* map, int32 object_id,
284 ReplyType* reply, Method method) {
285 MapObjectType* object = GetOrTerminateProcess(map, object_id);
286 if (!object)
287 return;
288
289 *reply = (object->*method)();
290 }
291
292 template <typename ObjectType> 282 template <typename ObjectType>
293 void IndexedDBDispatcherHost::DestroyObject( 283 void IndexedDBDispatcherHost::DestroyObject(
294 IDMap<ObjectType, IDMapOwnPointer>* map, int32 object_id) { 284 IDMap<ObjectType, IDMapOwnPointer>* map, int32 object_id) {
295 GetOrTerminateProcess(map, object_id); 285 GetOrTerminateProcess(map, object_id);
296 map->Remove(object_id); 286 map->Remove(object_id);
297 } 287 }
298 288
299 289
300 ////////////////////////////////////////////////////////////////////// 290 //////////////////////////////////////////////////////////////////////
301 // IndexedDBDispatcherHost::DatabaseDispatcherHost 291 // IndexedDBDispatcherHost::DatabaseDispatcherHost
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 return; 748 return;
759 749
760 *ec = 0; 750 *ec = 0;
761 scoped_ptr<WebIDBCallbacks> callbacks( 751 scoped_ptr<WebIDBCallbacks> callbacks(
762 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, thread_id, 752 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, thread_id,
763 response_id)); 753 response_id));
764 idb_object_store->clear(callbacks.release(), *idb_transaction, *ec); 754 idb_object_store->clear(callbacks.release(), *idb_transaction, *ec);
765 } 755 }
766 756
767 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnCreateIndex( 757 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnCreateIndex(
768 const IndexedDBHostMsg_ObjectStoreCreateIndex_Params& params, 758 const IndexedDBHostMsg_ObjectStoreCreateIndex_Params& params,
769 int32* index_id, WebKit::WebExceptionCode* ec) { 759 int32* index_id, WebKit::WebExceptionCode* ec) {
770 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 760 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
771 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( 761 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess(
772 &map_, params.idb_object_store_id); 762 &map_, params.idb_object_store_id);
773 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( 763 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess(
774 &parent_->transaction_dispatcher_host_->map_, params.transaction_id); 764 &parent_->transaction_dispatcher_host_->map_, params.transaction_id);
775 if (!idb_object_store || !idb_transaction) 765 if (!idb_object_store || !idb_transaction)
776 return; 766 return;
777 767
778 *ec = 0; 768 *ec = 0;
779 WebIDBIndex* index = idb_object_store->createIndex( 769 WebIDBIndex* index = idb_object_store->createIndex(
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 } 868 }
879 869
880 IndexedDBDispatcherHost::CursorDispatcherHost::~CursorDispatcherHost() { 870 IndexedDBDispatcherHost::CursorDispatcherHost::~CursorDispatcherHost() {
881 } 871 }
882 872
883 bool IndexedDBDispatcherHost::CursorDispatcherHost::OnMessageReceived( 873 bool IndexedDBDispatcherHost::CursorDispatcherHost::OnMessageReceived(
884 const IPC::Message& message, bool* msg_is_ok) { 874 const IPC::Message& message, bool* msg_is_ok) {
885 bool handled = true; 875 bool handled = true;
886 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::CursorDispatcherHost, 876 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::CursorDispatcherHost,
887 message, *msg_is_ok) 877 message, *msg_is_ok)
888 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_CursorUpdate, OnUpdate)
889 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_CursorAdvance, OnAdvance) 878 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_CursorAdvance, OnAdvance)
890 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_CursorContinue, OnContinue) 879 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_CursorContinue, OnContinue)
891 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_CursorPrefetch, OnPrefetch) 880 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_CursorPrefetch, OnPrefetch)
892 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_CursorPrefetchReset, OnPrefetchReset) 881 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_CursorPrefetchReset, OnPrefetchReset)
893 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_CursorDelete, OnDelete) 882 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_CursorDelete, OnDelete)
894 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_CursorDestroyed, OnDestroyed) 883 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_CursorDestroyed, OnDestroyed)
895 IPC_MESSAGE_UNHANDLED(handled = false) 884 IPC_MESSAGE_UNHANDLED(handled = false)
896 IPC_END_MESSAGE_MAP() 885 IPC_END_MESSAGE_MAP()
897 return handled; 886 return handled;
898 } 887 }
(...skipping 25 matching lines...) Expand all
924 void IndexedDBDispatcherHost::CursorDispatcherHost::OnValue( 913 void IndexedDBDispatcherHost::CursorDispatcherHost::OnValue(
925 int32 object_id, 914 int32 object_id,
926 SerializedScriptValue* script_value) { 915 SerializedScriptValue* script_value) {
927 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, object_id); 916 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, object_id);
928 if (!idb_cursor) 917 if (!idb_cursor)
929 return; 918 return;
930 919
931 *script_value = SerializedScriptValue(idb_cursor->value()); 920 *script_value = SerializedScriptValue(idb_cursor->value());
932 } 921 }
933 922
934 void IndexedDBDispatcherHost::CursorDispatcherHost::OnUpdate(
935 int32 cursor_id,
936 int32 thread_id,
937 int32 response_id,
938 const SerializedScriptValue& value,
939 WebKit::WebExceptionCode* ec) {
940 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
941 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, cursor_id);
942 if (!idb_cursor)
943 return;
944
945 *ec = 0;
946 idb_cursor->update(
947 value, new IndexedDBCallbacks<WebIDBKey>(parent_, thread_id, response_id),
948 *ec);
949 }
950
951 void IndexedDBDispatcherHost::CursorDispatcherHost::OnAdvance( 923 void IndexedDBDispatcherHost::CursorDispatcherHost::OnAdvance(
952 int32 cursor_id, 924 int32 cursor_id,
953 int32 thread_id, 925 int32 thread_id,
954 int32 response_id, 926 int32 response_id,
955 unsigned long count, 927 unsigned long count,
956 WebKit::WebExceptionCode* ec) { 928 WebKit::WebExceptionCode* ec) {
957 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 929 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
958 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, cursor_id); 930 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, cursor_id);
959 if (!idb_cursor) 931 if (!idb_cursor)
960 return; 932 return;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1052 } 1024 }
1053 } 1025 }
1054 1026
1055 bool IndexedDBDispatcherHost::TransactionDispatcherHost::OnMessageReceived( 1027 bool IndexedDBDispatcherHost::TransactionDispatcherHost::OnMessageReceived(
1056 const IPC::Message& message, bool* msg_is_ok) { 1028 const IPC::Message& message, bool* msg_is_ok) {
1057 bool handled = true; 1029 bool handled = true;
1058 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::TransactionDispatcherHost, 1030 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::TransactionDispatcherHost,
1059 message, *msg_is_ok) 1031 message, *msg_is_ok)
1060 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_TransactionCommit, OnCommit) 1032 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_TransactionCommit, OnCommit)
1061 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_TransactionAbort, OnAbort) 1033 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_TransactionAbort, OnAbort)
1062 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_TransactionMode, OnMode)
1063 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_TransactionObjectStore, OnObjectStore) 1034 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_TransactionObjectStore, OnObjectStore)
1064 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_TransactionDidCompleteTaskEvents, 1035 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_TransactionDidCompleteTaskEvents,
1065 OnDidCompleteTaskEvents) 1036 OnDidCompleteTaskEvents)
1066 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_TransactionDestroyed, OnDestroyed) 1037 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_TransactionDestroyed, OnDestroyed)
1067 IPC_MESSAGE_UNHANDLED(handled = false) 1038 IPC_MESSAGE_UNHANDLED(handled = false)
1068 IPC_END_MESSAGE_MAP() 1039 IPC_END_MESSAGE_MAP()
1069 return handled; 1040 return handled;
1070 } 1041 }
1071 1042
1072 void IndexedDBDispatcherHost::TransactionDispatcherHost::Send( 1043 void IndexedDBDispatcherHost::TransactionDispatcherHost::Send(
(...skipping 14 matching lines...) Expand all
1087 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnAbort( 1058 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnAbort(
1088 int32 transaction_id) { 1059 int32 transaction_id) {
1089 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( 1060 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess(
1090 &map_, transaction_id); 1061 &map_, transaction_id);
1091 if (!idb_transaction) 1062 if (!idb_transaction)
1092 return; 1063 return;
1093 1064
1094 idb_transaction->abort(); 1065 idb_transaction->abort();
1095 } 1066 }
1096 1067
1097 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnMode(
1098 int32 transaction_id,
1099 int* mode) {
1100 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess(
1101 &map_, transaction_id);
1102 if (!idb_transaction)
1103 return;
1104
1105 *mode = idb_transaction->mode();
1106 }
1107
1108 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnObjectStore( 1068 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnObjectStore(
1109 int32 transaction_id, const string16& name, int32* object_store_id, 1069 int32 transaction_id, const string16& name, int32* object_store_id,
1110 WebKit::WebExceptionCode* ec) { 1070 WebKit::WebExceptionCode* ec) {
1111 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( 1071 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess(
1112 &map_, transaction_id); 1072 &map_, transaction_id);
1113 if (!idb_transaction) 1073 if (!idb_transaction)
1114 return; 1074 return;
1115 1075
1116 *ec = 0; 1076 *ec = 0;
1117 WebIDBObjectStore* object_store = idb_transaction->objectStore(name, *ec); 1077 WebIDBObjectStore* object_store = idb_transaction->objectStore(name, *ec);
(...skipping 20 matching lines...) Expand all
1138 } 1098 }
1139 1099
1140 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( 1100 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed(
1141 int32 object_id) { 1101 int32 object_id) {
1142 // TODO(dgrogan): This doesn't seem to be happening with some version change 1102 // TODO(dgrogan): This doesn't seem to be happening with some version change
1143 // transactions. Possibly introduced with integer version support. 1103 // transactions. Possibly introduced with integer version support.
1144 transaction_size_map_.erase(object_id); 1104 transaction_size_map_.erase(object_id);
1145 transaction_url_map_.erase(object_id); 1105 transaction_url_map_.erase(object_id);
1146 parent_->DestroyObject(&map_, object_id); 1106 parent_->DestroyObject(&map_, object_id);
1147 } 1107 }
OLDNEW
« no previous file with comments | « content/browser/in_process_webkit/indexed_db_dispatcher_host.h ('k') | content/common/indexed_db/indexed_db_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698