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