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

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: 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 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(
19 WebIDBDatabaseCallbacks* callbacks,
20 scoped_refptr<ThreadSafeSender> thread_safe_sender) {
21 IndexedDBDispatcher* dispatcher =
22 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender.get());
23 dispatcher->UnregisterMojoOwnedDatabaseCallbacks(callbacks);
24 delete callbacks;
25 }
26
27 } // namespace
28
29 IndexedDBDatabaseCallbacksImpl::IndexedDBDatabaseCallbacksImpl(
30 WebIDBDatabaseCallbacks* callbacks,
31 scoped_refptr<ThreadSafeSender> thread_safe_sender)
32 : callback_runner_(base::ThreadTaskRunnerHandle::Get()),
33 thread_safe_sender_(thread_safe_sender),
34 callbacks_(callbacks) {
35 IndexedDBDispatcher* dispatcher =
36 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get());
37 dispatcher->RegisterMojoOwnedDatabaseCallbacks(callbacks_);
38 }
39
40 IndexedDBDatabaseCallbacksImpl::~IndexedDBDatabaseCallbacksImpl() {
41 callback_runner_->PostTask(
42 FROM_HERE,
43 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.
44 }
45
46 void IndexedDBDatabaseCallbacksImpl::ForcedClose() {
47 callback_runner_->PostTask(FROM_HERE,
48 base::Bind(&WebIDBDatabaseCallbacks::onForcedClose,
49 base::Unretained(callbacks_)));
50 }
51
52 void IndexedDBDatabaseCallbacksImpl::VersionChange(int64_t old_version,
53 int64_t new_version) {
54 callback_runner_->PostTask(
55 FROM_HERE,
56 base::Bind(&WebIDBDatabaseCallbacks::onVersionChange,
57 base::Unretained(callbacks_), old_version, new_version));
58 }
59
60 void IndexedDBDatabaseCallbacksImpl::Abort(int64_t transaction_id,
61 int32_t code,
62 const base::string16& message) {
63 callback_runner_->PostTask(
64 FROM_HERE, base::Bind(&WebIDBDatabaseCallbacks::onAbort,
65 base::Unretained(callbacks_), transaction_id,
66 blink::WebIDBDatabaseError(code, message)));
67 }
68
69 void IndexedDBDatabaseCallbacksImpl::Complete(int64_t transaction_id) {
70 callback_runner_->PostTask(
71 FROM_HERE, base::Bind(&WebIDBDatabaseCallbacks::onComplete,
72 base::Unretained(callbacks_), transaction_id));
73 }
74
75 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698