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_callbacks.h" | 5 #include "content/browser/indexed_db/indexed_db_callbacks.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "content/browser/indexed_db/indexed_db_database_error.h" | 10 #include "content/browser/indexed_db/indexed_db_database_error.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 } | 52 } |
53 | 53 |
54 void IndexedDBCallbacksBase::onUpgradeNeeded( | 54 void IndexedDBCallbacksBase::onUpgradeNeeded( |
55 long long old_version, | 55 long long old_version, |
56 WebIDBDatabaseImpl* database, | 56 WebIDBDatabaseImpl* database, |
57 const IndexedDBDatabaseMetadata& /*metadata*/, | 57 const IndexedDBDatabaseMetadata& /*metadata*/, |
58 WebKit::WebIDBCallbacks::DataLoss data_loss) { | 58 WebKit::WebIDBCallbacks::DataLoss data_loss) { |
59 NOTREACHED(); | 59 NOTREACHED(); |
60 } | 60 } |
61 | 61 |
62 void IndexedDBCallbacksBase::onSuccess(WebIDBCursorImpl* idb_object, | 62 void IndexedDBCallbacksBase::onSuccess(IndexedDBCursor* idb_object, |
63 const IndexedDBKey& key, | 63 const IndexedDBKey& key, |
64 const IndexedDBKey& primaryKey, | 64 const IndexedDBKey& primaryKey, |
65 std::vector<char>* value) { | 65 std::vector<char>* value) { |
66 NOTREACHED(); | 66 NOTREACHED(); |
67 } | 67 } |
68 | 68 |
69 void IndexedDBCallbacksBase::onSuccess(const IndexedDBKey& key, | 69 void IndexedDBCallbacksBase::onSuccess(const IndexedDBKey& key, |
70 const IndexedDBKey& primaryKey, | 70 const IndexedDBKey& primaryKey, |
71 std::vector<char>* value) { | 71 std::vector<char>* value) { |
72 NOTREACHED(); | 72 NOTREACHED(); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 params.ipc_thread_id = ipc_thread_id(); | 145 params.ipc_thread_id = ipc_thread_id(); |
146 params.ipc_callbacks_id = ipc_callbacks_id(); | 146 params.ipc_callbacks_id = ipc_callbacks_id(); |
147 params.ipc_database_id = ipc_database_id; | 147 params.ipc_database_id = ipc_database_id; |
148 params.ipc_database_callbacks_id = ipc_database_callbacks_id_; | 148 params.ipc_database_callbacks_id = ipc_database_callbacks_id_; |
149 params.old_version = old_version; | 149 params.old_version = old_version; |
150 params.idb_metadata = IndexedDBDispatcherHost::ConvertMetadata(metadata); | 150 params.idb_metadata = IndexedDBDispatcherHost::ConvertMetadata(metadata); |
151 params.data_loss = data_loss; | 151 params.data_loss = data_loss; |
152 dispatcher_host()->Send(new IndexedDBMsg_CallbacksUpgradeNeeded(params)); | 152 dispatcher_host()->Send(new IndexedDBMsg_CallbacksUpgradeNeeded(params)); |
153 } | 153 } |
154 | 154 |
155 void IndexedDBCallbacks<WebIDBCursorImpl>::onSuccess( | 155 void IndexedDBCallbacks<IndexedDBCursor>::onSuccess( |
156 WebIDBCursorImpl* idb_cursor, | 156 IndexedDBCursor* idb_cursor, |
157 const IndexedDBKey& key, | 157 const IndexedDBKey& key, |
158 const IndexedDBKey& primaryKey, | 158 const IndexedDBKey& primaryKey, |
159 std::vector<char>* value) { | 159 std::vector<char>* value) { |
160 int32 ipc_object_id = dispatcher_host()->Add(idb_cursor); | 160 int32 ipc_object_id = dispatcher_host()->Add(idb_cursor); |
161 IndexedDBMsg_CallbacksSuccessIDBCursor_Params params; | 161 IndexedDBMsg_CallbacksSuccessIDBCursor_Params params; |
162 params.ipc_thread_id = ipc_thread_id(); | 162 params.ipc_thread_id = ipc_thread_id(); |
163 params.ipc_callbacks_id = ipc_callbacks_id(); | 163 params.ipc_callbacks_id = ipc_callbacks_id(); |
164 params.ipc_cursor_id = ipc_object_id; | 164 params.ipc_cursor_id = ipc_object_id; |
165 params.key = key; | 165 params.key = key; |
166 params.primary_key = primaryKey; | 166 params.primary_key = primaryKey; |
167 if (value && !value->empty()) | 167 if (value && !value->empty()) |
168 std::swap(params.value, *value); | 168 std::swap(params.value, *value); |
169 // TODO(alecflett): Avoid a copy here: the whole params object is | 169 // TODO(alecflett): Avoid a copy here: the whole params object is |
170 // being copied into the message. | 170 // being copied into the message. |
171 dispatcher_host()->Send(new IndexedDBMsg_CallbacksSuccessIDBCursor(params)); | 171 dispatcher_host()->Send(new IndexedDBMsg_CallbacksSuccessIDBCursor(params)); |
172 } | 172 } |
173 | 173 |
174 void IndexedDBCallbacks<WebIDBCursorImpl>::onSuccess(std::vector<char>* value) { | 174 void IndexedDBCallbacks<IndexedDBCursor>::onSuccess(std::vector<char>* value) { |
175 std::vector<char> value_copy; | 175 std::vector<char> value_copy; |
176 if (value && !value->empty()) | 176 if (value && !value->empty()) |
177 std::swap(value_copy, *value); | 177 std::swap(value_copy, *value); |
178 dispatcher_host()->Send(new IndexedDBMsg_CallbacksSuccessValue( | 178 dispatcher_host()->Send(new IndexedDBMsg_CallbacksSuccessValue( |
179 ipc_thread_id(), | 179 ipc_thread_id(), |
180 ipc_callbacks_id(), | 180 ipc_callbacks_id(), |
181 // TODO(alecflett): avoid a copy here. | 181 // TODO(alecflett): avoid a copy here. |
182 value_copy)); | 182 value_copy)); |
183 } | 183 } |
184 | 184 |
185 void IndexedDBCallbacks<WebIDBCursorImpl>::onSuccess( | 185 void IndexedDBCallbacks<IndexedDBCursor>::onSuccess( |
186 const IndexedDBKey& key, | 186 const IndexedDBKey& key, |
187 const IndexedDBKey& primaryKey, | 187 const IndexedDBKey& primaryKey, |
188 std::vector<char>* value) { | 188 std::vector<char>* value) { |
189 DCHECK_NE(ipc_cursor_id_, -1); | 189 DCHECK_NE(ipc_cursor_id_, -1); |
190 WebIDBCursorImpl* idb_cursor = | 190 IndexedDBCursor* idb_cursor = |
191 dispatcher_host()->GetCursorFromId(ipc_cursor_id_); | 191 dispatcher_host()->GetCursorFromId(ipc_cursor_id_); |
192 | 192 |
193 DCHECK(idb_cursor); | 193 DCHECK(idb_cursor); |
194 if (!idb_cursor) | 194 if (!idb_cursor) |
195 return; | 195 return; |
196 IndexedDBMsg_CallbacksSuccessCursorContinue_Params params; | 196 IndexedDBMsg_CallbacksSuccessCursorContinue_Params params; |
197 params.ipc_thread_id = ipc_thread_id(); | 197 params.ipc_thread_id = ipc_thread_id(); |
198 params.ipc_callbacks_id = ipc_callbacks_id(); | 198 params.ipc_callbacks_id = ipc_callbacks_id(); |
199 params.ipc_cursor_id = ipc_cursor_id_; | 199 params.ipc_cursor_id = ipc_cursor_id_; |
200 params.key = key; | 200 params.key = key; |
201 params.primary_key = primaryKey; | 201 params.primary_key = primaryKey; |
202 if (value && !value->empty()) | 202 if (value && !value->empty()) |
203 std::swap(params.value, *value); | 203 std::swap(params.value, *value); |
204 // TODO(alecflett): Avoid a copy here: the whole params object is | 204 // TODO(alecflett): Avoid a copy here: the whole params object is |
205 // being copied into the message. | 205 // being copied into the message. |
206 dispatcher_host()->Send( | 206 dispatcher_host()->Send( |
207 new IndexedDBMsg_CallbacksSuccessCursorContinue(params)); | 207 new IndexedDBMsg_CallbacksSuccessCursorContinue(params)); |
208 } | 208 } |
209 | 209 |
210 void IndexedDBCallbacks<WebIDBCursorImpl>::onSuccessWithPrefetch( | 210 void IndexedDBCallbacks<IndexedDBCursor>::onSuccessWithPrefetch( |
211 const std::vector<IndexedDBKey>& keys, | 211 const std::vector<IndexedDBKey>& keys, |
212 const std::vector<IndexedDBKey>& primaryKeys, | 212 const std::vector<IndexedDBKey>& primaryKeys, |
213 const std::vector<std::vector<char> >& values) { | 213 const std::vector<std::vector<char> >& values) { |
214 DCHECK_NE(ipc_cursor_id_, -1); | 214 DCHECK_NE(ipc_cursor_id_, -1); |
215 | 215 |
216 std::vector<IndexedDBKey> msgKeys; | 216 std::vector<IndexedDBKey> msgKeys; |
217 std::vector<IndexedDBKey> msgPrimaryKeys; | 217 std::vector<IndexedDBKey> msgPrimaryKeys; |
218 | 218 |
219 for (size_t i = 0; i < keys.size(); ++i) { | 219 for (size_t i = 0; i < keys.size(); ++i) { |
220 msgKeys.push_back(keys[i]); | 220 msgKeys.push_back(keys[i]); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 ipc_thread_id(), ipc_callbacks_id())); | 286 ipc_thread_id(), ipc_callbacks_id())); |
287 } | 287 } |
288 | 288 |
289 void IndexedDBCallbacks<std::vector<char> >::onSuccess( | 289 void IndexedDBCallbacks<std::vector<char> >::onSuccess( |
290 const IndexedDBKey& value) { | 290 const IndexedDBKey& value) { |
291 dispatcher_host()->Send(new IndexedDBMsg_CallbacksSuccessIndexedDBKey( | 291 dispatcher_host()->Send(new IndexedDBMsg_CallbacksSuccessIndexedDBKey( |
292 ipc_thread_id(), ipc_callbacks_id(), value)); | 292 ipc_thread_id(), ipc_callbacks_id(), value)); |
293 } | 293 } |
294 | 294 |
295 } // namespace content | 295 } // namespace content |
OLD | NEW |