| 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" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/guid.h" | 12 #include "base/guid.h" |
| 13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 14 #include "base/process/process.h" | 14 #include "base/process/process.h" |
| 15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 17 #include "content/browser/bad_message.h" | 17 #include "content/browser/bad_message.h" |
| 18 #include "content/browser/child_process_security_policy_impl.h" | 18 #include "content/browser/child_process_security_policy_impl.h" |
| 19 #include "content/browser/indexed_db/indexed_db_callbacks.h" | 19 #include "content/browser/indexed_db/indexed_db_callbacks.h" |
| 20 #include "content/browser/indexed_db/indexed_db_connection.h" | 20 #include "content/browser/indexed_db/indexed_db_connection.h" |
| 21 #include "content/browser/indexed_db/indexed_db_context_impl.h" | 21 #include "content/browser/indexed_db/indexed_db_context_impl.h" |
| 22 #include "content/browser/indexed_db/indexed_db_cursor.h" | 22 #include "content/browser/indexed_db/indexed_db_cursor.h" |
| 23 #include "content/browser/indexed_db/indexed_db_database_callbacks.h" | 23 #include "content/browser/indexed_db/indexed_db_database_callbacks.h" |
| 24 #include "content/browser/indexed_db/indexed_db_metadata.h" | |
| 25 #include "content/browser/indexed_db/indexed_db_observation.h" | 24 #include "content/browser/indexed_db/indexed_db_observation.h" |
| 26 #include "content/browser/indexed_db/indexed_db_observer_changes.h" | 25 #include "content/browser/indexed_db/indexed_db_observer_changes.h" |
| 27 #include "content/browser/indexed_db/indexed_db_pending_connection.h" | 26 #include "content/browser/indexed_db/indexed_db_pending_connection.h" |
| 28 #include "content/browser/indexed_db/indexed_db_value.h" | 27 #include "content/browser/indexed_db/indexed_db_value.h" |
| 29 #include "content/browser/renderer_host/render_message_filter.h" | 28 #include "content/browser/renderer_host/render_message_filter.h" |
| 30 #include "content/common/indexed_db/indexed_db_messages.h" | 29 #include "content/common/indexed_db/indexed_db_messages.h" |
| 30 #include "content/common/indexed_db/indexed_db_metadata.h" |
| 31 #include "content/public/browser/browser_thread.h" | 31 #include "content/public/browser/browser_thread.h" |
| 32 #include "content/public/browser/user_metrics.h" | 32 #include "content/public/browser/user_metrics.h" |
| 33 #include "content/public/common/content_switches.h" | 33 #include "content/public/common/content_switches.h" |
| 34 #include "content/public/common/result_codes.h" | 34 #include "content/public/common/result_codes.h" |
| 35 #include "storage/browser/blob/blob_data_builder.h" | 35 #include "storage/browser/blob/blob_data_builder.h" |
| 36 #include "storage/browser/blob/blob_storage_context.h" | 36 #include "storage/browser/blob/blob_storage_context.h" |
| 37 #include "storage/browser/database/database_util.h" | 37 #include "storage/browser/database/database_util.h" |
| 38 #include "storage/browser/quota/quota_manager_proxy.h" | 38 #include "storage/browser/quota/quota_manager_proxy.h" |
| 39 #include "storage/common/database/database_identifier.h" | 39 #include "storage/common/database/database_identifier.h" |
| 40 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseExc
eption.h" | 40 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseExc
eption.h" |
| 41 #include "url/origin.h" | 41 #include "url/origin.h" |
| 42 | 42 |
| 43 using storage::DatabaseUtil; | 43 using storage::DatabaseUtil; |
| 44 using blink::WebIDBKey; | 44 using blink::WebIDBKey; |
| 45 | 45 |
| 46 namespace content { | 46 namespace content { |
| 47 | 47 |
| 48 namespace { | 48 namespace { |
| 49 | 49 |
| 50 const char kInvalidOrigin[] = "Origin is invalid"; |
| 51 |
| 50 bool IsValidOrigin(const url::Origin& origin) { | 52 bool IsValidOrigin(const url::Origin& origin) { |
| 51 return !origin.unique(); | 53 return !origin.unique(); |
| 52 } | 54 } |
| 53 | 55 |
| 54 } // namespace | 56 } // namespace |
| 55 | 57 |
| 56 IndexedDBDispatcherHost::IndexedDBDispatcherHost( | 58 IndexedDBDispatcherHost::IndexedDBDispatcherHost( |
| 57 int ipc_process_id, | 59 int ipc_process_id, |
| 58 net::URLRequestContextGetter* request_context_getter, | 60 net::URLRequestContextGetter* request_context_getter, |
| 59 IndexedDBContextImpl* indexed_db_context, | 61 IndexedDBContextImpl* indexed_db_context, |
| 60 ChromeBlobStorageContext* blob_storage_context) | 62 ChromeBlobStorageContext* blob_storage_context) |
| 61 : BrowserMessageFilter(IndexedDBMsgStart), | 63 : BrowserMessageFilter(IndexedDBMsgStart), |
| 64 BrowserAssociatedInterface(this, this), |
| 62 request_context_getter_(request_context_getter), | 65 request_context_getter_(request_context_getter), |
| 63 indexed_db_context_(indexed_db_context), | 66 indexed_db_context_(indexed_db_context), |
| 64 blob_storage_context_(blob_storage_context), | 67 blob_storage_context_(blob_storage_context), |
| 65 database_dispatcher_host_(base::MakeUnique<DatabaseDispatcherHost>(this)), | 68 database_dispatcher_host_(base::MakeUnique<DatabaseDispatcherHost>(this)), |
| 66 cursor_dispatcher_host_(base::MakeUnique<CursorDispatcherHost>(this)), | 69 cursor_dispatcher_host_(base::MakeUnique<CursorDispatcherHost>(this)), |
| 67 ipc_process_id_(ipc_process_id) { | 70 ipc_process_id_(ipc_process_id) { |
| 68 DCHECK(indexed_db_context_.get()); | 71 DCHECK(indexed_db_context_.get()); |
| 69 } | 72 } |
| 70 | 73 |
| 71 IndexedDBDispatcherHost::~IndexedDBDispatcherHost() {} | 74 IndexedDBDispatcherHost::~IndexedDBDispatcherHost() {} |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread() || | 130 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread() || |
| 128 (message.type() == IndexedDBHostMsg_DatabasePut::ID || | 131 (message.type() == IndexedDBHostMsg_DatabasePut::ID || |
| 129 message.type() == IndexedDBHostMsg_AckReceivedBlobs::ID)); | 132 message.type() == IndexedDBHostMsg_AckReceivedBlobs::ID)); |
| 130 | 133 |
| 131 bool handled = database_dispatcher_host_->OnMessageReceived(message) || | 134 bool handled = database_dispatcher_host_->OnMessageReceived(message) || |
| 132 cursor_dispatcher_host_->OnMessageReceived(message); | 135 cursor_dispatcher_host_->OnMessageReceived(message); |
| 133 | 136 |
| 134 if (!handled) { | 137 if (!handled) { |
| 135 handled = true; | 138 handled = true; |
| 136 IPC_BEGIN_MESSAGE_MAP(IndexedDBDispatcherHost, message) | 139 IPC_BEGIN_MESSAGE_MAP(IndexedDBDispatcherHost, message) |
| 137 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryGetDatabaseNames, | |
| 138 OnIDBFactoryGetDatabaseNames) | |
| 139 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryOpen, OnIDBFactoryOpen) | |
| 140 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryDeleteDatabase, | |
| 141 OnIDBFactoryDeleteDatabase) | |
| 142 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_AckReceivedBlobs, OnAckReceivedBlobs) | 140 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_AckReceivedBlobs, OnAckReceivedBlobs) |
| 143 IPC_MESSAGE_UNHANDLED(handled = false) | 141 IPC_MESSAGE_UNHANDLED(handled = false) |
| 144 IPC_END_MESSAGE_MAP() | 142 IPC_END_MESSAGE_MAP() |
| 145 } | 143 } |
| 146 return handled; | 144 return handled; |
| 147 } | 145 } |
| 148 | 146 |
| 149 int32_t IndexedDBDispatcherHost::Add(IndexedDBCursor* cursor) { | 147 int32_t IndexedDBDispatcherHost::Add(IndexedDBCursor* cursor) { |
| 150 if (!cursor_dispatcher_host_) { | 148 if (!cursor_dispatcher_host_) { |
| 151 return 0; | 149 return 0; |
| 152 } | 150 } |
| 153 return cursor_dispatcher_host_->map_.Add(cursor); | 151 return cursor_dispatcher_host_->map_.Add(cursor); |
| 154 } | 152 } |
| 155 | 153 |
| 156 int32_t IndexedDBDispatcherHost::Add(IndexedDBConnection* connection, | 154 int32_t IndexedDBDispatcherHost::Add(IndexedDBConnection* connection, |
| 157 int32_t ipc_thread_id, | |
| 158 const url::Origin& origin) { | 155 const url::Origin& origin) { |
| 159 if (!database_dispatcher_host_) { | 156 if (!database_dispatcher_host_) { |
| 160 connection->Close(); | 157 connection->Close(); |
| 161 delete connection; | 158 delete connection; |
| 162 return -1; | 159 return -1; |
| 163 } | 160 } |
| 164 int32_t ipc_database_id = database_dispatcher_host_->map_.Add(connection); | 161 int32_t ipc_database_id = database_dispatcher_host_->map_.Add(connection); |
| 165 connection->set_id(ipc_database_id); | 162 connection->set_id(ipc_database_id); |
| 166 context()->ConnectionOpened(origin, connection); | 163 context()->ConnectionOpened(origin, connection); |
| 167 database_dispatcher_host_->database_origin_map_[ipc_database_id] = origin; | 164 database_dispatcher_host_->database_origin_map_[ipc_database_id] = origin; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 252 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
| 256 return is_open_; | 253 return is_open_; |
| 257 } | 254 } |
| 258 | 255 |
| 259 IndexedDBCursor* IndexedDBDispatcherHost::GetCursorFromId( | 256 IndexedDBCursor* IndexedDBDispatcherHost::GetCursorFromId( |
| 260 int32_t ipc_cursor_id) { | 257 int32_t ipc_cursor_id) { |
| 261 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 258 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
| 262 return cursor_dispatcher_host_->map_.Lookup(ipc_cursor_id); | 259 return cursor_dispatcher_host_->map_.Lookup(ipc_cursor_id); |
| 263 } | 260 } |
| 264 | 261 |
| 265 ::IndexedDBDatabaseMetadata IndexedDBDispatcherHost::ConvertMetadata( | |
| 266 const content::IndexedDBDatabaseMetadata& web_metadata) { | |
| 267 ::IndexedDBDatabaseMetadata metadata; | |
| 268 metadata.id = web_metadata.id; | |
| 269 metadata.name = web_metadata.name; | |
| 270 metadata.version = web_metadata.version; | |
| 271 metadata.max_object_store_id = web_metadata.max_object_store_id; | |
| 272 | |
| 273 for (const auto& iter : web_metadata.object_stores) { | |
| 274 const content::IndexedDBObjectStoreMetadata& web_store_metadata = | |
| 275 iter.second; | |
| 276 ::IndexedDBObjectStoreMetadata idb_store_metadata; | |
| 277 idb_store_metadata.id = web_store_metadata.id; | |
| 278 idb_store_metadata.name = web_store_metadata.name; | |
| 279 idb_store_metadata.key_path = web_store_metadata.key_path; | |
| 280 idb_store_metadata.auto_increment = web_store_metadata.auto_increment; | |
| 281 idb_store_metadata.max_index_id = web_store_metadata.max_index_id; | |
| 282 | |
| 283 for (const auto& index_iter : web_store_metadata.indexes) { | |
| 284 const content::IndexedDBIndexMetadata& web_index_metadata = | |
| 285 index_iter.second; | |
| 286 ::IndexedDBIndexMetadata idb_index_metadata; | |
| 287 idb_index_metadata.id = web_index_metadata.id; | |
| 288 idb_index_metadata.name = web_index_metadata.name; | |
| 289 idb_index_metadata.key_path = web_index_metadata.key_path; | |
| 290 idb_index_metadata.unique = web_index_metadata.unique; | |
| 291 idb_index_metadata.multi_entry = web_index_metadata.multi_entry; | |
| 292 idb_store_metadata.indexes.push_back(idb_index_metadata); | |
| 293 } | |
| 294 metadata.object_stores.push_back(idb_store_metadata); | |
| 295 } | |
| 296 return metadata; | |
| 297 } | |
| 298 | |
| 299 IndexedDBMsg_ObserverChanges IndexedDBDispatcherHost::ConvertObserverChanges( | 262 IndexedDBMsg_ObserverChanges IndexedDBDispatcherHost::ConvertObserverChanges( |
| 300 std::unique_ptr<IndexedDBObserverChanges> changes) { | 263 std::unique_ptr<IndexedDBObserverChanges> changes) { |
| 301 IndexedDBMsg_ObserverChanges idb_changes; | 264 IndexedDBMsg_ObserverChanges idb_changes; |
| 302 idb_changes.observation_index = changes->release_observation_indices_map(); | 265 idb_changes.observation_index = changes->release_observation_indices_map(); |
| 303 for (const auto& observation : changes->release_observations()) | 266 for (const auto& observation : changes->release_observations()) |
| 304 idb_changes.observations.push_back(ConvertObservation(observation.get())); | 267 idb_changes.observations.push_back(ConvertObservation(observation.get())); |
| 305 return idb_changes; | 268 return idb_changes; |
| 306 } | 269 } |
| 307 | 270 |
| 308 IndexedDBMsg_Observation IndexedDBDispatcherHost::ConvertObservation( | 271 IndexedDBMsg_Observation IndexedDBDispatcherHost::ConvertObservation( |
| 309 const IndexedDBObservation* observation) { | 272 const IndexedDBObservation* observation) { |
| 310 // TODO(palakj): Modify function for indexed_db_value. Issue crbug.com/609934. | 273 // TODO(palakj): Modify function for indexed_db_value. Issue crbug.com/609934. |
| 311 IndexedDBMsg_Observation idb_observation; | 274 IndexedDBMsg_Observation idb_observation; |
| 312 idb_observation.object_store_id = observation->object_store_id(); | 275 idb_observation.object_store_id = observation->object_store_id(); |
| 313 idb_observation.type = observation->type(); | 276 idb_observation.type = observation->type(); |
| 314 idb_observation.key_range = observation->key_range(); | 277 idb_observation.key_range = observation->key_range(); |
| 315 return idb_observation; | 278 return idb_observation; |
| 316 } | 279 } |
| 317 | 280 |
| 318 void IndexedDBDispatcherHost::OnIDBFactoryGetDatabaseNames( | 281 void IndexedDBDispatcherHost::GetDatabaseNames( |
| 319 const IndexedDBHostMsg_FactoryGetDatabaseNames_Params& params) { | 282 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info, |
| 320 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 283 const url::Origin& origin) { |
| 284 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 321 | 285 |
| 322 if (!IsValidOrigin(params.origin)) { | 286 if (!IsValidOrigin(origin)) { |
| 323 bad_message::ReceivedBadMessage(this, bad_message::IDBDH_INVALID_ORIGIN); | 287 mojo::ReportBadMessage(kInvalidOrigin); |
| 324 return; | 288 return; |
| 325 } | 289 } |
| 326 | 290 |
| 291 scoped_refptr<IndexedDBCallbacks> callbacks( |
| 292 new IndexedDBCallbacks(this, origin, std::move(callbacks_info))); |
| 293 indexed_db_context_->TaskRunner()->PostTask( |
| 294 FROM_HERE, |
| 295 base::Bind(&IndexedDBDispatcherHost::GetDatabaseNamesOnIDBThread, this, |
| 296 callbacks, origin)); |
| 297 } |
| 298 |
| 299 void IndexedDBDispatcherHost::Open( |
| 300 int32_t worker_thread, |
| 301 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info, |
| 302 ::indexed_db::mojom::DatabaseCallbacksAssociatedPtrInfo |
| 303 database_callbacks_info, |
| 304 const url::Origin& origin, |
| 305 const base::string16& name, |
| 306 int64_t version, |
| 307 int64_t transaction_id) { |
| 308 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 309 |
| 310 if (!IsValidOrigin(origin)) { |
| 311 mojo::ReportBadMessage(kInvalidOrigin); |
| 312 return; |
| 313 } |
| 314 |
| 315 scoped_refptr<IndexedDBCallbacks> callbacks( |
| 316 new IndexedDBCallbacks(this, origin, std::move(callbacks_info))); |
| 317 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks( |
| 318 new IndexedDBDatabaseCallbacks(this, worker_thread, |
| 319 std::move(database_callbacks_info))); |
| 320 indexed_db_context_->TaskRunner()->PostTask( |
| 321 FROM_HERE, |
| 322 base::Bind(&IndexedDBDispatcherHost::OpenOnIDBThread, this, callbacks, |
| 323 database_callbacks, origin, name, version, transaction_id)); |
| 324 } |
| 325 |
| 326 void IndexedDBDispatcherHost::DeleteDatabase( |
| 327 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info, |
| 328 const url::Origin& origin, |
| 329 const base::string16& name) { |
| 330 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 331 |
| 332 if (!IsValidOrigin(origin)) { |
| 333 mojo::ReportBadMessage(kInvalidOrigin); |
| 334 return; |
| 335 } |
| 336 |
| 337 scoped_refptr<IndexedDBCallbacks> callbacks( |
| 338 new IndexedDBCallbacks(this, origin, std::move(callbacks_info))); |
| 339 indexed_db_context_->TaskRunner()->PostTask( |
| 340 FROM_HERE, base::Bind(&IndexedDBDispatcherHost::DeleteDatabaseOnIDBThread, |
| 341 this, callbacks, origin, name)); |
| 342 } |
| 343 |
| 344 void IndexedDBDispatcherHost::GetDatabaseNamesOnIDBThread( |
| 345 scoped_refptr<IndexedDBCallbacks> callbacks, |
| 346 const url::Origin& origin) { |
| 347 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
| 348 |
| 327 base::FilePath indexed_db_path = indexed_db_context_->data_path(); | 349 base::FilePath indexed_db_path = indexed_db_context_->data_path(); |
| 328 context()->GetIDBFactory()->GetDatabaseNames( | 350 context()->GetIDBFactory()->GetDatabaseNames( |
| 329 new IndexedDBCallbacks(this, params.ipc_thread_id, | 351 callbacks, origin, indexed_db_path, request_context_getter_); |
| 330 params.ipc_callbacks_id), | |
| 331 params.origin, indexed_db_path, request_context_getter_); | |
| 332 } | 352 } |
| 333 | 353 |
| 334 void IndexedDBDispatcherHost::OnIDBFactoryOpen( | 354 void IndexedDBDispatcherHost::OpenOnIDBThread( |
| 335 const IndexedDBHostMsg_FactoryOpen_Params& params) { | 355 scoped_refptr<IndexedDBCallbacks> callbacks, |
| 356 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, |
| 357 const url::Origin& origin, |
| 358 const base::string16& name, |
| 359 int64_t version, |
| 360 int64_t transaction_id) { |
| 336 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 361 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
| 337 | 362 |
| 338 if (!IsValidOrigin(params.origin)) { | |
| 339 bad_message::ReceivedBadMessage(this, bad_message::IDBDH_INVALID_ORIGIN); | |
| 340 return; | |
| 341 } | |
| 342 | |
| 343 base::TimeTicks begin_time = base::TimeTicks::Now(); | 363 base::TimeTicks begin_time = base::TimeTicks::Now(); |
| 344 base::FilePath indexed_db_path = indexed_db_context_->data_path(); | 364 base::FilePath indexed_db_path = indexed_db_context_->data_path(); |
| 345 | 365 |
| 346 int64_t host_transaction_id = HostTransactionId(params.transaction_id); | 366 int64_t host_transaction_id = HostTransactionId(transaction_id); |
| 347 | 367 |
| 348 // TODO(dgrogan): Don't let a non-existing database be opened (and therefore | 368 // TODO(dgrogan): Don't let a non-existing database be opened (and therefore |
| 349 // created) if this origin is already over quota. | 369 // created) if this origin is already over quota. |
| 350 scoped_refptr<IndexedDBCallbacks> callbacks = new IndexedDBCallbacks( | |
| 351 this, params.ipc_thread_id, params.ipc_callbacks_id, | |
| 352 params.ipc_database_callbacks_id, host_transaction_id, params.origin); | |
| 353 callbacks->SetConnectionOpenStartTime(begin_time); | 370 callbacks->SetConnectionOpenStartTime(begin_time); |
| 354 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks = | 371 callbacks->set_host_transaction_id(host_transaction_id); |
| 355 new IndexedDBDatabaseCallbacks( | |
| 356 this, params.ipc_thread_id, params.ipc_database_callbacks_id); | |
| 357 std::unique_ptr<IndexedDBPendingConnection> connection = | 372 std::unique_ptr<IndexedDBPendingConnection> connection = |
| 358 base::MakeUnique<IndexedDBPendingConnection>( | 373 base::MakeUnique<IndexedDBPendingConnection>( |
| 359 callbacks, database_callbacks, ipc_process_id_, host_transaction_id, | 374 callbacks, database_callbacks, ipc_process_id_, host_transaction_id, |
| 360 params.version); | 375 version); |
| 361 DCHECK(request_context_getter_); | 376 DCHECK(request_context_getter_); |
| 362 context()->GetIDBFactory()->Open(params.name, std::move(connection), | 377 context()->GetIDBFactory()->Open(name, std::move(connection), |
| 363 request_context_getter_, params.origin, | 378 request_context_getter_, origin, |
| 364 indexed_db_path); | 379 indexed_db_path); |
| 365 } | 380 } |
| 366 | 381 |
| 367 void IndexedDBDispatcherHost::OnIDBFactoryDeleteDatabase( | 382 void IndexedDBDispatcherHost::DeleteDatabaseOnIDBThread( |
| 368 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& params) { | 383 scoped_refptr<IndexedDBCallbacks> callbacks, |
| 384 const url::Origin& origin, |
| 385 const base::string16& name) { |
| 369 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 386 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
| 370 | 387 |
| 371 if (!IsValidOrigin(params.origin)) { | |
| 372 bad_message::ReceivedBadMessage(this, bad_message::IDBDH_INVALID_ORIGIN); | |
| 373 return; | |
| 374 } | |
| 375 | |
| 376 base::FilePath indexed_db_path = indexed_db_context_->data_path(); | 388 base::FilePath indexed_db_path = indexed_db_context_->data_path(); |
| 377 DCHECK(request_context_getter_); | 389 DCHECK(request_context_getter_); |
| 378 context()->GetIDBFactory()->DeleteDatabase( | 390 context()->GetIDBFactory()->DeleteDatabase( |
| 379 params.name, request_context_getter_, | 391 name, request_context_getter_, callbacks, origin, indexed_db_path); |
| 380 new IndexedDBCallbacks(this, params.ipc_thread_id, | |
| 381 params.ipc_callbacks_id), | |
| 382 params.origin, indexed_db_path); | |
| 383 } | 392 } |
| 384 | 393 |
| 385 // OnPutHelper exists only to allow us to hop threads while holding a reference | 394 // OnPutHelper exists only to allow us to hop threads while holding a reference |
| 386 // to the IndexedDBDispatcherHost. | 395 // to the IndexedDBDispatcherHost. |
| 387 void IndexedDBDispatcherHost::OnPutHelper( | 396 void IndexedDBDispatcherHost::OnPutHelper( |
| 388 const IndexedDBHostMsg_DatabasePut_Params& params, | 397 const IndexedDBHostMsg_DatabasePut_Params& params, |
| 389 std::vector<std::unique_ptr<storage::BlobDataHandle>> handles) { | 398 std::vector<std::unique_ptr<storage::BlobDataHandle>> handles) { |
| 390 database_dispatcher_host_->OnPut(params, std::move(handles)); | 399 database_dispatcher_host_->OnPut(params, std::move(handles)); |
| 391 } | 400 } |
| 392 | 401 |
| (...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1100 DLOG(ERROR) << "Unable to reset prefetch"; | 1109 DLOG(ERROR) << "Unable to reset prefetch"; |
| 1101 } | 1110 } |
| 1102 | 1111 |
| 1103 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( | 1112 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( |
| 1104 int32_t ipc_object_id) { | 1113 int32_t ipc_object_id) { |
| 1105 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread()); | 1114 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread()); |
| 1106 parent_->DestroyObject(&map_, ipc_object_id); | 1115 parent_->DestroyObject(&map_, ipc_object_id); |
| 1107 } | 1116 } |
| 1108 | 1117 |
| 1109 } // namespace content | 1118 } // namespace content |
| OLD | NEW |