| 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/indexed_db/indexed_db_dispatcher_host.h" | 5 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 metadata.object_stores.push_back(idb_store_metadata); | 305 metadata.object_stores.push_back(idb_store_metadata); |
| 306 } | 306 } |
| 307 return metadata; | 307 return metadata; |
| 308 } | 308 } |
| 309 | 309 |
| 310 void IndexedDBDispatcherHost::OnIDBFactoryGetDatabaseNames( | 310 void IndexedDBDispatcherHost::OnIDBFactoryGetDatabaseNames( |
| 311 const IndexedDBHostMsg_FactoryGetDatabaseNames_Params& params) { | 311 const IndexedDBHostMsg_FactoryGetDatabaseNames_Params& params) { |
| 312 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 312 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
| 313 base::FilePath indexed_db_path = indexed_db_context_->data_path(); | 313 base::FilePath indexed_db_path = indexed_db_context_->data_path(); |
| 314 | 314 |
| 315 GURL origin_url = | |
| 316 storage::GetOriginFromIdentifier(params.database_identifier); | |
| 317 | |
| 318 context()->GetIDBFactory()->GetDatabaseNames( | 315 context()->GetIDBFactory()->GetDatabaseNames( |
| 319 new IndexedDBCallbacks(this, params.ipc_thread_id, | 316 new IndexedDBCallbacks(this, params.ipc_thread_id, |
| 320 params.ipc_callbacks_id), | 317 params.ipc_callbacks_id), |
| 321 origin_url, indexed_db_path, request_context_); | 318 params.origin, indexed_db_path, request_context_); |
| 322 } | 319 } |
| 323 | 320 |
| 324 void IndexedDBDispatcherHost::OnIDBFactoryOpen( | 321 void IndexedDBDispatcherHost::OnIDBFactoryOpen( |
| 325 const IndexedDBHostMsg_FactoryOpen_Params& params) { | 322 const IndexedDBHostMsg_FactoryOpen_Params& params) { |
| 326 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 323 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
| 327 base::TimeTicks begin_time = base::TimeTicks::Now(); | 324 base::TimeTicks begin_time = base::TimeTicks::Now(); |
| 328 base::FilePath indexed_db_path = indexed_db_context_->data_path(); | 325 base::FilePath indexed_db_path = indexed_db_context_->data_path(); |
| 329 | 326 |
| 330 GURL origin_url = | |
| 331 storage::GetOriginFromIdentifier(params.database_identifier); | |
| 332 | |
| 333 int64_t host_transaction_id = HostTransactionId(params.transaction_id); | 327 int64_t host_transaction_id = HostTransactionId(params.transaction_id); |
| 334 | 328 |
| 335 // TODO(dgrogan): Don't let a non-existing database be opened (and therefore | 329 // TODO(dgrogan): Don't let a non-existing database be opened (and therefore |
| 336 // created) if this origin is already over quota. | 330 // created) if this origin is already over quota. |
| 337 scoped_refptr<IndexedDBCallbacks> callbacks = | 331 scoped_refptr<IndexedDBCallbacks> callbacks = new IndexedDBCallbacks( |
| 338 new IndexedDBCallbacks(this, | 332 this, params.ipc_thread_id, params.ipc_callbacks_id, |
| 339 params.ipc_thread_id, | 333 params.ipc_database_callbacks_id, host_transaction_id, params.origin); |
| 340 params.ipc_callbacks_id, | |
| 341 params.ipc_database_callbacks_id, | |
| 342 host_transaction_id, | |
| 343 origin_url); | |
| 344 callbacks->SetConnectionOpenStartTime(begin_time); | 334 callbacks->SetConnectionOpenStartTime(begin_time); |
| 345 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks = | 335 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks = |
| 346 new IndexedDBDatabaseCallbacks( | 336 new IndexedDBDatabaseCallbacks( |
| 347 this, params.ipc_thread_id, params.ipc_database_callbacks_id); | 337 this, params.ipc_thread_id, params.ipc_database_callbacks_id); |
| 348 IndexedDBPendingConnection connection(callbacks, | 338 IndexedDBPendingConnection connection(callbacks, |
| 349 database_callbacks, | 339 database_callbacks, |
| 350 ipc_process_id_, | 340 ipc_process_id_, |
| 351 host_transaction_id, | 341 host_transaction_id, |
| 352 params.version); | 342 params.version); |
| 353 DCHECK(request_context_); | 343 DCHECK(request_context_); |
| 354 context()->GetIDBFactory()->Open(params.name, connection, request_context_, | 344 context()->GetIDBFactory()->Open(params.name, connection, request_context_, |
| 355 origin_url, indexed_db_path); | 345 params.origin, indexed_db_path); |
| 356 } | 346 } |
| 357 | 347 |
| 358 void IndexedDBDispatcherHost::OnIDBFactoryDeleteDatabase( | 348 void IndexedDBDispatcherHost::OnIDBFactoryDeleteDatabase( |
| 359 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& params) { | 349 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& params) { |
| 360 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 350 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
| 361 GURL origin_url = | |
| 362 storage::GetOriginFromIdentifier(params.database_identifier); | |
| 363 base::FilePath indexed_db_path = indexed_db_context_->data_path(); | 351 base::FilePath indexed_db_path = indexed_db_context_->data_path(); |
| 364 DCHECK(request_context_); | 352 DCHECK(request_context_); |
| 365 context()->GetIDBFactory()->DeleteDatabase( | 353 context()->GetIDBFactory()->DeleteDatabase( |
| 366 params.name, request_context_, | 354 params.name, request_context_, |
| 367 new IndexedDBCallbacks(this, params.ipc_thread_id, | 355 new IndexedDBCallbacks(this, params.ipc_thread_id, |
| 368 params.ipc_callbacks_id), | 356 params.ipc_callbacks_id), |
| 369 origin_url, indexed_db_path); | 357 params.origin, indexed_db_path); |
| 370 } | 358 } |
| 371 | 359 |
| 372 // OnPutHelper exists only to allow us to hop threads while holding a reference | 360 // OnPutHelper exists only to allow us to hop threads while holding a reference |
| 373 // to the IndexedDBDispatcherHost. | 361 // to the IndexedDBDispatcherHost. |
| 374 void IndexedDBDispatcherHost::OnPutHelper( | 362 void IndexedDBDispatcherHost::OnPutHelper( |
| 375 const IndexedDBHostMsg_DatabasePut_Params& params, | 363 const IndexedDBHostMsg_DatabasePut_Params& params, |
| 376 std::vector<storage::BlobDataHandle*> handles) { | 364 std::vector<storage::BlobDataHandle*> handles) { |
| 377 database_dispatcher_host_->OnPut(params, handles); | 365 database_dispatcher_host_->OnPut(params, handles); |
| 378 } | 366 } |
| 379 | 367 |
| (...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1040 DLOG(ERROR) << "Unable to reset prefetch"; | 1028 DLOG(ERROR) << "Unable to reset prefetch"; |
| 1041 } | 1029 } |
| 1042 | 1030 |
| 1043 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( | 1031 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( |
| 1044 int32_t ipc_object_id) { | 1032 int32_t ipc_object_id) { |
| 1045 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread()); | 1033 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread()); |
| 1046 parent_->DestroyObject(&map_, ipc_object_id); | 1034 parent_->DestroyObject(&map_, ipc_object_id); |
| 1047 } | 1035 } |
| 1048 | 1036 |
| 1049 } // namespace content | 1037 } // namespace content |
| OLD | NEW |