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

Side by Side Diff: content/child/indexed_db/indexed_db_database_callbacks_impl.cc

Issue 2370643004: Port messages sent by WebIDBFactoryImpl to Mojo. (Closed)
Patch Set: Address last nits and fix leaks in unit tests. 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/child/indexed_db/indexed_db_database_callbacks_impl.h"
6
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"
10 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseErr or.h"
11
12 using blink::WebIDBDatabaseCallbacks;
13
14 namespace content {
15
16 namespace {
17
18 void DeleteDatabaseCallbacks(WebIDBDatabaseCallbacks* callbacks,
19 ThreadSafeSender* thread_safe_sender) {
20 IndexedDBDispatcher* dispatcher =
21 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender);
22 dispatcher->UnregisterMojoOwnedDatabaseCallbacks(callbacks);
23 delete callbacks;
24 }
25
26 } // namespace
27
28 IndexedDBDatabaseCallbacksImpl::IndexedDBDatabaseCallbacksImpl(
29 std::unique_ptr<WebIDBDatabaseCallbacks> callbacks,
30 scoped_refptr<ThreadSafeSender> thread_safe_sender)
31 : callback_runner_(base::ThreadTaskRunnerHandle::Get()),
32 thread_safe_sender_(thread_safe_sender),
33 callbacks_(callbacks.release()) {
34 IndexedDBDispatcher* dispatcher =
35 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get());
36 dispatcher->RegisterMojoOwnedDatabaseCallbacks(callbacks_);
37 }
38
39 IndexedDBDatabaseCallbacksImpl::~IndexedDBDatabaseCallbacksImpl() {
40 callback_runner_->PostTask(
41 FROM_HERE, base::Bind(&DeleteDatabaseCallbacks, callbacks_,
42 base::RetainedRef(thread_safe_sender_)));
43 }
44
45 void IndexedDBDatabaseCallbacksImpl::ForcedClose() {
46 callback_runner_->PostTask(FROM_HERE,
47 base::Bind(&WebIDBDatabaseCallbacks::onForcedClose,
48 base::Unretained(callbacks_)));
49 }
50
51 void IndexedDBDatabaseCallbacksImpl::VersionChange(int64_t old_version,
52 int64_t new_version) {
53 callback_runner_->PostTask(
54 FROM_HERE,
55 base::Bind(&WebIDBDatabaseCallbacks::onVersionChange,
56 base::Unretained(callbacks_), old_version, new_version));
57 }
58
59 void IndexedDBDatabaseCallbacksImpl::Abort(int64_t transaction_id,
60 int32_t code,
61 const base::string16& message) {
62 callback_runner_->PostTask(
63 FROM_HERE, base::Bind(&WebIDBDatabaseCallbacks::onAbort,
64 base::Unretained(callbacks_), transaction_id,
65 blink::WebIDBDatabaseError(code, message)));
66 }
67
68 void IndexedDBDatabaseCallbacksImpl::Complete(int64_t transaction_id) {
69 callback_runner_->PostTask(
70 FROM_HERE, base::Bind(&WebIDBDatabaseCallbacks::onComplete,
71 base::Unretained(callbacks_), transaction_id));
72 }
73
74 } // namespace content
OLDNEW
« no previous file with comments | « content/child/indexed_db/indexed_db_database_callbacks_impl.h ('k') | content/child/indexed_db/indexed_db_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698