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