| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/in_process_webkit/indexed_db_dispatcher_host.h" | 5 #include "chrome/browser/in_process_webkit/indexed_db_dispatcher_host.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/chrome_thread.h" | 8 #include "chrome/browser/chrome_thread.h" |
| 9 #include "chrome/browser/in_process_webkit/indexed_db_callbacks.h" | 9 #include "chrome/browser/in_process_webkit/indexed_db_callbacks.h" |
| 10 #include "chrome/browser/renderer_host/browser_render_process_host.h" | 10 #include "chrome/browser/renderer_host/browser_render_process_host.h" |
| 11 #include "chrome/browser/renderer_host/resource_message_filter.h" | 11 #include "chrome/browser/renderer_host/resource_message_filter.h" |
| 12 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
| 13 #include "chrome/common/render_messages.h" | 13 #include "chrome/common/render_messages.h" |
| 14 #include "chrome/common/serialized_script_value.h" | 14 #include "chrome/common/serialized_script_value.h" |
| 15 #include "third_party/WebKit/WebKit/chromium/public/WebDOMStringList.h" | 15 #include "third_party/WebKit/WebKit/chromium/public/WebDOMStringList.h" |
| 16 #include "third_party/WebKit/WebKit/chromium/public/WebIDBCursor.h" | 16 #include "third_party/WebKit/WebKit/chromium/public/WebIDBCursor.h" |
| 17 #include "third_party/WebKit/WebKit/chromium/public/WebIDBDatabase.h" | 17 #include "third_party/WebKit/WebKit/chromium/public/WebIDBDatabase.h" |
| 18 #include "third_party/WebKit/WebKit/chromium/public/WebIDBDatabaseError.h" | 18 #include "third_party/WebKit/WebKit/chromium/public/WebIDBDatabaseError.h" |
| 19 #include "third_party/WebKit/WebKit/chromium/public/WebIDBKeyRange.h" | 19 #include "third_party/WebKit/WebKit/chromium/public/WebIDBKeyRange.h" |
| 20 #include "third_party/WebKit/WebKit/chromium/public/WebIDBIndex.h" | 20 #include "third_party/WebKit/WebKit/chromium/public/WebIDBIndex.h" |
| 21 #include "third_party/WebKit/WebKit/chromium/public/WebIDBFactory.h" | 21 #include "third_party/WebKit/WebKit/chromium/public/WebIDBFactory.h" |
| 22 #include "third_party/WebKit/WebKit/chromium/public/WebIDBObjectStore.h" | 22 #include "third_party/WebKit/WebKit/chromium/public/WebIDBObjectStore.h" |
| 23 #include "third_party/WebKit/WebKit/chromium/public/WebIDBTransaction.h" | |
| 24 #include "third_party/WebKit/WebKit/chromium/public/WebSecurityOrigin.h" | 23 #include "third_party/WebKit/WebKit/chromium/public/WebSecurityOrigin.h" |
| 25 #include "third_party/WebKit/WebKit/chromium/public/WebVector.h" | |
| 26 | 24 |
| 27 using WebKit::WebDOMStringList; | 25 using WebKit::WebDOMStringList; |
| 28 using WebKit::WebIDBCursor; | 26 using WebKit::WebIDBCursor; |
| 29 using WebKit::WebIDBDatabase; | 27 using WebKit::WebIDBDatabase; |
| 30 using WebKit::WebIDBDatabaseError; | 28 using WebKit::WebIDBDatabaseError; |
| 31 using WebKit::WebIDBIndex; | 29 using WebKit::WebIDBIndex; |
| 32 using WebKit::WebIDBKey; | 30 using WebKit::WebIDBKey; |
| 33 using WebKit::WebIDBKeyRange; | 31 using WebKit::WebIDBKeyRange; |
| 34 using WebKit::WebIDBObjectStore; | 32 using WebKit::WebIDBObjectStore; |
| 35 using WebKit::WebIDBTransaction; | |
| 36 using WebKit::WebSecurityOrigin; | 33 using WebKit::WebSecurityOrigin; |
| 37 using WebKit::WebSerializedScriptValue; | 34 using WebKit::WebSerializedScriptValue; |
| 38 using WebKit::WebVector; | |
| 39 | 35 |
| 40 IndexedDBDispatcherHost::IndexedDBDispatcherHost( | 36 IndexedDBDispatcherHost::IndexedDBDispatcherHost( |
| 41 IPC::Message::Sender* sender, WebKitContext* webkit_context) | 37 IPC::Message::Sender* sender, WebKitContext* webkit_context) |
| 42 : sender_(sender), | 38 : sender_(sender), |
| 43 webkit_context_(webkit_context), | 39 webkit_context_(webkit_context), |
| 44 ALLOW_THIS_IN_INITIALIZER_LIST(database_dispatcher_host_( | 40 ALLOW_THIS_IN_INITIALIZER_LIST(database_dispatcher_host_( |
| 45 new DatabaseDispatcherHost(this))), | 41 new DatabaseDispatcherHost(this))), |
| 46 ALLOW_THIS_IN_INITIALIZER_LIST(index_dispatcher_host_( | 42 ALLOW_THIS_IN_INITIALIZER_LIST(index_dispatcher_host_( |
| 47 new IndexDispatcherHost(this))), | 43 new IndexDispatcherHost(this))), |
| 48 ALLOW_THIS_IN_INITIALIZER_LIST(object_store_dispatcher_host_( | 44 ALLOW_THIS_IN_INITIALIZER_LIST(object_store_dispatcher_host_( |
| 49 new ObjectStoreDispatcherHost(this))), | 45 new ObjectStoreDispatcherHost(this))), |
| 50 ALLOW_THIS_IN_INITIALIZER_LIST(cursor_dispatcher_host_( | 46 ALLOW_THIS_IN_INITIALIZER_LIST(cursor_dispatcher_host_( |
| 51 new CursorDispatcherHost(this))), | 47 new CursorDispatcherHost(this))), |
| 52 ALLOW_THIS_IN_INITIALIZER_LIST(transaction_dispatcher_host_( | |
| 53 new TransactionDispatcherHost(this))), | |
| 54 process_handle_(0) { | 48 process_handle_(0) { |
| 55 DCHECK(sender_); | 49 DCHECK(sender_); |
| 56 DCHECK(webkit_context_.get()); | 50 DCHECK(webkit_context_.get()); |
| 57 } | 51 } |
| 58 | 52 |
| 59 IndexedDBDispatcherHost::~IndexedDBDispatcherHost() { | 53 IndexedDBDispatcherHost::~IndexedDBDispatcherHost() { |
| 60 } | 54 } |
| 61 | 55 |
| 62 void IndexedDBDispatcherHost::Init(int process_id, | 56 void IndexedDBDispatcherHost::Init(int process_id, |
| 63 base::ProcessHandle process_handle) { | 57 base::ProcessHandle process_handle) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 91 bool IndexedDBDispatcherHost::OnMessageReceived(const IPC::Message& message) { | 85 bool IndexedDBDispatcherHost::OnMessageReceived(const IPC::Message& message) { |
| 92 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); | 86 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); |
| 93 DCHECK(process_handle_); | 87 DCHECK(process_handle_); |
| 94 | 88 |
| 95 switch (message.type()) { | 89 switch (message.type()) { |
| 96 case ViewHostMsg_IDBCursorDestroyed::ID: | 90 case ViewHostMsg_IDBCursorDestroyed::ID: |
| 97 case ViewHostMsg_IDBCursorDirection::ID: | 91 case ViewHostMsg_IDBCursorDirection::ID: |
| 98 case ViewHostMsg_IDBCursorKey::ID: | 92 case ViewHostMsg_IDBCursorKey::ID: |
| 99 case ViewHostMsg_IDBCursorValue::ID: | 93 case ViewHostMsg_IDBCursorValue::ID: |
| 100 case ViewHostMsg_IDBFactoryOpen::ID: | 94 case ViewHostMsg_IDBFactoryOpen::ID: |
| 101 case ViewHostMsg_IDBFactoryAbortPendingTransactions::ID: | |
| 102 case ViewHostMsg_IDBDatabaseName::ID: | 95 case ViewHostMsg_IDBDatabaseName::ID: |
| 103 case ViewHostMsg_IDBDatabaseDescription::ID: | 96 case ViewHostMsg_IDBDatabaseDescription::ID: |
| 104 case ViewHostMsg_IDBDatabaseVersion::ID: | 97 case ViewHostMsg_IDBDatabaseVersion::ID: |
| 105 case ViewHostMsg_IDBDatabaseObjectStores::ID: | 98 case ViewHostMsg_IDBDatabaseObjectStores::ID: |
| 106 case ViewHostMsg_IDBDatabaseCreateObjectStore::ID: | 99 case ViewHostMsg_IDBDatabaseCreateObjectStore::ID: |
| 107 case ViewHostMsg_IDBDatabaseObjectStore::ID: | 100 case ViewHostMsg_IDBDatabaseObjectStore::ID: |
| 108 case ViewHostMsg_IDBDatabaseRemoveObjectStore::ID: | 101 case ViewHostMsg_IDBDatabaseRemoveObjectStore::ID: |
| 109 case ViewHostMsg_IDBDatabaseTransaction::ID: | |
| 110 case ViewHostMsg_IDBDatabaseDestroyed::ID: | 102 case ViewHostMsg_IDBDatabaseDestroyed::ID: |
| 111 case ViewHostMsg_IDBIndexName::ID: | 103 case ViewHostMsg_IDBIndexName::ID: |
| 112 case ViewHostMsg_IDBIndexKeyPath::ID: | 104 case ViewHostMsg_IDBIndexKeyPath::ID: |
| 113 case ViewHostMsg_IDBIndexUnique::ID: | 105 case ViewHostMsg_IDBIndexUnique::ID: |
| 114 case ViewHostMsg_IDBIndexDestroyed::ID: | 106 case ViewHostMsg_IDBIndexDestroyed::ID: |
| 115 case ViewHostMsg_IDBObjectStoreName::ID: | 107 case ViewHostMsg_IDBObjectStoreName::ID: |
| 116 case ViewHostMsg_IDBObjectStoreKeyPath::ID: | 108 case ViewHostMsg_IDBObjectStoreKeyPath::ID: |
| 117 case ViewHostMsg_IDBObjectStoreIndexNames::ID: | 109 case ViewHostMsg_IDBObjectStoreIndexNames::ID: |
| 118 case ViewHostMsg_IDBObjectStoreGet::ID: | 110 case ViewHostMsg_IDBObjectStoreGet::ID: |
| 119 case ViewHostMsg_IDBObjectStoreOpenCursor::ID: | 111 case ViewHostMsg_IDBObjectStoreOpenCursor::ID: |
| 120 case ViewHostMsg_IDBObjectStorePut::ID: | 112 case ViewHostMsg_IDBObjectStorePut::ID: |
| 121 case ViewHostMsg_IDBObjectStoreRemove::ID: | 113 case ViewHostMsg_IDBObjectStoreRemove::ID: |
| 122 case ViewHostMsg_IDBObjectStoreCreateIndex::ID: | 114 case ViewHostMsg_IDBObjectStoreCreateIndex::ID: |
| 123 case ViewHostMsg_IDBObjectStoreIndex::ID: | 115 case ViewHostMsg_IDBObjectStoreIndex::ID: |
| 124 case ViewHostMsg_IDBObjectStoreRemoveIndex::ID: | 116 case ViewHostMsg_IDBObjectStoreRemoveIndex::ID: |
| 125 case ViewHostMsg_IDBObjectStoreDestroyed::ID: | 117 case ViewHostMsg_IDBObjectStoreDestroyed::ID: |
| 126 case ViewHostMsg_IDBTransactionDestroyed::ID: | |
| 127 break; | 118 break; |
| 128 default: | 119 default: |
| 129 return false; | 120 return false; |
| 130 } | 121 } |
| 131 | 122 |
| 132 bool success = ChromeThread::PostTask( | 123 bool success = ChromeThread::PostTask( |
| 133 ChromeThread::WEBKIT, FROM_HERE, NewRunnableMethod( | 124 ChromeThread::WEBKIT, FROM_HERE, NewRunnableMethod( |
| 134 this, &IndexedDBDispatcherHost::OnMessageReceivedWebKit, message)); | 125 this, &IndexedDBDispatcherHost::OnMessageReceivedWebKit, message)); |
| 135 DCHECK(success); | 126 DCHECK(success); |
| 136 return true; | 127 return true; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 161 void IndexedDBDispatcherHost::OnMessageReceivedWebKit( | 152 void IndexedDBDispatcherHost::OnMessageReceivedWebKit( |
| 162 const IPC::Message& message) { | 153 const IPC::Message& message) { |
| 163 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)); | 154 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)); |
| 164 DCHECK(process_handle_); | 155 DCHECK(process_handle_); |
| 165 | 156 |
| 166 bool msg_is_ok = true; | 157 bool msg_is_ok = true; |
| 167 bool handled = | 158 bool handled = |
| 168 database_dispatcher_host_->OnMessageReceived(message, &msg_is_ok) || | 159 database_dispatcher_host_->OnMessageReceived(message, &msg_is_ok) || |
| 169 index_dispatcher_host_->OnMessageReceived(message, &msg_is_ok) || | 160 index_dispatcher_host_->OnMessageReceived(message, &msg_is_ok) || |
| 170 object_store_dispatcher_host_->OnMessageReceived(message, &msg_is_ok) || | 161 object_store_dispatcher_host_->OnMessageReceived(message, &msg_is_ok) || |
| 171 cursor_dispatcher_host_->OnMessageReceived(message, &msg_is_ok) || | 162 cursor_dispatcher_host_->OnMessageReceived(message, &msg_is_ok); |
| 172 transaction_dispatcher_host_->OnMessageReceived(message, &msg_is_ok); | |
| 173 | 163 |
| 174 if (!handled) { | 164 if (!handled) { |
| 175 handled = true; | 165 handled = true; |
| 176 DCHECK(msg_is_ok); | 166 DCHECK(msg_is_ok); |
| 177 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost, message, msg_is_ok) | 167 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost, message, msg_is_ok) |
| 178 IPC_MESSAGE_HANDLER(ViewHostMsg_IDBFactoryOpen, | 168 IPC_MESSAGE_HANDLER(ViewHostMsg_IDBFactoryOpen, |
| 179 OnIDBFactoryOpen) | 169 OnIDBFactoryOpen) |
| 180 IPC_MESSAGE_HANDLER(ViewHostMsg_IDBFactoryAbortPendingTransactions, | |
| 181 OnIDBFactoryAbortPendingTransactions) | |
| 182 IPC_MESSAGE_UNHANDLED(handled = false) | 170 IPC_MESSAGE_UNHANDLED(handled = false) |
| 183 IPC_END_MESSAGE_MAP() | 171 IPC_END_MESSAGE_MAP() |
| 184 } | 172 } |
| 185 | 173 |
| 186 DCHECK(handled); | 174 DCHECK(handled); |
| 187 if (!msg_is_ok) { | 175 if (!msg_is_ok) { |
| 188 BrowserRenderProcessHost::BadMessageTerminateProcess(message.type(), | 176 BrowserRenderProcessHost::BadMessageTerminateProcess(message.type(), |
| 189 process_handle_); | 177 process_handle_); |
| 190 } | 178 } |
| 191 } | 179 } |
| 192 | 180 |
| 193 int32 IndexedDBDispatcherHost::Add(WebIDBCursor* idb_cursor) { | 181 int32 IndexedDBDispatcherHost::Add(WebIDBCursor* idb_cursor) { |
| 194 return cursor_dispatcher_host_->map_.Add(idb_cursor); | 182 return cursor_dispatcher_host_->map_.Add(idb_cursor); |
| 195 } | 183 } |
| 196 | 184 |
| 197 int32 IndexedDBDispatcherHost::Add(WebIDBDatabase* idb_database) { | 185 int32 IndexedDBDispatcherHost::Add(WebIDBDatabase* idb_database) { |
| 198 return database_dispatcher_host_->map_.Add(idb_database); | 186 return database_dispatcher_host_->map_.Add(idb_database); |
| 199 } | 187 } |
| 200 | 188 |
| 201 int32 IndexedDBDispatcherHost::Add(WebIDBIndex* idb_index) { | 189 int32 IndexedDBDispatcherHost::Add(WebIDBIndex* idb_index) { |
| 202 return index_dispatcher_host_->map_.Add(idb_index); | 190 return index_dispatcher_host_->map_.Add(idb_index); |
| 203 } | 191 } |
| 204 | 192 |
| 205 int32 IndexedDBDispatcherHost::Add(WebIDBObjectStore* idb_object_store) { | 193 int32 IndexedDBDispatcherHost::Add(WebIDBObjectStore* idb_object_store) { |
| 206 return object_store_dispatcher_host_->map_.Add(idb_object_store); | 194 return object_store_dispatcher_host_->map_.Add(idb_object_store); |
| 207 } | 195 } |
| 208 | 196 |
| 209 void IndexedDBDispatcherHost::Add(WebIDBTransaction* idb_transaction) { | |
| 210 transaction_dispatcher_host_->map_.AddWithID( | |
| 211 idb_transaction, idb_transaction->id()); | |
| 212 } | |
| 213 | |
| 214 void IndexedDBDispatcherHost::OnIDBFactoryOpen( | 197 void IndexedDBDispatcherHost::OnIDBFactoryOpen( |
| 215 const ViewHostMsg_IDBFactoryOpen_Params& params) { | 198 const ViewHostMsg_IDBFactoryOpen_Params& params) { |
| 216 // TODO(jorlow): Check the content settings map and use params.routing_id_ | 199 // TODO(jorlow): Check the content settings map and use params.routing_id_ |
| 217 // if it's necessary to ask the user for permission. | 200 // if it's necessary to ask the user for permission. |
| 218 | 201 |
| 219 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)); | 202 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)); |
| 220 Context()->GetIDBFactory()->open( | 203 Context()->GetIDBFactory()->open( |
| 221 params.name_, params.description_, | 204 params.name_, params.description_, |
| 222 new IndexedDBCallbacks<WebIDBDatabase>(this, params.response_id_), | 205 new IndexedDBCallbacks<WebIDBDatabase>(this, params.response_id_), |
| 223 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin_), NULL); | 206 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin_), NULL); |
| 224 } | 207 } |
| 225 | 208 |
| 226 void IndexedDBDispatcherHost::OnIDBFactoryAbortPendingTransactions( | |
| 227 const std::vector<int32>& ids) { | |
| 228 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)); | |
| 229 | |
| 230 WebVector<int32> pendingIDs = ids; | |
| 231 Context()->GetIDBFactory()->abortPendingTransactions(pendingIDs); | |
| 232 } | |
| 233 | |
| 234 ////////////////////////////////////////////////////////////////////// | 209 ////////////////////////////////////////////////////////////////////// |
| 235 // Helper templates. | 210 // Helper templates. |
| 236 // | 211 // |
| 237 | 212 |
| 238 template <typename ObjectType> | 213 template <typename ObjectType> |
| 239 ObjectType* IndexedDBDispatcherHost::GetOrTerminateProcess( | 214 ObjectType* IndexedDBDispatcherHost::GetOrTerminateProcess( |
| 240 IDMap<ObjectType, IDMapOwnPointer>* map, int32 return_object_id, | 215 IDMap<ObjectType, IDMapOwnPointer>* map, int32 return_object_id, |
| 241 IPC::Message* reply_msg, uint32 message_type) { | 216 IPC::Message* reply_msg, uint32 message_type) { |
| 242 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)); | 217 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)); |
| 243 ObjectType* return_object = map->Lookup(return_object_id); | 218 ObjectType* return_object = map->Lookup(return_object_id); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 OnDescription) | 270 OnDescription) |
| 296 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBDatabaseVersion, OnVersion) | 271 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBDatabaseVersion, OnVersion) |
| 297 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBDatabaseObjectStores, | 272 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBDatabaseObjectStores, |
| 298 OnObjectStores) | 273 OnObjectStores) |
| 299 IPC_MESSAGE_HANDLER(ViewHostMsg_IDBDatabaseCreateObjectStore, | 274 IPC_MESSAGE_HANDLER(ViewHostMsg_IDBDatabaseCreateObjectStore, |
| 300 OnCreateObjectStore) | 275 OnCreateObjectStore) |
| 301 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBDatabaseObjectStore, | 276 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBDatabaseObjectStore, |
| 302 OnObjectStore) | 277 OnObjectStore) |
| 303 IPC_MESSAGE_HANDLER(ViewHostMsg_IDBDatabaseRemoveObjectStore, | 278 IPC_MESSAGE_HANDLER(ViewHostMsg_IDBDatabaseRemoveObjectStore, |
| 304 OnRemoveObjectStore) | 279 OnRemoveObjectStore) |
| 305 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBDatabaseTransaction, | |
| 306 OnTransaction) | |
| 307 IPC_MESSAGE_HANDLER(ViewHostMsg_IDBDatabaseDestroyed, OnDestroyed) | 280 IPC_MESSAGE_HANDLER(ViewHostMsg_IDBDatabaseDestroyed, OnDestroyed) |
| 308 IPC_MESSAGE_UNHANDLED(handled = false) | 281 IPC_MESSAGE_UNHANDLED(handled = false) |
| 309 IPC_END_MESSAGE_MAP() | 282 IPC_END_MESSAGE_MAP() |
| 310 return handled; | 283 return handled; |
| 311 } | 284 } |
| 312 | 285 |
| 313 void IndexedDBDispatcherHost::DatabaseDispatcherHost::Send( | 286 void IndexedDBDispatcherHost::DatabaseDispatcherHost::Send( |
| 314 IPC::Message* message) { | 287 IPC::Message* message) { |
| 315 // The macro magic in OnMessageReceived requires this to link, but it should | 288 // The macro magic in OnMessageReceived requires this to link, but it should |
| 316 // never actually be called. | 289 // never actually be called. |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)); | 361 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)); |
| 389 WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess( | 362 WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess( |
| 390 &map_, idb_database_id, NULL, | 363 &map_, idb_database_id, NULL, |
| 391 ViewHostMsg_IDBDatabaseRemoveObjectStore::ID); | 364 ViewHostMsg_IDBDatabaseRemoveObjectStore::ID); |
| 392 if (!idb_database) | 365 if (!idb_database) |
| 393 return; | 366 return; |
| 394 idb_database->removeObjectStore( | 367 idb_database->removeObjectStore( |
| 395 name, new IndexedDBCallbacks<WebIDBObjectStore>(parent_, response_id)); | 368 name, new IndexedDBCallbacks<WebIDBObjectStore>(parent_, response_id)); |
| 396 } | 369 } |
| 397 | 370 |
| 398 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnTransaction( | |
| 399 int32 idb_database_id, const std::vector<string16>& names, | |
| 400 int32 mode, int32 timeout, IPC::Message* reply_msg) { | |
| 401 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | |
| 402 &map_, idb_database_id, reply_msg, | |
| 403 ViewHostMsg_IDBDatabaseTransaction::ID); | |
| 404 if (!database) | |
| 405 return; | |
| 406 | |
| 407 WebDOMStringList object_stores; | |
| 408 for (std::vector<string16>::const_iterator it = names.begin(); | |
| 409 it != names.end(); ++it) { | |
| 410 object_stores.append(*it); | |
| 411 } | |
| 412 | |
| 413 WebIDBTransaction* transaction = database->transaction( | |
| 414 object_stores, mode, timeout); | |
| 415 transaction->setCallbacks( | |
| 416 new IndexedDBTransactionCallbacks(parent_, transaction->id())); | |
| 417 parent_->Add(transaction); | |
| 418 ViewHostMsg_IDBDatabaseTransaction::WriteReplyParams( | |
| 419 reply_msg, transaction->id()); | |
| 420 parent_->Send(reply_msg); | |
| 421 } | |
| 422 | |
| 423 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDestroyed( | 371 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDestroyed( |
| 424 int32 object_id) { | 372 int32 object_id) { |
| 425 parent_->DestroyObject(&map_, object_id, | 373 parent_->DestroyObject(&map_, object_id, |
| 426 ViewHostMsg_IDBDatabaseDestroyed::ID); | 374 ViewHostMsg_IDBDatabaseDestroyed::ID); |
| 427 } | 375 } |
| 428 | 376 |
| 429 | 377 |
| 430 ////////////////////////////////////////////////////////////////////// | 378 ////////////////////////////////////////////////////////////////////// |
| 431 // IndexedDBDispatcherHost::IndexDispatcherHost | 379 // IndexedDBDispatcherHost::IndexDispatcherHost |
| 432 // | 380 // |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBCursorDirection, | 608 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBCursorDirection, |
| 661 OnDirection) | 609 OnDirection) |
| 662 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBCursorKey, OnKey) | 610 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBCursorKey, OnKey) |
| 663 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBCursorValue, OnValue) | 611 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBCursorValue, OnValue) |
| 664 IPC_MESSAGE_HANDLER(ViewHostMsg_IDBCursorDestroyed, OnDestroyed) | 612 IPC_MESSAGE_HANDLER(ViewHostMsg_IDBCursorDestroyed, OnDestroyed) |
| 665 IPC_MESSAGE_UNHANDLED(handled = false) | 613 IPC_MESSAGE_UNHANDLED(handled = false) |
| 666 IPC_END_MESSAGE_MAP() | 614 IPC_END_MESSAGE_MAP() |
| 667 return handled; | 615 return handled; |
| 668 } | 616 } |
| 669 | 617 |
| 670 | |
| 671 void IndexedDBDispatcherHost::CursorDispatcherHost::Send( | 618 void IndexedDBDispatcherHost::CursorDispatcherHost::Send( |
| 672 IPC::Message* message) { | 619 IPC::Message* message) { |
| 673 // The macro magic in OnMessageReceived requires this to link, but it should | 620 // The macro magic in OnMessageReceived requires this to link, but it should |
| 674 // never actually be called. | 621 // never actually be called. |
| 675 NOTREACHED(); | 622 NOTREACHED(); |
| 676 parent_->Send(message); | 623 parent_->Send(message); |
| 677 } | 624 } |
| 678 | 625 |
| 679 void IndexedDBDispatcherHost::CursorDispatcherHost::OnOpenCursor( | 626 void IndexedDBDispatcherHost::CursorDispatcherHost::OnOpenCursor( |
| 680 const ViewHostMsg_IDBObjectStoreOpenCursor_Params& params) { | 627 const ViewHostMsg_IDBObjectStoreOpenCursor_Params& params) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 728 SerializedScriptValue value(idb_cursor->value()); | 675 SerializedScriptValue value(idb_cursor->value()); |
| 729 ViewHostMsg_IDBCursorValue::WriteReplyParams(reply_msg, value); | 676 ViewHostMsg_IDBCursorValue::WriteReplyParams(reply_msg, value); |
| 730 parent_->Send(reply_msg); | 677 parent_->Send(reply_msg); |
| 731 } | 678 } |
| 732 | 679 |
| 733 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( | 680 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( |
| 734 int32 object_id) { | 681 int32 object_id) { |
| 735 parent_->DestroyObject( | 682 parent_->DestroyObject( |
| 736 &map_, object_id, ViewHostMsg_IDBCursorDestroyed::ID); | 683 &map_, object_id, ViewHostMsg_IDBCursorDestroyed::ID); |
| 737 } | 684 } |
| 738 | |
| 739 ////////////////////////////////////////////////////////////////////// | |
| 740 // IndexedDBDispatcherHost::TransactionDispatcherHost | |
| 741 // | |
| 742 | |
| 743 IndexedDBDispatcherHost::TransactionDispatcherHost::TransactionDispatcherHost( | |
| 744 IndexedDBDispatcherHost* parent) | |
| 745 : parent_(parent) { | |
| 746 } | |
| 747 | |
| 748 IndexedDBDispatcherHost:: | |
| 749 TransactionDispatcherHost::~TransactionDispatcherHost() { | |
| 750 } | |
| 751 | |
| 752 bool IndexedDBDispatcherHost::TransactionDispatcherHost::OnMessageReceived( | |
| 753 const IPC::Message& message, bool* msg_is_ok) { | |
| 754 bool handled = true; | |
| 755 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::TransactionDispatcherHost, | |
| 756 message, *msg_is_ok) | |
| 757 IPC_MESSAGE_HANDLER(ViewHostMsg_IDBTransactionDestroyed, OnDestroyed) | |
| 758 IPC_MESSAGE_UNHANDLED(handled = false) | |
| 759 IPC_END_MESSAGE_MAP() | |
| 760 return handled; | |
| 761 } | |
| 762 | |
| 763 void IndexedDBDispatcherHost::TransactionDispatcherHost::Send( | |
| 764 IPC::Message* message) { | |
| 765 // The macro magic in OnMessageReceived requires this to link, but it should | |
| 766 // never actually be called. | |
| 767 NOTREACHED(); | |
| 768 parent_->Send(message); | |
| 769 } | |
| 770 | |
| 771 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( | |
| 772 int32 object_id) { | |
| 773 parent_->DestroyObject( | |
| 774 &map_, object_id, ViewHostMsg_IDBTransactionDestroyed::ID); | |
| 775 } | |
| OLD | NEW |