Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1753)

Unified Diff: content/child/indexed_db/indexed_db_database_callbacks_impl.cc

Issue 2370643004: Port messages sent by WebIDBFactoryImpl to Mojo. (Closed)
Patch Set: Store IOThreadHelper in an unique_ptr and add a TestBrowserThreadBundle where needed. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..f762575175d06892fb4b5dc388b33eec79cb5c6d
--- /dev/null
+++ b/content/child/indexed_db/indexed_db_database_callbacks_impl.cc
@@ -0,0 +1,75 @@
+// 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 "content/child/indexed_db/indexed_db_dispatcher.h"
+#include "content/child/thread_safe_sender.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 {
+
+namespace {
+
+void DeleteDatabaseCallbacks(
+ WebIDBDatabaseCallbacks* callbacks,
+ scoped_refptr<ThreadSafeSender> thread_safe_sender) {
+ IndexedDBDispatcher* dispatcher =
+ IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender.get());
+ dispatcher->UnregisterMojoOwnedDatabaseCallbacks(callbacks);
+ delete callbacks;
+}
+
+} // namespace
+
+IndexedDBDatabaseCallbacksImpl::IndexedDBDatabaseCallbacksImpl(
+ WebIDBDatabaseCallbacks* callbacks,
+ scoped_refptr<ThreadSafeSender> thread_safe_sender)
+ : callback_runner_(base::ThreadTaskRunnerHandle::Get()),
+ thread_safe_sender_(thread_safe_sender),
+ callbacks_(callbacks) {
+ IndexedDBDispatcher* dispatcher =
+ IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get());
+ dispatcher->RegisterMojoOwnedDatabaseCallbacks(callbacks_);
+}
+
+IndexedDBDatabaseCallbacksImpl::~IndexedDBDatabaseCallbacksImpl() {
+ callback_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&DeleteDatabaseCallbacks, callbacks_, thread_safe_sender_));
dcheng 2016/10/19 23:44:02 Nit: If thread_safe_sender is wrapped with base::R
Reilly Grant (use Gerrit) 2016/10/20 01:46:18 Done.
+}
+
+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

Powered by Google App Engine
This is Rietveld 408576698