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

Side by Side Diff: content/browser/indexed_db/indexed_db_database_callbacks.cc

Issue 1963293002: Replacing Indexed DB Chromium IPC with Mojo Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Some (incomplete) work on struct traits. Created 4 years, 5 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browser/indexed_db/indexed_db_database_callbacks.h" 5 #include "content/browser/indexed_db/indexed_db_database_callbacks.h"
6 6
7 #include <utility>
8
7 #include "content/browser/indexed_db/indexed_db_database_error.h" 9 #include "content/browser/indexed_db/indexed_db_database_error.h"
8 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" 10 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h"
9 #include "content/common/indexed_db/indexed_db_messages.h"
10 11
11 namespace content { 12 namespace content {
12 13
13 IndexedDBDatabaseCallbacks::IndexedDBDatabaseCallbacks( 14 IndexedDBDatabaseCallbacks::IndexedDBDatabaseCallbacks(
14 IndexedDBDispatcherHost* dispatcher_host, 15 indexed_db::mojom::DatabaseObserverPtr database_observer)
15 int ipc_thread_id, 16 : database_observer_(std::move(database_observer)) {}
16 int ipc_database_callbacks_id)
17 : dispatcher_host_(dispatcher_host),
18 ipc_thread_id_(ipc_thread_id),
19 ipc_database_callbacks_id_(ipc_database_callbacks_id) {}
20 17
21 IndexedDBDatabaseCallbacks::~IndexedDBDatabaseCallbacks() {} 18 IndexedDBDatabaseCallbacks::~IndexedDBDatabaseCallbacks() {}
22 19
23 void IndexedDBDatabaseCallbacks::OnForcedClose() { 20 void IndexedDBDatabaseCallbacks::OnForcedClose() {
24 if (!dispatcher_host_.get()) 21 if (!database_observer_)
25 return; 22 return;
26 23
27 dispatcher_host_->Send(new IndexedDBMsg_DatabaseCallbacksForcedClose( 24 database_observer_->OnForcedClosed();
28 ipc_thread_id_, ipc_database_callbacks_id_)); 25 database_observer_ = nullptr;
29
30 dispatcher_host_ = NULL;
31 } 26 }
32 27
33 void IndexedDBDatabaseCallbacks::OnVersionChange(int64_t old_version, 28 void IndexedDBDatabaseCallbacks::OnVersionChange(int64_t old_version,
34 int64_t new_version) { 29 int64_t new_version) {
35 if (!dispatcher_host_.get()) 30 if (!database_observer_)
36 return; 31 return;
37 32
38 dispatcher_host_->Send(new IndexedDBMsg_DatabaseCallbacksVersionChange( 33 database_observer_->OnVersionChange(old_version, new_version);
39 ipc_thread_id_, ipc_database_callbacks_id_, old_version, new_version));
40 } 34 }
41 35
42 void IndexedDBDatabaseCallbacks::OnAbort(int64_t host_transaction_id, 36 void IndexedDBDatabaseCallbacks::OnAbort(int64_t host_transaction_id,
43 const IndexedDBDatabaseError& error) { 37 const IndexedDBDatabaseError& error) {
44 if (!dispatcher_host_.get()) 38 if (!database_observer_)
45 return; 39 return;
46 40
47 dispatcher_host_->FinishTransaction(host_transaction_id, false); 41 database_observer_->OnTransactionFinished(host_transaction_id, false);
48 dispatcher_host_->Send(new IndexedDBMsg_DatabaseCallbacksAbort( 42 database_observer_->OnTransactionAborted(host_transaction_id, error);
49 ipc_thread_id_,
50 ipc_database_callbacks_id_,
51 dispatcher_host_->RendererTransactionId(host_transaction_id),
52 error.code(),
53 error.message()));
54 } 43 }
55 44
56 void IndexedDBDatabaseCallbacks::OnComplete(int64_t host_transaction_id) { 45 void IndexedDBDatabaseCallbacks::OnComplete(int64_t host_transaction_id) {
57 if (!dispatcher_host_.get()) 46 if (!database_observer_)
58 return; 47 return;
59 48
60 dispatcher_host_->FinishTransaction(host_transaction_id, true); 49 database_observer_->OnTransactionFinished(host_transaction_id, false);
61 dispatcher_host_->Send(new IndexedDBMsg_DatabaseCallbacksComplete( 50 database_observer_->OnTransactionCompleted(host_transaction_id);
62 ipc_thread_id_,
63 ipc_database_callbacks_id_,
64 dispatcher_host_->RendererTransactionId(host_transaction_id)));
65 } 51 }
66 52
67 } // namespace content 53 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698