OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "content/browser/indexed_db/indexed_db_database_callbacks.h" | |
6 | |
7 #include "content/browser/indexed_db/indexed_db_database_error.h" | |
8 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" | |
9 #include "content/browser/indexed_db/indexed_db_observer_changes.h" | |
10 #include "content/common/indexed_db/indexed_db_messages.h" | |
11 | |
12 namespace content { | |
13 | |
14 IndexedDBDatabaseCallbacks::IndexedDBDatabaseCallbacks( | |
15 IndexedDBDispatcherHost* dispatcher_host, | |
16 int ipc_thread_id, | |
17 int ipc_database_callbacks_id) | |
18 : dispatcher_host_(dispatcher_host), | |
19 ipc_thread_id_(ipc_thread_id), | |
20 ipc_database_callbacks_id_(ipc_database_callbacks_id) {} | |
21 | |
22 IndexedDBDatabaseCallbacks::~IndexedDBDatabaseCallbacks() {} | |
23 | |
24 void IndexedDBDatabaseCallbacks::OnForcedClose() { | |
25 if (!dispatcher_host_.get()) | |
26 return; | |
27 | |
28 dispatcher_host_->Send(new IndexedDBMsg_DatabaseCallbacksForcedClose( | |
29 ipc_thread_id_, ipc_database_callbacks_id_)); | |
30 | |
31 dispatcher_host_ = NULL; | |
32 } | |
33 | |
34 void IndexedDBDatabaseCallbacks::OnVersionChange(int64_t old_version, | |
35 int64_t new_version) { | |
36 if (!dispatcher_host_.get()) | |
37 return; | |
38 | |
39 dispatcher_host_->Send(new IndexedDBMsg_DatabaseCallbacksVersionChange( | |
40 ipc_thread_id_, ipc_database_callbacks_id_, old_version, new_version)); | |
41 } | |
42 | |
43 void IndexedDBDatabaseCallbacks::OnAbort(int64_t host_transaction_id, | |
44 const IndexedDBDatabaseError& error) { | |
45 if (!dispatcher_host_.get()) | |
46 return; | |
47 | |
48 dispatcher_host_->FinishTransaction(host_transaction_id, false); | |
49 dispatcher_host_->Send(new IndexedDBMsg_DatabaseCallbacksAbort( | |
50 ipc_thread_id_, | |
51 ipc_database_callbacks_id_, | |
52 dispatcher_host_->RendererTransactionId(host_transaction_id), | |
53 error.code(), | |
54 error.message())); | |
55 } | |
56 | |
57 void IndexedDBDatabaseCallbacks::OnComplete(int64_t host_transaction_id) { | |
58 if (!dispatcher_host_.get()) | |
59 return; | |
60 | |
61 dispatcher_host_->FinishTransaction(host_transaction_id, true); | |
62 dispatcher_host_->Send(new IndexedDBMsg_DatabaseCallbacksComplete( | |
63 ipc_thread_id_, | |
64 ipc_database_callbacks_id_, | |
65 dispatcher_host_->RendererTransactionId(host_transaction_id))); | |
66 } | |
67 | |
68 void IndexedDBDatabaseCallbacks::OnDatabaseChange( | |
69 int32_t ipc_database_id, | |
70 std::unique_ptr<IndexedDBObserverChanges> changes) { | |
71 dispatcher_host_->Send(new IndexedDBMsg_DatabaseCallbacksChanges( | |
72 ipc_thread_id_, ipc_database_id, | |
73 IndexedDBDispatcherHost::ConvertObserverChanges(std::move(changes)))); | |
74 } | |
75 | |
76 } // namespace content | |
OLD | NEW |