Index: content/browser/indexed_db/indexed_db_database_callbacks.h |
diff --git a/content/browser/indexed_db/indexed_db_database_callbacks.h b/content/browser/indexed_db/indexed_db_database_callbacks.h |
index 654195a18ea19d5dd5cc140bda34a3e9a487a986..07c42610465e3a43d6acfb181e842f8485b61f58 100644 |
--- a/content/browser/indexed_db/indexed_db_database_callbacks.h |
+++ b/content/browser/indexed_db/indexed_db_database_callbacks.h |
@@ -44,9 +44,28 @@ class CONTENT_EXPORT IndexedDBDatabaseCallbacks |
class IOThreadHelper; |
+ // Required for unittests so that are scheduled on a taskrunner. |
+ struct DeleteOnIOThreadTaskRunner { |
+ template <typename T> |
+ static void Destruct(const T* x) { |
+ if (!BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, x)) { |
+#if defined(UNIT_TEST) |
+ // Only logged under unit testing because leaks at shutdown |
+ // are acceptable under normal circumstances. |
+ LOG(ERROR) << "DeleteSoon failed on IO thread"; |
+#endif // UNIT_TEST |
+ } |
+ } |
+ template <typename T> |
+ inline void operator()(T* ptr) const { |
+ enum { type_must_be_complete = sizeof(T) }; |
+ Destruct(ptr); |
+ } |
+ }; |
+ |
bool complete_ = false; |
scoped_refptr<IndexedDBContextImpl> indexed_db_context_; |
- std::unique_ptr<IOThreadHelper, BrowserThread::DeleteOnIOThread> io_helper_; |
+ std::unique_ptr<IOThreadHelper, DeleteOnIOThreadTaskRunner> io_helper_; |
base::ThreadChecker thread_checker_; |
DISALLOW_COPY_AND_ASSIGN(IndexedDBDatabaseCallbacks); |