OLD | NEW |
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 "base/memory/scoped_vector.h" | |
8 #include "content/browser/indexed_db/indexed_db_database_error.h" | 7 #include "content/browser/indexed_db/indexed_db_database_error.h" |
9 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" | 8 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" |
10 #include "content/common/indexed_db/indexed_db_messages.h" | 9 #include "content/common/indexed_db/indexed_db_messages.h" |
11 | 10 |
12 namespace content { | 11 namespace content { |
13 | 12 |
14 IndexedDBDatabaseCallbacks::IndexedDBDatabaseCallbacks( | 13 IndexedDBDatabaseCallbacks::IndexedDBDatabaseCallbacks( |
15 IndexedDBDispatcherHost* dispatcher_host, | 14 IndexedDBDispatcherHost* dispatcher_host, |
16 int ipc_thread_id, | 15 int ipc_thread_id, |
17 int ipc_database_callbacks_id) | 16 int ipc_database_callbacks_id) |
18 : dispatcher_host_(dispatcher_host), | 17 : dispatcher_host_(dispatcher_host), |
19 ipc_thread_id_(ipc_thread_id), | 18 ipc_thread_id_(ipc_thread_id), |
20 ipc_database_callbacks_id_(ipc_database_callbacks_id) {} | 19 ipc_database_callbacks_id_(ipc_database_callbacks_id) {} |
21 | 20 |
22 IndexedDBDatabaseCallbacks::~IndexedDBDatabaseCallbacks() {} | 21 IndexedDBDatabaseCallbacks::~IndexedDBDatabaseCallbacks() {} |
23 | 22 |
24 void IndexedDBDatabaseCallbacks::onForcedClose() { | 23 void IndexedDBDatabaseCallbacks::OnForcedClose() { |
| 24 if (!dispatcher_host_) |
| 25 return; |
| 26 |
25 dispatcher_host_->Send(new IndexedDBMsg_DatabaseCallbacksForcedClose( | 27 dispatcher_host_->Send(new IndexedDBMsg_DatabaseCallbacksForcedClose( |
26 ipc_thread_id_, ipc_database_callbacks_id_)); | 28 ipc_thread_id_, ipc_database_callbacks_id_)); |
| 29 |
| 30 dispatcher_host_ = NULL; |
27 } | 31 } |
28 | 32 |
29 void IndexedDBDatabaseCallbacks::onVersionChange(long long old_version, | 33 void IndexedDBDatabaseCallbacks::OnVersionChange(int64 old_version, |
30 long long new_version) { | 34 int64 new_version) { |
| 35 if (!dispatcher_host_) |
| 36 return; |
| 37 |
31 dispatcher_host_->Send(new IndexedDBMsg_DatabaseCallbacksIntVersionChange( | 38 dispatcher_host_->Send(new IndexedDBMsg_DatabaseCallbacksIntVersionChange( |
32 ipc_thread_id_, ipc_database_callbacks_id_, old_version, new_version)); | 39 ipc_thread_id_, ipc_database_callbacks_id_, old_version, new_version)); |
33 } | 40 } |
34 | 41 |
35 void IndexedDBDatabaseCallbacks::onAbort( | 42 void IndexedDBDatabaseCallbacks::OnAbort( |
36 long long host_transaction_id, | 43 int64 host_transaction_id, |
37 const IndexedDBDatabaseError& error) { | 44 const IndexedDBDatabaseError& error) { |
| 45 if (!dispatcher_host_) |
| 46 return; |
| 47 |
38 dispatcher_host_->FinishTransaction(host_transaction_id, false); | 48 dispatcher_host_->FinishTransaction(host_transaction_id, false); |
39 dispatcher_host_->Send(new IndexedDBMsg_DatabaseCallbacksAbort( | 49 dispatcher_host_->Send(new IndexedDBMsg_DatabaseCallbacksAbort( |
40 ipc_thread_id_, | 50 ipc_thread_id_, |
41 ipc_database_callbacks_id_, | 51 ipc_database_callbacks_id_, |
42 dispatcher_host_->RendererTransactionId(host_transaction_id), | 52 dispatcher_host_->RendererTransactionId(host_transaction_id), |
43 error.code(), | 53 error.code(), |
44 error.message())); | 54 error.message())); |
45 } | 55 } |
46 | 56 |
47 void IndexedDBDatabaseCallbacks::onComplete(long long host_transaction_id) { | 57 void IndexedDBDatabaseCallbacks::OnComplete(int64 host_transaction_id) { |
| 58 if (!dispatcher_host_) |
| 59 return; |
| 60 |
48 dispatcher_host_->FinishTransaction(host_transaction_id, true); | 61 dispatcher_host_->FinishTransaction(host_transaction_id, true); |
49 dispatcher_host_->Send(new IndexedDBMsg_DatabaseCallbacksComplete( | 62 dispatcher_host_->Send(new IndexedDBMsg_DatabaseCallbacksComplete( |
50 ipc_thread_id_, | 63 ipc_thread_id_, |
51 ipc_database_callbacks_id_, | 64 ipc_database_callbacks_id_, |
52 dispatcher_host_->RendererTransactionId(host_transaction_id))); | 65 dispatcher_host_->RendererTransactionId(host_transaction_id))); |
53 } | 66 } |
54 | 67 |
55 } // namespace content | 68 } // namespace content |
OLD | NEW |