| 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_callbacks.h" | 5 #include "content/browser/indexed_db/indexed_db_callbacks.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "content/browser/child_process_security_policy_impl.h" | 15 #include "content/browser/child_process_security_policy_impl.h" |
| 16 #include "content/browser/fileapi/fileapi_message_filter.h" | 16 #include "content/browser/fileapi/fileapi_message_filter.h" |
| 17 #include "content/browser/indexed_db/indexed_db_blob_info.h" | 17 #include "content/browser/indexed_db/indexed_db_blob_info.h" |
| 18 #include "content/browser/indexed_db/indexed_db_connection.h" | 18 #include "content/browser/indexed_db/indexed_db_connection.h" |
| 19 #include "content/browser/indexed_db/indexed_db_context_impl.h" | 19 #include "content/browser/indexed_db/indexed_db_context_impl.h" |
| 20 #include "content/browser/indexed_db/indexed_db_cursor.h" | 20 #include "content/browser/indexed_db/indexed_db_cursor.h" |
| 21 #include "content/browser/indexed_db/indexed_db_database_error.h" | 21 #include "content/browser/indexed_db/indexed_db_database_error.h" |
| 22 #include "content/browser/indexed_db/indexed_db_return_value.h" | 22 #include "content/browser/indexed_db/indexed_db_return_value.h" |
| 23 #include "content/browser/indexed_db/indexed_db_tracing.h" | 23 #include "content/browser/indexed_db/indexed_db_tracing.h" |
| 24 #include "content/browser/indexed_db/indexed_db_transaction.h" |
| 24 #include "content/browser/indexed_db/indexed_db_value.h" | 25 #include "content/browser/indexed_db/indexed_db_value.h" |
| 25 #include "content/common/indexed_db/indexed_db_constants.h" | 26 #include "content/common/indexed_db/indexed_db_constants.h" |
| 26 #include "content/common/indexed_db/indexed_db_messages.h" | 27 #include "content/common/indexed_db/indexed_db_messages.h" |
| 27 #include "content/common/indexed_db/indexed_db_metadata.h" | 28 #include "content/common/indexed_db/indexed_db_metadata.h" |
| 28 #include "storage/browser/blob/blob_storage_context.h" | 29 #include "storage/browser/blob/blob_storage_context.h" |
| 29 #include "storage/browser/blob/shareable_file_reference.h" | 30 #include "storage/browser/blob/shareable_file_reference.h" |
| 30 #include "storage/browser/quota/quota_manager.h" | 31 #include "storage/browser/quota/quota_manager.h" |
| 31 | 32 |
| 32 using indexed_db::mojom::CallbacksAssociatedPtrInfo; | 33 using indexed_db::mojom::CallbacksAssociatedPtrInfo; |
| 33 using storage::ShareableFileReference; | 34 using storage::ShareableFileReference; |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 UMA_HISTOGRAM_MEDIUM_TIMES( | 168 UMA_HISTOGRAM_MEDIUM_TIMES( |
| 168 "WebCore.IndexedDB.OpenTime.Blocked", | 169 "WebCore.IndexedDB.OpenTime.Blocked", |
| 169 base::TimeTicks::Now() - connection_open_start_time_); | 170 base::TimeTicks::Now() - connection_open_start_time_); |
| 170 connection_open_start_time_ = base::TimeTicks(); | 171 connection_open_start_time_ = base::TimeTicks(); |
| 171 } | 172 } |
| 172 } | 173 } |
| 173 | 174 |
| 174 void IndexedDBCallbacks::OnUpgradeNeeded( | 175 void IndexedDBCallbacks::OnUpgradeNeeded( |
| 175 int64_t old_version, | 176 int64_t old_version, |
| 176 std::unique_ptr<IndexedDBConnection> connection, | 177 std::unique_ptr<IndexedDBConnection> connection, |
| 178 IndexedDBTransaction* transaction, |
| 177 const IndexedDBDatabaseMetadata& metadata, | 179 const IndexedDBDatabaseMetadata& metadata, |
| 178 const IndexedDBDataLossInfo& data_loss_info) { | 180 const IndexedDBDataLossInfo& data_loss_info) { |
| 179 DCHECK(thread_checker_.CalledOnValidThread()); | 181 DCHECK(thread_checker_.CalledOnValidThread()); |
| 180 DCHECK(dispatcher_host_); | 182 DCHECK(dispatcher_host_); |
| 181 DCHECK(io_helper_); | 183 DCHECK(io_helper_); |
| 182 DCHECK_NE(kNoTransaction, host_transaction_id_); | 184 DCHECK_NE(kNoTransaction, host_transaction_id_); |
| 183 DCHECK_EQ(kNoCursor, ipc_cursor_id_); | 185 DCHECK_EQ(kNoCursor, ipc_cursor_id_); |
| 184 DCHECK_EQ(kNoDatabase, ipc_database_id_); | 186 DCHECK_EQ(kNoDatabase, ipc_database_id_); |
| 185 | 187 |
| 186 data_loss_ = data_loss_info.status; | 188 data_loss_ = data_loss_info.status; |
| 187 dispatcher_host_->RegisterTransactionId(host_transaction_id_, origin_); | 189 transaction->set_origin(origin_); |
| 188 int32_t ipc_database_id = | 190 int32_t ipc_database_id = |
| 189 dispatcher_host_->Add(connection.release(), origin_); | 191 dispatcher_host_->Add(connection.release(), origin_); |
| 190 if (ipc_database_id < 0) | 192 if (ipc_database_id < 0) |
| 191 return; | 193 return; |
| 192 | 194 |
| 193 ipc_database_id_ = ipc_database_id; | 195 ipc_database_id_ = ipc_database_id; |
| 194 | 196 |
| 195 BrowserThread::PostTask( | 197 BrowserThread::PostTask( |
| 196 BrowserThread::IO, FROM_HERE, | 198 BrowserThread::IO, FROM_HERE, |
| 197 base::Bind(&IOThreadHelper::SendUpgradeNeeded, | 199 base::Bind(&IOThreadHelper::SendUpgradeNeeded, |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 const std::vector<IndexedDBBlobInfo>& blob_info, | 349 const std::vector<IndexedDBBlobInfo>& blob_info, |
| 348 const base::Closure& callback) { | 350 const base::Closure& callback) { |
| 349 for (const auto& iter : blob_info) { | 351 for (const auto& iter : blob_info) { |
| 350 if (!iter.mark_used_callback().is_null()) | 352 if (!iter.mark_used_callback().is_null()) |
| 351 iter.mark_used_callback().Run(); | 353 iter.mark_used_callback().Run(); |
| 352 } | 354 } |
| 353 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO)); | 355 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 354 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, callback); | 356 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, callback); |
| 355 } | 357 } |
| 356 | 358 |
| 357 void IndexedDBCallbacks::OnSuccess(scoped_refptr<IndexedDBCursor> cursor, | 359 void IndexedDBCallbacks::OnSuccess(std::unique_ptr<IndexedDBCursor> cursor, |
| 358 const IndexedDBKey& key, | 360 const IndexedDBKey& key, |
| 359 const IndexedDBKey& primary_key, | 361 const IndexedDBKey& primary_key, |
| 360 IndexedDBValue* value) { | 362 IndexedDBValue* value) { |
| 361 DCHECK(thread_checker_.CalledOnValidThread()); | 363 DCHECK(thread_checker_.CalledOnValidThread()); |
| 362 DCHECK(dispatcher_host_); | 364 DCHECK(dispatcher_host_); |
| 363 DCHECK(!io_helper_); | 365 DCHECK(!io_helper_); |
| 364 | 366 |
| 365 DCHECK_EQ(kNoCursor, ipc_cursor_id_); | 367 DCHECK_EQ(kNoCursor, ipc_cursor_id_); |
| 366 DCHECK_EQ(kNoTransaction, host_transaction_id_); | 368 DCHECK_EQ(kNoTransaction, host_transaction_id_); |
| 367 DCHECK_EQ(kNoDatabase, ipc_database_id_); | 369 DCHECK_EQ(kNoDatabase, ipc_database_id_); |
| 368 DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_); | 370 DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_); |
| 369 | 371 |
| 370 int32_t ipc_object_id = dispatcher_host_->Add(cursor.get()); | 372 int32_t ipc_object_id = dispatcher_host_->Add(std::move(cursor)); |
| 371 std::unique_ptr<IndexedDBMsg_CallbacksSuccessIDBCursor_Params> params( | 373 std::unique_ptr<IndexedDBMsg_CallbacksSuccessIDBCursor_Params> params( |
| 372 new IndexedDBMsg_CallbacksSuccessIDBCursor_Params()); | 374 new IndexedDBMsg_CallbacksSuccessIDBCursor_Params()); |
| 373 params->ipc_thread_id = ipc_thread_id_; | 375 params->ipc_thread_id = ipc_thread_id_; |
| 374 params->ipc_callbacks_id = ipc_callbacks_id_; | 376 params->ipc_callbacks_id = ipc_callbacks_id_; |
| 375 params->ipc_cursor_id = ipc_object_id; | 377 params->ipc_cursor_id = ipc_object_id; |
| 376 params->key = key; | 378 params->key = key; |
| 377 params->primary_key = primary_key; | 379 params->primary_key = primary_key; |
| 378 if (value && !value->empty()) | 380 if (value && !value->empty()) |
| 379 std::swap(params->value.bits, value->bits); | 381 std::swap(params->value.bits, value->bits); |
| 380 // TODO(alecflett): Avoid a copy here: the whole params object is | 382 // TODO(alecflett): Avoid a copy here: the whole params object is |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 int32_t database_id, | 688 int32_t database_id, |
| 687 const content::IndexedDBDatabaseMetadata& metadata) { | 689 const content::IndexedDBDatabaseMetadata& metadata) { |
| 688 callbacks_->SuccessDatabase(database_id, metadata); | 690 callbacks_->SuccessDatabase(database_id, metadata); |
| 689 } | 691 } |
| 690 | 692 |
| 691 void IndexedDBCallbacks::IOThreadHelper::SendSuccessInteger(int64_t value) { | 693 void IndexedDBCallbacks::IOThreadHelper::SendSuccessInteger(int64_t value) { |
| 692 callbacks_->SuccessInteger(value); | 694 callbacks_->SuccessInteger(value); |
| 693 } | 695 } |
| 694 | 696 |
| 695 } // namespace content | 697 } // namespace content |
| OLD | NEW |