Commit d17cb16e authored by Hajime Hoshi's avatar Hajime Hoshi Committed by Commit Bot

indexed_db: Pass appropriate task runners to AssociatedInterfacePtr::Bind via IndexedDB classes

This is part of efforts to replace base::ThreadTaskRunnerHandle::Get()
and SequencedTaskRunnerHandle::Get() with other appropriate task runners
in the renderer.

Bug: 786332
Change-Id: I2ab4e22c26cf710fbc22adeb951c1eb12440f354
Reviewed-on: https://chromium-review.googlesource.com/975281Reviewed-by: default avatarChris Mumford <cmumford@chromium.org>
Commit-Queue: Hajime Hoshi <hajimehoshi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#547997}
parent 20c5d0a0
...@@ -28,7 +28,8 @@ namespace content { ...@@ -28,7 +28,8 @@ namespace content {
class WebIDBCursorImpl::IOThreadHelper { class WebIDBCursorImpl::IOThreadHelper {
public: public:
IOThreadHelper(); explicit IOThreadHelper(
scoped_refptr<base::SingleThreadTaskRunner> task_runner);
~IOThreadHelper(); ~IOThreadHelper();
void Bind(CursorAssociatedPtrInfo cursor_info); void Bind(CursorAssociatedPtrInfo cursor_info);
...@@ -46,6 +47,7 @@ class WebIDBCursorImpl::IOThreadHelper { ...@@ -46,6 +47,7 @@ class WebIDBCursorImpl::IOThreadHelper {
std::unique_ptr<IndexedDBCallbacksImpl> callbacks); std::unique_ptr<IndexedDBCallbacksImpl> callbacks);
indexed_db::mojom::CursorAssociatedPtr cursor_; indexed_db::mojom::CursorAssociatedPtr cursor_;
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
DISALLOW_COPY_AND_ASSIGN(IOThreadHelper); DISALLOW_COPY_AND_ASSIGN(IOThreadHelper);
}; };
...@@ -56,7 +58,7 @@ WebIDBCursorImpl::WebIDBCursorImpl( ...@@ -56,7 +58,7 @@ WebIDBCursorImpl::WebIDBCursorImpl(
scoped_refptr<base::SingleThreadTaskRunner> io_runner, scoped_refptr<base::SingleThreadTaskRunner> io_runner,
scoped_refptr<base::SingleThreadTaskRunner> callback_runner) scoped_refptr<base::SingleThreadTaskRunner> callback_runner)
: transaction_id_(transaction_id), : transaction_id_(transaction_id),
helper_(new IOThreadHelper()), helper_(new IOThreadHelper(io_runner)),
io_runner_(std::move(io_runner)), io_runner_(std::move(io_runner)),
callback_runner_(std::move(callback_runner)), callback_runner_(std::move(callback_runner)),
continue_count_(0), continue_count_(0),
...@@ -250,13 +252,15 @@ void WebIDBCursorImpl::ResetPrefetchCache() { ...@@ -250,13 +252,15 @@ void WebIDBCursorImpl::ResetPrefetchCache() {
pending_onsuccess_callbacks_ = 0; pending_onsuccess_callbacks_ = 0;
} }
WebIDBCursorImpl::IOThreadHelper::IOThreadHelper() {} WebIDBCursorImpl::IOThreadHelper::IOThreadHelper(
scoped_refptr<base::SingleThreadTaskRunner> task_runner)
: task_runner_(std::move(task_runner)) {}
WebIDBCursorImpl::IOThreadHelper::~IOThreadHelper() {} WebIDBCursorImpl::IOThreadHelper::~IOThreadHelper() {}
void WebIDBCursorImpl::IOThreadHelper::Bind( void WebIDBCursorImpl::IOThreadHelper::Bind(
CursorAssociatedPtrInfo cursor_info) { CursorAssociatedPtrInfo cursor_info) {
cursor_.Bind(std::move(cursor_info)); cursor_.Bind(std::move(cursor_info), task_runner_);
} }
void WebIDBCursorImpl::IOThreadHelper::Advance( void WebIDBCursorImpl::IOThreadHelper::Advance(
......
...@@ -64,7 +64,8 @@ std::vector<content::IndexedDBIndexKeys> ConvertWebIndexKeys( ...@@ -64,7 +64,8 @@ std::vector<content::IndexedDBIndexKeys> ConvertWebIndexKeys(
class WebIDBDatabaseImpl::IOThreadHelper { class WebIDBDatabaseImpl::IOThreadHelper {
public: public:
IOThreadHelper(); explicit IOThreadHelper(
scoped_refptr<base::SingleThreadTaskRunner> task_runner);
~IOThreadHelper(); ~IOThreadHelper();
void Bind(DatabaseAssociatedPtrInfo database_info); void Bind(DatabaseAssociatedPtrInfo database_info);
...@@ -158,6 +159,7 @@ class WebIDBDatabaseImpl::IOThreadHelper { ...@@ -158,6 +159,7 @@ class WebIDBDatabaseImpl::IOThreadHelper {
std::unique_ptr<IndexedDBCallbacksImpl> callbacks); std::unique_ptr<IndexedDBCallbacksImpl> callbacks);
indexed_db::mojom::DatabaseAssociatedPtr database_; indexed_db::mojom::DatabaseAssociatedPtr database_;
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
DISALLOW_COPY_AND_ASSIGN(IOThreadHelper); DISALLOW_COPY_AND_ASSIGN(IOThreadHelper);
}; };
...@@ -166,7 +168,7 @@ WebIDBDatabaseImpl::WebIDBDatabaseImpl( ...@@ -166,7 +168,7 @@ WebIDBDatabaseImpl::WebIDBDatabaseImpl(
DatabaseAssociatedPtrInfo database_info, DatabaseAssociatedPtrInfo database_info,
scoped_refptr<base::SingleThreadTaskRunner> io_runner, scoped_refptr<base::SingleThreadTaskRunner> io_runner,
scoped_refptr<base::SingleThreadTaskRunner> callback_runner) scoped_refptr<base::SingleThreadTaskRunner> callback_runner)
: helper_(new IOThreadHelper()), : helper_(new IOThreadHelper(io_runner)),
io_runner_(std::move(io_runner)), io_runner_(std::move(io_runner)),
callback_runner_(std::move(callback_runner)) { callback_runner_(std::move(callback_runner)) {
io_runner_->PostTask(FROM_HERE, base::BindOnce(&IOThreadHelper::Bind, io_runner_->PostTask(FROM_HERE, base::BindOnce(&IOThreadHelper::Bind,
...@@ -525,13 +527,15 @@ void WebIDBDatabaseImpl::Commit(long long transaction_id) { ...@@ -525,13 +527,15 @@ void WebIDBDatabaseImpl::Commit(long long transaction_id) {
base::Unretained(helper_), transaction_id)); base::Unretained(helper_), transaction_id));
} }
WebIDBDatabaseImpl::IOThreadHelper::IOThreadHelper() {} WebIDBDatabaseImpl::IOThreadHelper::IOThreadHelper(
scoped_refptr<base::SingleThreadTaskRunner> task_runner)
: task_runner_(std::move(task_runner)) {}
WebIDBDatabaseImpl::IOThreadHelper::~IOThreadHelper() {} WebIDBDatabaseImpl::IOThreadHelper::~IOThreadHelper() {}
void WebIDBDatabaseImpl::IOThreadHelper::Bind( void WebIDBDatabaseImpl::IOThreadHelper::Bind(
DatabaseAssociatedPtrInfo database_info) { DatabaseAssociatedPtrInfo database_info) {
database_.Bind(std::move(database_info)); database_.Bind(std::move(database_info), task_runner_);
} }
void WebIDBDatabaseImpl::IOThreadHelper::CreateObjectStore( void WebIDBDatabaseImpl::IOThreadHelper::CreateObjectStore(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment