| OLD | NEW |
| 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> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 message, message_was_ok) || | 132 message, message_was_ok) || |
| 133 cursor_dispatcher_host_->OnMessageReceived(message, message_was_ok) || | 133 cursor_dispatcher_host_->OnMessageReceived(message, message_was_ok) || |
| 134 transaction_dispatcher_host_->OnMessageReceived(message, message_was_ok); | 134 transaction_dispatcher_host_->OnMessageReceived(message, message_was_ok); |
| 135 | 135 |
| 136 if (!handled) { | 136 if (!handled) { |
| 137 handled = true; | 137 handled = true; |
| 138 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost, message, *message_was_ok) | 138 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost, message, *message_was_ok) |
| 139 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryGetDatabaseNames, | 139 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryGetDatabaseNames, |
| 140 OnIDBFactoryGetDatabaseNames) | 140 OnIDBFactoryGetDatabaseNames) |
| 141 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryOpen, OnIDBFactoryOpen) | 141 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryOpen, OnIDBFactoryOpen) |
| 142 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryOpenLegacy, | |
| 143 OnIDBFactoryOpenLegacy) | |
| 144 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryDeleteDatabase, | 142 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryDeleteDatabase, |
| 145 OnIDBFactoryDeleteDatabase) | 143 OnIDBFactoryDeleteDatabase) |
| 146 IPC_MESSAGE_UNHANDLED(handled = false) | 144 IPC_MESSAGE_UNHANDLED(handled = false) |
| 147 IPC_END_MESSAGE_MAP() | 145 IPC_END_MESSAGE_MAP() |
| 148 } | 146 } |
| 149 | 147 |
| 150 return handled; | 148 return handled; |
| 151 } | 149 } |
| 152 | 150 |
| 153 int32 IndexedDBDispatcherHost::Add(WebIDBCursor* idb_cursor) { | 151 int32 IndexedDBDispatcherHost::Add(WebIDBCursor* idb_cursor) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 | 215 |
| 218 WebSecurityOrigin origin( | 216 WebSecurityOrigin origin( |
| 219 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin)); | 217 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin)); |
| 220 | 218 |
| 221 Context()->GetIDBFactory()->getDatabaseNames( | 219 Context()->GetIDBFactory()->getDatabaseNames( |
| 222 new IndexedDBCallbacks<WebDOMStringList>(this, params.thread_id, | 220 new IndexedDBCallbacks<WebDOMStringList>(this, params.thread_id, |
| 223 params.response_id), origin, NULL, | 221 params.response_id), origin, NULL, |
| 224 webkit_glue::FilePathToWebString(indexed_db_path)); | 222 webkit_glue::FilePathToWebString(indexed_db_path)); |
| 225 } | 223 } |
| 226 | 224 |
| 227 // TODO(jsbell): Remove once WK90411 has rolled. | |
| 228 void IndexedDBDispatcherHost::OnIDBFactoryOpenLegacy( | |
| 229 const IndexedDBHostMsg_FactoryOpen_Params& params) { | |
| 230 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | |
| 231 FilePath indexed_db_path = indexed_db_context_->data_path(); | |
| 232 | |
| 233 GURL origin_url = DatabaseUtil::GetOriginFromIdentifier(params.origin); | |
| 234 WebSecurityOrigin origin( | |
| 235 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin)); | |
| 236 | |
| 237 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | |
| 238 | |
| 239 // TODO(dgrogan): Don't let a non-existing database be opened (and therefore | |
| 240 // created) if this origin is already over quota. | |
| 241 Context()->GetIDBFactory()->open( | |
| 242 params.name, | |
| 243 params.version, | |
| 244 new IndexedDBCallbacksDatabase(this, params.thread_id, | |
| 245 params.response_id, origin_url), | |
| 246 origin, NULL, webkit_glue::FilePathToWebString(indexed_db_path)); | |
| 247 } | |
| 248 | |
| 249 void IndexedDBDispatcherHost::OnIDBFactoryOpen( | 225 void IndexedDBDispatcherHost::OnIDBFactoryOpen( |
| 250 const IndexedDBHostMsg_FactoryOpen_Params& params) { | 226 const IndexedDBHostMsg_FactoryOpen_Params& params) { |
| 251 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 227 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 252 FilePath indexed_db_path = indexed_db_context_->data_path(); | 228 FilePath indexed_db_path = indexed_db_context_->data_path(); |
| 253 | 229 |
| 254 GURL origin_url = DatabaseUtil::GetOriginFromIdentifier(params.origin); | 230 GURL origin_url = DatabaseUtil::GetOriginFromIdentifier(params.origin); |
| 255 WebSecurityOrigin origin( | 231 WebSecurityOrigin origin( |
| 256 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin)); | 232 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin)); |
| 257 | 233 |
| 258 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 234 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::DatabaseDispatcherHost, | 316 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::DatabaseDispatcherHost, |
| 341 message, *msg_is_ok) | 317 message, *msg_is_ok) |
| 342 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseMetadata, OnMetadata) | 318 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseMetadata, OnMetadata) |
| 343 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateObjectStore, | 319 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateObjectStore, |
| 344 OnCreateObjectStore) | 320 OnCreateObjectStore) |
| 345 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteObjectStore, | 321 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteObjectStore, |
| 346 OnDeleteObjectStore) | 322 OnDeleteObjectStore) |
| 347 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetVersion, OnSetVersion) | 323 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetVersion, OnSetVersion) |
| 348 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseTransaction, OnTransaction) | 324 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseTransaction, OnTransaction) |
| 349 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClose, OnClose) | 325 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClose, OnClose) |
| 350 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseOpen, OnOpen) | |
| 351 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDestroyed, OnDestroyed) | 326 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDestroyed, OnDestroyed) |
| 352 IPC_MESSAGE_UNHANDLED(handled = false) | 327 IPC_MESSAGE_UNHANDLED(handled = false) |
| 353 IPC_END_MESSAGE_MAP() | 328 IPC_END_MESSAGE_MAP() |
| 354 return handled; | 329 return handled; |
| 355 } | 330 } |
| 356 | 331 |
| 357 void IndexedDBDispatcherHost::DatabaseDispatcherHost::Send( | 332 void IndexedDBDispatcherHost::DatabaseDispatcherHost::Send( |
| 358 IPC::Message* message) { | 333 IPC::Message* message) { |
| 359 parent_->Send(message); | 334 parent_->Send(message); |
| 360 } | 335 } |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 | 447 |
| 473 *ec = 0; | 448 *ec = 0; |
| 474 WebIDBTransaction* transaction = database->transaction( | 449 WebIDBTransaction* transaction = database->transaction( |
| 475 object_stores, mode, *ec); | 450 object_stores, mode, *ec); |
| 476 DCHECK(!transaction != !*ec); | 451 DCHECK(!transaction != !*ec); |
| 477 *idb_transaction_id = | 452 *idb_transaction_id = |
| 478 *ec ? 0 : parent_->Add(transaction, thread_id, | 453 *ec ? 0 : parent_->Add(transaction, thread_id, |
| 479 database_url_map_[idb_database_id]); | 454 database_url_map_[idb_database_id]); |
| 480 } | 455 } |
| 481 | 456 |
| 482 // TODO(jsbell): Remove once WK90411 has rolled. | |
| 483 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnOpen( | |
| 484 int32 idb_database_id, int32 thread_id, int32 response_id) { | |
| 485 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | |
| 486 &map_, idb_database_id); | |
| 487 if (!database) | |
| 488 return; | |
| 489 database->open(new IndexedDBDatabaseCallbacks(parent_, thread_id, | |
| 490 response_id)); | |
| 491 } | |
| 492 | |
| 493 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnClose( | 457 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnClose( |
| 494 int32 idb_database_id) { | 458 int32 idb_database_id) { |
| 495 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | 459 WebIDBDatabase* database = parent_->GetOrTerminateProcess( |
| 496 &map_, idb_database_id); | 460 &map_, idb_database_id); |
| 497 if (!database) | 461 if (!database) |
| 498 return; | 462 return; |
| 499 database->close(); | 463 database->close(); |
| 500 } | 464 } |
| 501 | 465 |
| 502 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDestroyed( | 466 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDestroyed( |
| (...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1137 } | 1101 } |
| 1138 | 1102 |
| 1139 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( | 1103 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( |
| 1140 int32 object_id) { | 1104 int32 object_id) { |
| 1141 // TODO(dgrogan): This doesn't seem to be happening with some version change | 1105 // TODO(dgrogan): This doesn't seem to be happening with some version change |
| 1142 // transactions. Possibly introduced with integer version support. | 1106 // transactions. Possibly introduced with integer version support. |
| 1143 transaction_size_map_.erase(object_id); | 1107 transaction_size_map_.erase(object_id); |
| 1144 transaction_url_map_.erase(object_id); | 1108 transaction_url_map_.erase(object_id); |
| 1145 parent_->DestroyObject(&map_, object_id); | 1109 parent_->DestroyObject(&map_, object_id); |
| 1146 } | 1110 } |
| OLD | NEW |