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_context_impl.h" | 7 #include "content/browser/indexed_db/indexed_db_context_impl.h" |
8 #include "content/browser/indexed_db/indexed_db_database_error.h" | 8 #include "content/browser/indexed_db/indexed_db_database_error.h" |
9 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" | 9 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" |
10 #include "content/browser/indexed_db/indexed_db_transaction.h" | 10 #include "content/browser/indexed_db/indexed_db_transaction.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); | 44 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
45 } | 45 } |
46 | 46 |
47 void IndexedDBDatabaseCallbacks::OnForcedClose() { | 47 void IndexedDBDatabaseCallbacks::OnForcedClose() { |
48 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); | 48 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
49 if (complete_) | 49 if (complete_) |
50 return; | 50 return; |
51 | 51 |
52 DCHECK(io_helper_); | 52 DCHECK(io_helper_); |
53 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 53 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
54 base::Bind(&IOThreadHelper::SendForcedClose, | 54 base::BindOnce(&IOThreadHelper::SendForcedClose, |
55 base::Unretained(io_helper_.get()))); | 55 base::Unretained(io_helper_.get()))); |
56 complete_ = true; | 56 complete_ = true; |
57 } | 57 } |
58 | 58 |
59 void IndexedDBDatabaseCallbacks::OnVersionChange(int64_t old_version, | 59 void IndexedDBDatabaseCallbacks::OnVersionChange(int64_t old_version, |
60 int64_t new_version) { | 60 int64_t new_version) { |
61 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); | 61 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
62 if (complete_) | 62 if (complete_) |
63 return; | 63 return; |
64 | 64 |
65 DCHECK(io_helper_); | 65 DCHECK(io_helper_); |
66 BrowserThread::PostTask( | 66 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
67 BrowserThread::IO, FROM_HERE, | 67 base::BindOnce(&IOThreadHelper::SendVersionChange, |
68 base::Bind(&IOThreadHelper::SendVersionChange, | 68 base::Unretained(io_helper_.get()), |
69 base::Unretained(io_helper_.get()), old_version, new_version)); | 69 old_version, new_version)); |
70 } | 70 } |
71 | 71 |
72 void IndexedDBDatabaseCallbacks::OnAbort( | 72 void IndexedDBDatabaseCallbacks::OnAbort( |
73 const IndexedDBTransaction& transaction, | 73 const IndexedDBTransaction& transaction, |
74 const IndexedDBDatabaseError& error) { | 74 const IndexedDBDatabaseError& error) { |
75 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); | 75 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
76 if (complete_) | 76 if (complete_) |
77 return; | 77 return; |
78 | 78 |
79 DCHECK(io_helper_); | 79 DCHECK(io_helper_); |
80 BrowserThread::PostTask( | 80 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
81 BrowserThread::IO, FROM_HERE, | 81 base::BindOnce(&IOThreadHelper::SendAbort, |
82 base::Bind(&IOThreadHelper::SendAbort, base::Unretained(io_helper_.get()), | 82 base::Unretained(io_helper_.get()), |
83 transaction.id(), error)); | 83 transaction.id(), error)); |
84 } | 84 } |
85 | 85 |
86 void IndexedDBDatabaseCallbacks::OnComplete( | 86 void IndexedDBDatabaseCallbacks::OnComplete( |
87 const IndexedDBTransaction& transaction) { | 87 const IndexedDBTransaction& transaction) { |
88 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); | 88 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
89 if (complete_) | 89 if (complete_) |
90 return; | 90 return; |
91 | 91 |
92 indexed_db_context_->TransactionComplete(transaction.database()->origin()); | 92 indexed_db_context_->TransactionComplete(transaction.database()->origin()); |
93 DCHECK(io_helper_); | 93 DCHECK(io_helper_); |
94 BrowserThread::PostTask( | 94 BrowserThread::PostTask( |
95 BrowserThread::IO, FROM_HERE, | 95 BrowserThread::IO, FROM_HERE, |
96 base::Bind(&IOThreadHelper::SendComplete, | 96 base::BindOnce(&IOThreadHelper::SendComplete, |
97 base::Unretained(io_helper_.get()), transaction.id())); | 97 base::Unretained(io_helper_.get()), transaction.id())); |
98 } | 98 } |
99 | 99 |
100 void IndexedDBDatabaseCallbacks::OnDatabaseChange( | 100 void IndexedDBDatabaseCallbacks::OnDatabaseChange( |
101 ::indexed_db::mojom::ObserverChangesPtr changes) { | 101 ::indexed_db::mojom::ObserverChangesPtr changes) { |
102 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); | 102 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
103 DCHECK(io_helper_); | 103 DCHECK(io_helper_); |
104 BrowserThread::PostTask( | 104 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
105 BrowserThread::IO, FROM_HERE, | 105 base::BindOnce(&IOThreadHelper::SendChanges, |
106 base::Bind(&IOThreadHelper::SendChanges, | 106 base::Unretained(io_helper_.get()), |
107 base::Unretained(io_helper_.get()), base::Passed(&changes))); | 107 base::Passed(&changes))); |
108 } | 108 } |
109 | 109 |
110 IndexedDBDatabaseCallbacks::IOThreadHelper::IOThreadHelper( | 110 IndexedDBDatabaseCallbacks::IOThreadHelper::IOThreadHelper( |
111 DatabaseCallbacksAssociatedPtrInfo callbacks_info) { | 111 DatabaseCallbacksAssociatedPtrInfo callbacks_info) { |
112 if (!callbacks_info.is_valid()) | 112 if (!callbacks_info.is_valid()) |
113 return; | 113 return; |
114 callbacks_.Bind(std::move(callbacks_info)); | 114 callbacks_.Bind(std::move(callbacks_info)); |
115 callbacks_.set_connection_error_handler( | 115 callbacks_.set_connection_error_handler(base::BindOnce( |
116 base::Bind(&IOThreadHelper::OnConnectionError, base::Unretained(this))); | 116 &IOThreadHelper::OnConnectionError, base::Unretained(this))); |
117 } | 117 } |
118 | 118 |
119 IndexedDBDatabaseCallbacks::IOThreadHelper::~IOThreadHelper() {} | 119 IndexedDBDatabaseCallbacks::IOThreadHelper::~IOThreadHelper() {} |
120 | 120 |
121 void IndexedDBDatabaseCallbacks::IOThreadHelper::SendForcedClose() { | 121 void IndexedDBDatabaseCallbacks::IOThreadHelper::SendForcedClose() { |
122 if (callbacks_) | 122 if (callbacks_) |
123 callbacks_->ForcedClose(); | 123 callbacks_->ForcedClose(); |
124 } | 124 } |
125 | 125 |
126 void IndexedDBDatabaseCallbacks::IOThreadHelper::SendVersionChange( | 126 void IndexedDBDatabaseCallbacks::IOThreadHelper::SendVersionChange( |
(...skipping 20 matching lines...) Expand all Loading... |
147 ::indexed_db::mojom::ObserverChangesPtr changes) { | 147 ::indexed_db::mojom::ObserverChangesPtr changes) { |
148 if (callbacks_) | 148 if (callbacks_) |
149 callbacks_->Changes(std::move(changes)); | 149 callbacks_->Changes(std::move(changes)); |
150 } | 150 } |
151 | 151 |
152 void IndexedDBDatabaseCallbacks::IOThreadHelper::OnConnectionError() { | 152 void IndexedDBDatabaseCallbacks::IOThreadHelper::OnConnectionError() { |
153 callbacks_.reset(); | 153 callbacks_.reset(); |
154 } | 154 } |
155 | 155 |
156 } // namespace content | 156 } // namespace content |
OLD | NEW |