 Chromium Code Reviews
 Chromium Code Reviews Issue 2472213003:
  [IndexedDB] Refactoring to remove ref ptrs and host transaction ids.  (Closed)
    
  
    Issue 2472213003:
  [IndexedDB] Refactoring to remove ref ptrs and host transaction ids.  (Closed) 
  | Index: content/browser/indexed_db/indexed_db_callbacks.cc | 
| diff --git a/content/browser/indexed_db/indexed_db_callbacks.cc b/content/browser/indexed_db/indexed_db_callbacks.cc | 
| index 03dd974f2b5211d1ce8c10a172b9d6c3b4520ccf..d7f4f89a79b468890a4f7a07f58f3c7c6412f598 100644 | 
| --- a/content/browser/indexed_db/indexed_db_callbacks.cc | 
| +++ b/content/browser/indexed_db/indexed_db_callbacks.cc | 
| @@ -23,6 +23,7 @@ | 
| #include "content/browser/indexed_db/indexed_db_database_error.h" | 
| #include "content/browser/indexed_db/indexed_db_return_value.h" | 
| #include "content/browser/indexed_db/indexed_db_tracing.h" | 
| +#include "content/browser/indexed_db/indexed_db_transaction.h" | 
| #include "content/browser/indexed_db/indexed_db_value.h" | 
| #include "content/common/indexed_db/indexed_db_constants.h" | 
| #include "content/common/indexed_db/indexed_db_metadata.h" | 
| @@ -38,7 +39,6 @@ using storage::ShareableFileReference; | 
| namespace content { | 
| namespace { | 
| -const int64_t kNoTransaction = -1; | 
| void ConvertBlobInfo( | 
| const std::vector<IndexedDBBlobInfo>& blob_info, | 
| @@ -144,7 +144,6 @@ IndexedDBCallbacks::IndexedDBCallbacks( | 
| const url::Origin& origin, | 
| ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info) | 
| : dispatcher_host_(std::move(dispatcher_host)), | 
| - host_transaction_id_(kNoTransaction), | 
| origin_(origin), | 
| data_loss_(blink::WebIDBDataLossNone), | 
| sent_blocked_(false), | 
| @@ -180,7 +179,6 @@ void IndexedDBCallbacks::OnSuccess(const std::vector<base::string16>& value) { | 
| DCHECK(thread_checker_.CalledOnValidThread()); | 
| DCHECK(dispatcher_host_); | 
| DCHECK(io_helper_); | 
| - DCHECK_EQ(kNoTransaction, host_transaction_id_); | 
| BrowserThread::PostTask( | 
| BrowserThread::IO, FROM_HERE, | 
| @@ -215,17 +213,16 @@ void IndexedDBCallbacks::OnBlocked(int64_t existing_version) { | 
| void IndexedDBCallbacks::OnUpgradeNeeded( | 
| int64_t old_version, | 
| std::unique_ptr<IndexedDBConnection> connection, | 
| + IndexedDBTransaction* transaction, | 
| 
cmumford
2016/12/01 19:14:51
transaction unused in this function.
 
dmurph
2016/12/01 21:12:23
Done.
 | 
| const IndexedDBDatabaseMetadata& metadata, | 
| const IndexedDBDataLossInfo& data_loss_info) { | 
| DCHECK(thread_checker_.CalledOnValidThread()); | 
| DCHECK(dispatcher_host_); | 
| DCHECK(io_helper_); | 
| - DCHECK_NE(kNoTransaction, host_transaction_id_); | 
| DCHECK(!database_sent_); | 
| data_loss_ = data_loss_info.status; | 
| - dispatcher_host_->RegisterTransactionId(host_transaction_id_, origin_); | 
| database_sent_ = true; | 
| auto database = base::MakeUnique<DatabaseImpl>(std::move(connection), origin_, | 
| dispatcher_host_); | 
| @@ -252,7 +249,6 @@ void IndexedDBCallbacks::OnSuccess( | 
| DCHECK(dispatcher_host_); | 
| DCHECK(io_helper_); | 
| - DCHECK_NE(kNoTransaction, host_transaction_id_); | 
| DCHECK_EQ(database_sent_, !connection); | 
| scoped_refptr<IndexedDBCallbacks> self(this); | 
| @@ -278,7 +274,7 @@ void IndexedDBCallbacks::OnSuccess( | 
| } | 
| } | 
| -void IndexedDBCallbacks::OnSuccess(scoped_refptr<IndexedDBCursor> cursor, | 
| +void IndexedDBCallbacks::OnSuccess(std::unique_ptr<IndexedDBCursor> cursor, | 
| const IndexedDBKey& key, | 
| const IndexedDBKey& primary_key, | 
| IndexedDBValue* value) { | 
| @@ -286,11 +282,10 @@ void IndexedDBCallbacks::OnSuccess(scoped_refptr<IndexedDBCursor> cursor, | 
| DCHECK(dispatcher_host_); | 
| DCHECK(io_helper_); | 
| - DCHECK_EQ(kNoTransaction, host_transaction_id_); | 
| DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_); | 
| - auto cursor_impl = | 
| - base::MakeUnique<CursorImpl>(cursor, origin_, dispatcher_host_); | 
| + auto cursor_impl = base::MakeUnique<CursorImpl>(std::move(cursor), origin_, | 
| + dispatcher_host_); | 
| ::indexed_db::mojom::ValuePtr mojo_value; | 
| std::vector<IndexedDBBlobInfo> blob_info; | 
| @@ -315,7 +310,6 @@ void IndexedDBCallbacks::OnSuccess(const IndexedDBKey& key, | 
| DCHECK(dispatcher_host_); | 
| DCHECK(io_helper_); | 
| - DCHECK_EQ(kNoTransaction, host_transaction_id_); | 
| DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_); | 
| ::indexed_db::mojom::ValuePtr mojo_value; | 
| @@ -343,7 +337,6 @@ void IndexedDBCallbacks::OnSuccessWithPrefetch( | 
| DCHECK_EQ(keys.size(), primary_keys.size()); | 
| DCHECK_EQ(keys.size(), values->size()); | 
| - DCHECK_EQ(kNoTransaction, host_transaction_id_); | 
| DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_); | 
| std::vector<::indexed_db::mojom::ValuePtr> mojo_values; | 
| @@ -363,7 +356,6 @@ void IndexedDBCallbacks::OnSuccess(IndexedDBReturnValue* value) { | 
| DCHECK(thread_checker_.CalledOnValidThread()); | 
| DCHECK(dispatcher_host_); | 
| - DCHECK_EQ(kNoTransaction, host_transaction_id_); | 
| DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_); | 
| ::indexed_db::mojom::ReturnValuePtr mojo_value; | 
| @@ -387,7 +379,6 @@ void IndexedDBCallbacks::OnSuccessArray( | 
| DCHECK(dispatcher_host_); | 
| DCHECK(io_helper_); | 
| - DCHECK_EQ(kNoTransaction, host_transaction_id_); | 
| DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_); | 
| std::vector<::indexed_db::mojom::ReturnValuePtr> mojo_values; | 
| @@ -407,7 +398,6 @@ void IndexedDBCallbacks::OnSuccess(const IndexedDBKey& value) { | 
| DCHECK(dispatcher_host_); | 
| DCHECK(io_helper_); | 
| - DCHECK_EQ(kNoTransaction, host_transaction_id_); | 
| DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_); | 
| BrowserThread::PostTask( | 
| @@ -433,7 +423,6 @@ void IndexedDBCallbacks::OnSuccess() { | 
| DCHECK(dispatcher_host_); | 
| DCHECK(io_helper_); | 
| - DCHECK_EQ(kNoTransaction, host_transaction_id_); | 
| DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_); | 
| BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |