Index: content/child/indexed_db/indexed_db_database_callbacks_impl.cc |
diff --git a/content/child/indexed_db/indexed_db_database_callbacks_impl.cc b/content/child/indexed_db/indexed_db_database_callbacks_impl.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a0a1ce6f74801eb223c421bfd1f6bf822b2b8b8e |
--- /dev/null |
+++ b/content/child/indexed_db/indexed_db_database_callbacks_impl.cc |
@@ -0,0 +1,66 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "content/child/indexed_db/indexed_db_database_callbacks_impl.h" |
+ |
+#include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseCallbacks.h" |
+#include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseError.h" |
+ |
+using blink::WebIDBDatabaseCallbacks; |
+ |
+namespace content { |
+ |
+IndexedDBDatabaseCallbacksImpl::IndexedDBDatabaseCallbacksImpl( |
+ WebIDBDatabaseCallbacks* callbacks) |
+ : callback_runner_(base::ThreadTaskRunnerHandle::Get()), |
+ callbacks_(callbacks), |
+ binding_(this) {} |
+ |
+IndexedDBDatabaseCallbacksImpl::~IndexedDBDatabaseCallbacksImpl() { |
+ callback_runner_->DeleteSoon(FROM_HERE, callbacks_); |
+} |
+ |
+void IndexedDBDatabaseCallbacksImpl::Bind( |
+ indexed_db::mojom::DatabaseCallbacksAssociatedPtrInfo* ptr_info, |
+ mojo::AssociatedGroup* associated_group) { |
+ binding_.Bind(ptr_info, associated_group); |
+ binding_.set_connection_error_handler( |
+ base::Bind(&IndexedDBDatabaseCallbacksImpl::OnConnectionError, |
+ base::Unretained(this))); |
+} |
+ |
+void IndexedDBDatabaseCallbacksImpl::OnConnectionError() { |
+ delete this; |
+} |
+ |
+void IndexedDBDatabaseCallbacksImpl::ForcedClose() { |
+ callback_runner_->PostTask(FROM_HERE, |
+ base::Bind(&WebIDBDatabaseCallbacks::onForcedClose, |
+ base::Unretained(callbacks_))); |
+} |
+ |
+void IndexedDBDatabaseCallbacksImpl::VersionChange(int64_t old_version, |
+ int64_t new_version) { |
+ callback_runner_->PostTask( |
+ FROM_HERE, |
+ base::Bind(&WebIDBDatabaseCallbacks::onVersionChange, |
+ base::Unretained(callbacks_), old_version, new_version)); |
+} |
+ |
+void IndexedDBDatabaseCallbacksImpl::Abort(int64_t transaction_id, |
+ int32_t code, |
+ const base::string16& message) { |
+ callback_runner_->PostTask( |
+ FROM_HERE, base::Bind(&WebIDBDatabaseCallbacks::onAbort, |
+ base::Unretained(callbacks_), transaction_id, |
+ blink::WebIDBDatabaseError(code, message))); |
+} |
+ |
+void IndexedDBDatabaseCallbacksImpl::Complete(int64_t transaction_id) { |
+ callback_runner_->PostTask( |
+ FROM_HERE, base::Bind(&WebIDBDatabaseCallbacks::onComplete, |
+ base::Unretained(callbacks_), transaction_id)); |
+} |
+ |
+} // namespace content |