| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/child/indexed_db/indexed_db_database_callbacks_impl.h" | 5 #include "content/child/indexed_db/indexed_db_database_callbacks_impl.h" |
| 6 | 6 |
| 7 #include "content/child/indexed_db/indexed_db_dispatcher.h" | 7 #include "content/child/indexed_db/indexed_db_dispatcher.h" |
| 8 #include "content/child/thread_safe_sender.h" | |
| 9 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseCal
lbacks.h" | 8 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseCal
lbacks.h" |
| 10 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseErr
or.h" | 9 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseErr
or.h" |
| 11 | 10 |
| 12 using blink::WebIDBDatabaseCallbacks; | 11 using blink::WebIDBDatabaseCallbacks; |
| 13 | 12 |
| 14 namespace content { | 13 namespace content { |
| 15 | 14 |
| 16 namespace { | 15 namespace { |
| 17 | 16 |
| 18 void DeleteDatabaseCallbacks(WebIDBDatabaseCallbacks* callbacks, | 17 void DeleteDatabaseCallbacks(WebIDBDatabaseCallbacks* callbacks) { |
| 19 ThreadSafeSender* thread_safe_sender) { | 18 IndexedDBDispatcher::ThreadSpecificInstance() |
| 20 IndexedDBDispatcher* dispatcher = | 19 ->UnregisterMojoOwnedDatabaseCallbacks(callbacks); |
| 21 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender); | |
| 22 dispatcher->UnregisterMojoOwnedDatabaseCallbacks(callbacks); | |
| 23 delete callbacks; | 20 delete callbacks; |
| 24 } | 21 } |
| 25 | 22 |
| 26 } // namespace | 23 } // namespace |
| 27 | 24 |
| 28 IndexedDBDatabaseCallbacksImpl::IndexedDBDatabaseCallbacksImpl( | 25 IndexedDBDatabaseCallbacksImpl::IndexedDBDatabaseCallbacksImpl( |
| 29 std::unique_ptr<WebIDBDatabaseCallbacks> callbacks, | 26 std::unique_ptr<WebIDBDatabaseCallbacks> callbacks) |
| 30 scoped_refptr<ThreadSafeSender> thread_safe_sender) | |
| 31 : callback_runner_(base::ThreadTaskRunnerHandle::Get()), | 27 : callback_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 32 thread_safe_sender_(thread_safe_sender), | |
| 33 callbacks_(callbacks.release()) { | 28 callbacks_(callbacks.release()) { |
| 34 IndexedDBDispatcher* dispatcher = | 29 IndexedDBDispatcher::ThreadSpecificInstance() |
| 35 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); | 30 ->RegisterMojoOwnedDatabaseCallbacks(callbacks_); |
| 36 dispatcher->RegisterMojoOwnedDatabaseCallbacks(callbacks_); | |
| 37 } | 31 } |
| 38 | 32 |
| 39 IndexedDBDatabaseCallbacksImpl::~IndexedDBDatabaseCallbacksImpl() { | 33 IndexedDBDatabaseCallbacksImpl::~IndexedDBDatabaseCallbacksImpl() { |
| 40 callback_runner_->PostTask( | 34 callback_runner_->PostTask(FROM_HERE, |
| 41 FROM_HERE, base::Bind(&DeleteDatabaseCallbacks, callbacks_, | 35 base::Bind(&DeleteDatabaseCallbacks, callbacks_)); |
| 42 base::RetainedRef(thread_safe_sender_))); | |
| 43 } | 36 } |
| 44 | 37 |
| 45 void IndexedDBDatabaseCallbacksImpl::ForcedClose() { | 38 void IndexedDBDatabaseCallbacksImpl::ForcedClose() { |
| 46 callback_runner_->PostTask(FROM_HERE, | 39 callback_runner_->PostTask(FROM_HERE, |
| 47 base::Bind(&WebIDBDatabaseCallbacks::onForcedClose, | 40 base::Bind(&WebIDBDatabaseCallbacks::onForcedClose, |
| 48 base::Unretained(callbacks_))); | 41 base::Unretained(callbacks_))); |
| 49 } | 42 } |
| 50 | 43 |
| 51 void IndexedDBDatabaseCallbacksImpl::VersionChange(int64_t old_version, | 44 void IndexedDBDatabaseCallbacksImpl::VersionChange(int64_t old_version, |
| 52 int64_t new_version) { | 45 int64_t new_version) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 65 blink::WebIDBDatabaseError(code, message))); | 58 blink::WebIDBDatabaseError(code, message))); |
| 66 } | 59 } |
| 67 | 60 |
| 68 void IndexedDBDatabaseCallbacksImpl::Complete(int64_t transaction_id) { | 61 void IndexedDBDatabaseCallbacksImpl::Complete(int64_t transaction_id) { |
| 69 callback_runner_->PostTask( | 62 callback_runner_->PostTask( |
| 70 FROM_HERE, base::Bind(&WebIDBDatabaseCallbacks::onComplete, | 63 FROM_HERE, base::Bind(&WebIDBDatabaseCallbacks::onComplete, |
| 71 base::Unretained(callbacks_), transaction_id)); | 64 base::Unretained(callbacks_), transaction_id)); |
| 72 } | 65 } |
| 73 | 66 |
| 74 } // namespace content | 67 } // namespace content |
| OLD | NEW |