Index: content/browser/indexed_db/indexed_db_callbacks.h |
diff --git a/content/browser/indexed_db/indexed_db_callbacks.h b/content/browser/indexed_db/indexed_db_callbacks.h |
index 45d9e0d25f8e5e341a8ec9c09999755c93862a8a..25d19e4b25660ef023c73152962892dcd69f5124 100644 |
--- a/content/browser/indexed_db/indexed_db_callbacks.h |
+++ b/content/browser/indexed_db/indexed_db_callbacks.h |
@@ -127,7 +127,26 @@ class CONTENT_EXPORT IndexedDBCallbacks |
bool sent_blocked_ = false; |
base::TimeTicks connection_open_start_time_; |
- std::unique_ptr<IOThreadHelper, BrowserThread::DeleteOnIOThread> io_helper_; |
+ // 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); |
+ } |
+ }; |
+ |
+ std::unique_ptr<IOThreadHelper, DeleteOnIOThreadTaskRunner> io_helper_; |
Reilly Grant (use Gerrit)
2017/05/11 01:57:08
Why did you copy this code from BrowserThread::Del
dmurph
2017/05/12 01:22:06
Not a perfect copy - DeleteOnIOThread actually del
Reilly Grant (use Gerrit)
2017/05/12 01:46:52
I don't understand this last sentence. In unit tes
|
base::ThreadChecker thread_checker_; |
DISALLOW_COPY_AND_ASSIGN(IndexedDBCallbacks); |