Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(600)

Unified Diff: content/browser/indexed_db/indexed_db_database_callbacks.cc

Issue 2439863002: Prevent cross-thread refcounting for thread-unsafe IndexedDBCallbacks. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/indexed_db/indexed_db_database_callbacks.cc
diff --git a/content/browser/indexed_db/indexed_db_database_callbacks.cc b/content/browser/indexed_db/indexed_db_database_callbacks.cc
index d829891867bd57bc903099b8fbc2785cc1c67d00..e45a77bbb0c8cf26c5c8687e0a1b7ec3ace5e442 100644
--- a/content/browser/indexed_db/indexed_db_database_callbacks.cc
+++ b/content/browser/indexed_db/indexed_db_database_callbacks.cc
@@ -4,6 +4,7 @@
#include "content/browser/indexed_db/indexed_db_database_callbacks.h"
+#include "content/browser/indexed_db/indexed_db_context_impl.h"
#include "content/browser/indexed_db/indexed_db_database_error.h"
#include "content/browser/indexed_db/indexed_db_dispatcher_host.h"
#include "content/browser/indexed_db/indexed_db_observer_changes.h"
@@ -35,12 +36,18 @@ IndexedDBDatabaseCallbacks::IndexedDBDatabaseCallbacks(
DatabaseCallbacksAssociatedPtrInfo callbacks_info)
: dispatcher_host_(std::move(dispatcher_host)),
ipc_thread_id_(ipc_thread_id),
- io_helper_(new IOThreadHelper(std::move(callbacks_info))) {}
+ io_helper_(new IOThreadHelper(std::move(callbacks_info))) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ thread_checker_.DetachFromThread();
+}
-IndexedDBDatabaseCallbacks::~IndexedDBDatabaseCallbacks() {}
+IndexedDBDatabaseCallbacks::~IndexedDBDatabaseCallbacks() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+}
void IndexedDBDatabaseCallbacks::OnForcedClose() {
- if (!dispatcher_host_.get())
+ DCHECK(thread_checker_.CalledOnValidThread());
+ if (!dispatcher_host_)
return;
DCHECK(io_helper_);
@@ -52,7 +59,8 @@ void IndexedDBDatabaseCallbacks::OnForcedClose() {
void IndexedDBDatabaseCallbacks::OnVersionChange(int64_t old_version,
int64_t new_version) {
- if (!dispatcher_host_.get())
+ DCHECK(thread_checker_.CalledOnValidThread());
+ if (!dispatcher_host_)
return;
DCHECK(io_helper_);
@@ -64,7 +72,8 @@ void IndexedDBDatabaseCallbacks::OnVersionChange(int64_t old_version,
void IndexedDBDatabaseCallbacks::OnAbort(int64_t host_transaction_id,
const IndexedDBDatabaseError& error) {
- if (!dispatcher_host_.get())
+ DCHECK(thread_checker_.CalledOnValidThread());
+ if (!dispatcher_host_)
return;
dispatcher_host_->FinishTransaction(host_transaction_id, false);
@@ -77,7 +86,8 @@ void IndexedDBDatabaseCallbacks::OnAbort(int64_t host_transaction_id,
}
void IndexedDBDatabaseCallbacks::OnComplete(int64_t host_transaction_id) {
- if (!dispatcher_host_.get())
+ DCHECK(thread_checker_.CalledOnValidThread());
+ if (!dispatcher_host_)
return;
dispatcher_host_->FinishTransaction(host_transaction_id, true);
@@ -92,6 +102,7 @@ void IndexedDBDatabaseCallbacks::OnComplete(int64_t host_transaction_id) {
void IndexedDBDatabaseCallbacks::OnDatabaseChange(
int32_t ipc_database_id,
std::unique_ptr<IndexedDBObserverChanges> changes) {
+ DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(io_helper_);
dispatcher_host_->Send(new IndexedDBMsg_DatabaseCallbacksChanges(
ipc_thread_id_, ipc_database_id,
« no previous file with comments | « content/browser/indexed_db/indexed_db_database_callbacks.h ('k') | content/browser/indexed_db/indexed_db_dispatcher_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698