OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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.h" | 5 #include "content/browser/indexed_db/indexed_db_database.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 const IndexedDBObjectStoreMetadata object_store_metadata_; | 56 const IndexedDBObjectStoreMetadata object_store_metadata_; |
57 }; | 57 }; |
58 | 58 |
59 class IndexedDBDatabase::VersionChangeOperation | 59 class IndexedDBDatabase::VersionChangeOperation |
60 : public IndexedDBTransaction::Operation { | 60 : public IndexedDBTransaction::Operation { |
61 public: | 61 public: |
62 VersionChangeOperation( | 62 VersionChangeOperation( |
63 scoped_refptr<IndexedDBDatabase> database, | 63 scoped_refptr<IndexedDBDatabase> database, |
64 int64 transaction_id, | 64 int64 transaction_id, |
65 int64 version, | 65 int64 version, |
66 scoped_refptr<IndexedDBCallbacksWrapper> callbacks, | 66 scoped_refptr<IndexedDBCallbacks> callbacks, |
67 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, | 67 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, |
68 WebKit::WebIDBCallbacks::DataLoss data_loss) | 68 WebKit::WebIDBCallbacks::DataLoss data_loss) |
69 : database_(database), | 69 : database_(database), |
70 transaction_id_(transaction_id), | 70 transaction_id_(transaction_id), |
71 version_(version), | 71 version_(version), |
72 callbacks_(callbacks), | 72 callbacks_(callbacks), |
73 database_callbacks_(database_callbacks), | 73 database_callbacks_(database_callbacks), |
74 data_loss_(data_loss) {} | 74 data_loss_(data_loss) {} |
75 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; | 75 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; |
76 | 76 |
77 private: | 77 private: |
78 scoped_refptr<IndexedDBDatabase> database_; | 78 scoped_refptr<IndexedDBDatabase> database_; |
79 int64 transaction_id_; | 79 int64 transaction_id_; |
80 int64 version_; | 80 int64 version_; |
81 scoped_refptr<IndexedDBCallbacksWrapper> callbacks_; | 81 scoped_refptr<IndexedDBCallbacks> callbacks_; |
82 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks_; | 82 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks_; |
83 WebKit::WebIDBCallbacks::DataLoss data_loss_; | 83 WebKit::WebIDBCallbacks::DataLoss data_loss_; |
84 }; | 84 }; |
85 | 85 |
86 class CreateObjectStoreAbortOperation : public IndexedDBTransaction::Operation { | 86 class CreateObjectStoreAbortOperation : public IndexedDBTransaction::Operation { |
87 public: | 87 public: |
88 CreateObjectStoreAbortOperation(scoped_refptr<IndexedDBDatabase> database, | 88 CreateObjectStoreAbortOperation(scoped_refptr<IndexedDBDatabase> database, |
89 int64 object_store_id) | 89 int64 object_store_id) |
90 : database_(database), object_store_id_(object_store_id) {} | 90 : database_(database), object_store_id_(object_store_id) {} |
91 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; | 91 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 class GetOperation : public IndexedDBTransaction::Operation { | 192 class GetOperation : public IndexedDBTransaction::Operation { |
193 public: | 193 public: |
194 GetOperation(scoped_refptr<IndexedDBBackingStore> backing_store, | 194 GetOperation(scoped_refptr<IndexedDBBackingStore> backing_store, |
195 int64 database_id, | 195 int64 database_id, |
196 int64 object_store_id, | 196 int64 object_store_id, |
197 int64 index_id, | 197 int64 index_id, |
198 const IndexedDBKeyPath& key_path, | 198 const IndexedDBKeyPath& key_path, |
199 const bool auto_increment, | 199 const bool auto_increment, |
200 scoped_ptr<IndexedDBKeyRange> key_range, | 200 scoped_ptr<IndexedDBKeyRange> key_range, |
201 indexed_db::CursorType cursor_type, | 201 indexed_db::CursorType cursor_type, |
202 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) | 202 scoped_refptr<IndexedDBCallbacks> callbacks) |
203 : backing_store_(backing_store), | 203 : backing_store_(backing_store), |
204 database_id_(database_id), | 204 database_id_(database_id), |
205 object_store_id_(object_store_id), | 205 object_store_id_(object_store_id), |
206 index_id_(index_id), | 206 index_id_(index_id), |
207 key_path_(key_path), | 207 key_path_(key_path), |
208 auto_increment_(auto_increment), | 208 auto_increment_(auto_increment), |
209 key_range_(key_range.Pass()), | 209 key_range_(key_range.Pass()), |
210 cursor_type_(cursor_type), | 210 cursor_type_(cursor_type), |
211 callbacks_(callbacks) { | 211 callbacks_(callbacks) {} |
212 } | |
213 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; | 212 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; |
214 | 213 |
215 private: | 214 private: |
216 const scoped_refptr<IndexedDBBackingStore> backing_store_; | 215 const scoped_refptr<IndexedDBBackingStore> backing_store_; |
217 const int64 database_id_; | 216 const int64 database_id_; |
218 const int64 object_store_id_; | 217 const int64 object_store_id_; |
219 const int64 index_id_; | 218 const int64 index_id_; |
220 const IndexedDBKeyPath key_path_; | 219 const IndexedDBKeyPath key_path_; |
221 const bool auto_increment_; | 220 const bool auto_increment_; |
222 const scoped_ptr<IndexedDBKeyRange> key_range_; | 221 const scoped_ptr<IndexedDBKeyRange> key_range_; |
223 const indexed_db::CursorType cursor_type_; | 222 const indexed_db::CursorType cursor_type_; |
224 const scoped_refptr<IndexedDBCallbacksWrapper> callbacks_; | 223 const scoped_refptr<IndexedDBCallbacks> callbacks_; |
225 }; | 224 }; |
226 | 225 |
227 class PutOperation : public IndexedDBTransaction::Operation { | 226 class PutOperation : public IndexedDBTransaction::Operation { |
228 public: | 227 public: |
229 PutOperation(scoped_refptr<IndexedDBBackingStore> backing_store, | 228 PutOperation(scoped_refptr<IndexedDBBackingStore> backing_store, |
230 int64 database_id, | 229 int64 database_id, |
231 const IndexedDBObjectStoreMetadata& object_store, | 230 const IndexedDBObjectStoreMetadata& object_store, |
232 std::vector<char>* value, | 231 std::vector<char>* value, |
233 scoped_ptr<IndexedDBKey> key, | 232 scoped_ptr<IndexedDBKey> key, |
234 IndexedDBDatabase::PutMode put_mode, | 233 IndexedDBDatabase::PutMode put_mode, |
235 scoped_refptr<IndexedDBCallbacksWrapper> callbacks, | 234 scoped_refptr<IndexedDBCallbacks> callbacks, |
236 const std::vector<int64>& index_ids, | 235 const std::vector<int64>& index_ids, |
237 const std::vector<IndexedDBDatabase::IndexKeys>& index_keys) | 236 const std::vector<IndexedDBDatabase::IndexKeys>& index_keys) |
238 : backing_store_(backing_store), | 237 : backing_store_(backing_store), |
239 database_id_(database_id), | 238 database_id_(database_id), |
240 object_store_(object_store), | 239 object_store_(object_store), |
241 key_(key.Pass()), | 240 key_(key.Pass()), |
242 put_mode_(put_mode), | 241 put_mode_(put_mode), |
243 callbacks_(callbacks), | 242 callbacks_(callbacks), |
244 index_ids_(index_ids), | 243 index_ids_(index_ids), |
245 index_keys_(index_keys) { | 244 index_keys_(index_keys) { |
246 value_.swap(*value); | 245 value_.swap(*value); |
247 } | 246 } |
248 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; | 247 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; |
249 | 248 |
250 private: | 249 private: |
251 const scoped_refptr<IndexedDBBackingStore> backing_store_; | 250 const scoped_refptr<IndexedDBBackingStore> backing_store_; |
252 const int64 database_id_; | 251 const int64 database_id_; |
253 const IndexedDBObjectStoreMetadata object_store_; | 252 const IndexedDBObjectStoreMetadata object_store_; |
254 std::vector<char> value_; | 253 std::vector<char> value_; |
255 scoped_ptr<IndexedDBKey> key_; | 254 scoped_ptr<IndexedDBKey> key_; |
256 const IndexedDBDatabase::PutMode put_mode_; | 255 const IndexedDBDatabase::PutMode put_mode_; |
257 const scoped_refptr<IndexedDBCallbacksWrapper> callbacks_; | 256 const scoped_refptr<IndexedDBCallbacks> callbacks_; |
258 const std::vector<int64> index_ids_; | 257 const std::vector<int64> index_ids_; |
259 const std::vector<IndexedDBDatabase::IndexKeys> index_keys_; | 258 const std::vector<IndexedDBDatabase::IndexKeys> index_keys_; |
260 }; | 259 }; |
261 | 260 |
262 class SetIndexesReadyOperation : public IndexedDBTransaction::Operation { | 261 class SetIndexesReadyOperation : public IndexedDBTransaction::Operation { |
263 public: | 262 public: |
264 explicit SetIndexesReadyOperation(size_t index_count) | 263 explicit SetIndexesReadyOperation(size_t index_count) |
265 : index_count_(index_count) {} | 264 : index_count_(index_count) {} |
266 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; | 265 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; |
267 | 266 |
268 private: | 267 private: |
269 const size_t index_count_; | 268 const size_t index_count_; |
270 }; | 269 }; |
271 | 270 |
272 class OpenCursorOperation : public IndexedDBTransaction::Operation { | 271 class OpenCursorOperation : public IndexedDBTransaction::Operation { |
273 public: | 272 public: |
274 OpenCursorOperation(scoped_refptr<IndexedDBBackingStore> backing_store, | 273 OpenCursorOperation(scoped_refptr<IndexedDBBackingStore> backing_store, |
275 int64 database_id, | 274 int64 database_id, |
276 int64 object_store_id, | 275 int64 object_store_id, |
277 int64 index_id, | 276 int64 index_id, |
278 scoped_ptr<IndexedDBKeyRange> key_range, | 277 scoped_ptr<IndexedDBKeyRange> key_range, |
279 indexed_db::CursorDirection direction, | 278 indexed_db::CursorDirection direction, |
280 indexed_db::CursorType cursor_type, | 279 indexed_db::CursorType cursor_type, |
281 IndexedDBDatabase::TaskType task_type, | 280 IndexedDBDatabase::TaskType task_type, |
282 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) | 281 scoped_refptr<IndexedDBCallbacks> callbacks) |
283 : backing_store_(backing_store), | 282 : backing_store_(backing_store), |
284 database_id_(database_id), | 283 database_id_(database_id), |
285 object_store_id_(object_store_id), | 284 object_store_id_(object_store_id), |
286 index_id_(index_id), | 285 index_id_(index_id), |
287 key_range_(key_range.Pass()), | 286 key_range_(key_range.Pass()), |
288 direction_(direction), | 287 direction_(direction), |
289 cursor_type_(cursor_type), | 288 cursor_type_(cursor_type), |
290 task_type_(task_type), | 289 task_type_(task_type), |
291 callbacks_(callbacks) {} | 290 callbacks_(callbacks) {} |
292 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; | 291 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; |
293 | 292 |
294 private: | 293 private: |
295 const scoped_refptr<IndexedDBBackingStore> backing_store_; | 294 const scoped_refptr<IndexedDBBackingStore> backing_store_; |
296 const int64 database_id_; | 295 const int64 database_id_; |
297 const int64 object_store_id_; | 296 const int64 object_store_id_; |
298 const int64 index_id_; | 297 const int64 index_id_; |
299 const scoped_ptr<IndexedDBKeyRange> key_range_; | 298 const scoped_ptr<IndexedDBKeyRange> key_range_; |
300 const indexed_db::CursorDirection direction_; | 299 const indexed_db::CursorDirection direction_; |
301 const indexed_db::CursorType cursor_type_; | 300 const indexed_db::CursorType cursor_type_; |
302 const IndexedDBDatabase::TaskType task_type_; | 301 const IndexedDBDatabase::TaskType task_type_; |
303 const scoped_refptr<IndexedDBCallbacksWrapper> callbacks_; | 302 const scoped_refptr<IndexedDBCallbacks> callbacks_; |
304 }; | 303 }; |
305 | 304 |
306 class CountOperation : public IndexedDBTransaction::Operation { | 305 class CountOperation : public IndexedDBTransaction::Operation { |
307 public: | 306 public: |
308 CountOperation(scoped_refptr<IndexedDBBackingStore> backing_store, | 307 CountOperation(scoped_refptr<IndexedDBBackingStore> backing_store, |
309 int64 database_id, | 308 int64 database_id, |
310 int64 object_store_id, | 309 int64 object_store_id, |
311 int64 index_id, | 310 int64 index_id, |
312 scoped_ptr<IndexedDBKeyRange> key_range, | 311 scoped_ptr<IndexedDBKeyRange> key_range, |
313 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) | 312 scoped_refptr<IndexedDBCallbacks> callbacks) |
314 : backing_store_(backing_store), | 313 : backing_store_(backing_store), |
315 database_id_(database_id), | 314 database_id_(database_id), |
316 object_store_id_(object_store_id), | 315 object_store_id_(object_store_id), |
317 index_id_(index_id), | 316 index_id_(index_id), |
318 key_range_(key_range.Pass()), | 317 key_range_(key_range.Pass()), |
319 callbacks_(callbacks) {} | 318 callbacks_(callbacks) {} |
320 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; | 319 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; |
321 | 320 |
322 private: | 321 private: |
323 const scoped_refptr<IndexedDBBackingStore> backing_store_; | 322 const scoped_refptr<IndexedDBBackingStore> backing_store_; |
324 const int64 database_id_; | 323 const int64 database_id_; |
325 const int64 object_store_id_; | 324 const int64 object_store_id_; |
326 const int64 index_id_; | 325 const int64 index_id_; |
327 const scoped_ptr<IndexedDBKeyRange> key_range_; | 326 const scoped_ptr<IndexedDBKeyRange> key_range_; |
328 const scoped_refptr<IndexedDBCallbacksWrapper> callbacks_; | 327 const scoped_refptr<IndexedDBCallbacks> callbacks_; |
329 }; | 328 }; |
330 | 329 |
331 class DeleteRangeOperation : public IndexedDBTransaction::Operation { | 330 class DeleteRangeOperation : public IndexedDBTransaction::Operation { |
332 public: | 331 public: |
333 DeleteRangeOperation(scoped_refptr<IndexedDBBackingStore> backing_store, | 332 DeleteRangeOperation(scoped_refptr<IndexedDBBackingStore> backing_store, |
334 int64 database_id, | 333 int64 database_id, |
335 int64 object_store_id, | 334 int64 object_store_id, |
336 scoped_ptr<IndexedDBKeyRange> key_range, | 335 scoped_ptr<IndexedDBKeyRange> key_range, |
337 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) | 336 scoped_refptr<IndexedDBCallbacks> callbacks) |
338 : backing_store_(backing_store), | 337 : backing_store_(backing_store), |
339 database_id_(database_id), | 338 database_id_(database_id), |
340 object_store_id_(object_store_id), | 339 object_store_id_(object_store_id), |
341 key_range_(key_range.Pass()), | 340 key_range_(key_range.Pass()), |
342 callbacks_(callbacks) {} | 341 callbacks_(callbacks) {} |
343 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; | 342 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; |
344 | 343 |
345 private: | 344 private: |
346 const scoped_refptr<IndexedDBBackingStore> backing_store_; | 345 const scoped_refptr<IndexedDBBackingStore> backing_store_; |
347 const int64 database_id_; | 346 const int64 database_id_; |
348 const int64 object_store_id_; | 347 const int64 object_store_id_; |
349 const scoped_ptr<IndexedDBKeyRange> key_range_; | 348 const scoped_ptr<IndexedDBKeyRange> key_range_; |
350 const scoped_refptr<IndexedDBCallbacksWrapper> callbacks_; | 349 const scoped_refptr<IndexedDBCallbacks> callbacks_; |
351 }; | 350 }; |
352 | 351 |
353 class ClearOperation : public IndexedDBTransaction::Operation { | 352 class ClearOperation : public IndexedDBTransaction::Operation { |
354 public: | 353 public: |
355 ClearOperation(scoped_refptr<IndexedDBBackingStore> backing_store, | 354 ClearOperation(scoped_refptr<IndexedDBBackingStore> backing_store, |
356 int64 database_id, | 355 int64 database_id, |
357 int64 object_store_id, | 356 int64 object_store_id, |
358 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) | 357 scoped_refptr<IndexedDBCallbacks> callbacks) |
359 : backing_store_(backing_store), | 358 : backing_store_(backing_store), |
360 database_id_(database_id), | 359 database_id_(database_id), |
361 object_store_id_(object_store_id), | 360 object_store_id_(object_store_id), |
362 callbacks_(callbacks) {} | 361 callbacks_(callbacks) {} |
363 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; | 362 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; |
364 | 363 |
365 private: | 364 private: |
366 const scoped_refptr<IndexedDBBackingStore> backing_store_; | 365 const scoped_refptr<IndexedDBBackingStore> backing_store_; |
367 const int64 database_id_; | 366 const int64 database_id_; |
368 const int64 object_store_id_; | 367 const int64 object_store_id_; |
369 const scoped_refptr<IndexedDBCallbacksWrapper> callbacks_; | 368 const scoped_refptr<IndexedDBCallbacks> callbacks_; |
370 }; | 369 }; |
371 | 370 |
372 class IndexedDBDatabase::PendingOpenCall { | 371 class IndexedDBDatabase::PendingOpenCall { |
373 public: | 372 public: |
374 PendingOpenCall( | 373 PendingOpenCall(scoped_refptr<IndexedDBCallbacks> callbacks, |
375 scoped_refptr<IndexedDBCallbacksWrapper> callbacks, | 374 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, |
376 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, | 375 int64 transaction_id, |
377 int64 transaction_id, | 376 int64 version) |
378 int64 version) | |
379 : callbacks_(callbacks), | 377 : callbacks_(callbacks), |
380 database_callbacks_(database_callbacks), | 378 database_callbacks_(database_callbacks), |
381 version_(version), | 379 version_(version), |
382 transaction_id_(transaction_id) {} | 380 transaction_id_(transaction_id) {} |
383 scoped_refptr<IndexedDBCallbacksWrapper> Callbacks() { return callbacks_; } | 381 scoped_refptr<IndexedDBCallbacks> Callbacks() { return callbacks_; } |
384 scoped_refptr<IndexedDBDatabaseCallbacks> DatabaseCallbacks() { | 382 scoped_refptr<IndexedDBDatabaseCallbacks> DatabaseCallbacks() { |
385 return database_callbacks_; | 383 return database_callbacks_; |
386 } | 384 } |
387 int64 Version() { return version_; } | 385 int64 Version() { return version_; } |
388 int64 TransactionId() const { return transaction_id_; } | 386 int64 TransactionId() const { return transaction_id_; } |
389 | 387 |
390 private: | 388 private: |
391 scoped_refptr<IndexedDBCallbacksWrapper> callbacks_; | 389 scoped_refptr<IndexedDBCallbacks> callbacks_; |
392 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks_; | 390 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks_; |
393 int64 version_; | 391 int64 version_; |
394 const int64 transaction_id_; | 392 const int64 transaction_id_; |
395 }; | 393 }; |
396 | 394 |
397 class IndexedDBDatabase::PendingDeleteCall { | 395 class IndexedDBDatabase::PendingDeleteCall { |
398 public: | 396 public: |
399 explicit PendingDeleteCall(scoped_refptr<IndexedDBCallbacksWrapper> callbacks) | 397 explicit PendingDeleteCall(scoped_refptr<IndexedDBCallbacks> callbacks) |
400 : callbacks_(callbacks) {} | 398 : callbacks_(callbacks) {} |
401 scoped_refptr<IndexedDBCallbacksWrapper> Callbacks() { return callbacks_; } | 399 scoped_refptr<IndexedDBCallbacks> Callbacks() { return callbacks_; } |
402 | 400 |
403 private: | 401 private: |
404 scoped_refptr<IndexedDBCallbacksWrapper> callbacks_; | 402 scoped_refptr<IndexedDBCallbacks> callbacks_; |
405 }; | 403 }; |
406 | 404 |
407 scoped_refptr<IndexedDBDatabase> IndexedDBDatabase::Create( | 405 scoped_refptr<IndexedDBDatabase> IndexedDBDatabase::Create( |
408 const string16& name, | 406 const string16& name, |
409 IndexedDBBackingStore* database, | 407 IndexedDBBackingStore* database, |
410 IndexedDBFactory* factory, | 408 IndexedDBFactory* factory, |
411 const string16& unique_identifier) { | 409 const string16& unique_identifier) { |
412 scoped_refptr<IndexedDBDatabase> backend = | 410 scoped_refptr<IndexedDBDatabase> backend = |
413 new IndexedDBDatabase(name, database, factory, unique_identifier); | 411 new IndexedDBDatabase(name, database, factory, unique_identifier); |
414 if (!backend->OpenInternal()) | 412 if (!backend->OpenInternal()) |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 } | 693 } |
696 | 694 |
697 void IndexedDBDatabase::Abort(int64 transaction_id, | 695 void IndexedDBDatabase::Abort(int64 transaction_id, |
698 const IndexedDBDatabaseError& error) { | 696 const IndexedDBDatabaseError& error) { |
699 // If the transaction is unknown, then it has already been aborted by the | 697 // If the transaction is unknown, then it has already been aborted by the |
700 // backend before this call so it is safe to ignore it. | 698 // backend before this call so it is safe to ignore it. |
701 if (transactions_.find(transaction_id) != transactions_.end()) | 699 if (transactions_.find(transaction_id) != transactions_.end()) |
702 transactions_[transaction_id]->Abort(error); | 700 transactions_[transaction_id]->Abort(error); |
703 } | 701 } |
704 | 702 |
705 void IndexedDBDatabase::Get( | 703 void IndexedDBDatabase::Get(int64 transaction_id, |
706 int64 transaction_id, | 704 int64 object_store_id, |
707 int64 object_store_id, | 705 int64 index_id, |
708 int64 index_id, | 706 scoped_ptr<IndexedDBKeyRange> key_range, |
709 scoped_ptr<IndexedDBKeyRange> key_range, | 707 bool key_only, |
710 bool key_only, | 708 scoped_refptr<IndexedDBCallbacks> callbacks) { |
711 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) { | |
712 IDB_TRACE("IndexedDBDatabase::Get"); | 709 IDB_TRACE("IndexedDBDatabase::Get"); |
713 TransactionMap::const_iterator trans_iterator = | 710 TransactionMap::const_iterator trans_iterator = |
714 transactions_.find(transaction_id); | 711 transactions_.find(transaction_id); |
715 if (trans_iterator == transactions_.end()) | 712 if (trans_iterator == transactions_.end()) |
716 return; | 713 return; |
717 IndexedDBDatabaseMetadata::ObjectStoreMap::const_iterator store_iterator = | 714 IndexedDBDatabaseMetadata::ObjectStoreMap::const_iterator store_iterator = |
718 metadata_.object_stores.find(object_store_id); | 715 metadata_.object_stores.find(object_store_id); |
719 if (store_iterator == metadata_.object_stores.end()) | 716 if (store_iterator == metadata_.object_stores.end()) |
720 return; | 717 return; |
721 IndexedDBTransaction* transaction = trans_iterator->second; | 718 IndexedDBTransaction* transaction = trans_iterator->second; |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
897 object_store_id, | 894 object_store_id, |
898 static_cast<int64>(floor(key->number())) + 1, | 895 static_cast<int64>(floor(key->number())) + 1, |
899 check_current); | 896 check_current); |
900 } | 897 } |
901 | 898 |
902 void IndexedDBDatabase::Put(int64 transaction_id, | 899 void IndexedDBDatabase::Put(int64 transaction_id, |
903 int64 object_store_id, | 900 int64 object_store_id, |
904 std::vector<char>* value, | 901 std::vector<char>* value, |
905 scoped_ptr<IndexedDBKey> key, | 902 scoped_ptr<IndexedDBKey> key, |
906 PutMode put_mode, | 903 PutMode put_mode, |
907 scoped_refptr<IndexedDBCallbacksWrapper> callbacks, | 904 scoped_refptr<IndexedDBCallbacks> callbacks, |
908 const std::vector<int64>& index_ids, | 905 const std::vector<int64>& index_ids, |
909 const std::vector<IndexKeys>& index_keys) { | 906 const std::vector<IndexKeys>& index_keys) { |
910 IDB_TRACE("IndexedDBDatabase::Put"); | 907 IDB_TRACE("IndexedDBDatabase::Put"); |
911 TransactionMap::const_iterator trans_iterator = | 908 TransactionMap::const_iterator trans_iterator = |
912 transactions_.find(transaction_id); | 909 transactions_.find(transaction_id); |
913 if (trans_iterator == transactions_.end()) | 910 if (trans_iterator == transactions_.end()) |
914 return; | 911 return; |
915 IndexedDBTransaction* transaction = trans_iterator->second; | 912 IndexedDBTransaction* transaction = trans_iterator->second; |
916 DCHECK_NE(transaction->mode(), indexed_db::TRANSACTION_READ_ONLY); | 913 DCHECK_NE(transaction->mode(), indexed_db::TRANSACTION_READ_ONLY); |
917 | 914 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
976 callbacks_->OnError( | 973 callbacks_->OnError( |
977 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionConstraintError, | 974 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionConstraintError, |
978 "Key already exists in the object store.")); | 975 "Key already exists in the object store.")); |
979 return; | 976 return; |
980 } | 977 } |
981 } | 978 } |
982 | 979 |
983 ScopedVector<IndexWriter> index_writers; | 980 ScopedVector<IndexWriter> index_writers; |
984 string16 error_message; | 981 string16 error_message; |
985 bool obeys_constraints = false; | 982 bool obeys_constraints = false; |
986 bool backing_store_success = | 983 bool backing_store_success = MakeIndexWriters(transaction, |
987 MakeIndexWriters(transaction, | 984 backing_store_.get(), |
988 backing_store_.get(), | 985 database_id_, |
989 database_id_, | 986 object_store_, |
990 object_store_, | 987 *key, |
991 *key, | 988 key_was_generated, |
992 key_was_generated, | 989 index_ids_, |
993 index_ids_, | 990 index_keys_, |
994 index_keys_, | 991 &index_writers, |
995 &index_writers, | 992 &error_message, |
996 &error_message, | 993 &obeys_constraints); |
997 &obeys_constraints); | |
998 if (!backing_store_success) { | 994 if (!backing_store_success) { |
999 callbacks_->OnError(IndexedDBDatabaseError( | 995 callbacks_->OnError(IndexedDBDatabaseError( |
1000 WebKit::WebIDBDatabaseExceptionUnknownError, | 996 WebKit::WebIDBDatabaseExceptionUnknownError, |
1001 "Internal error: backing store error updating index keys.")); | 997 "Internal error: backing store error updating index keys.")); |
1002 return; | 998 return; |
1003 } | 999 } |
1004 if (!obeys_constraints) { | 1000 if (!obeys_constraints) { |
1005 callbacks_->OnError(IndexedDBDatabaseError( | 1001 callbacks_->OnError(IndexedDBDatabaseError( |
1006 WebKit::WebIDBDatabaseExceptionConstraintError, error_message)); | 1002 WebKit::WebIDBDatabaseExceptionConstraintError, error_message)); |
1007 return; | 1003 return; |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1152 } | 1148 } |
1153 | 1149 |
1154 void IndexedDBDatabase::OpenCursor( | 1150 void IndexedDBDatabase::OpenCursor( |
1155 int64 transaction_id, | 1151 int64 transaction_id, |
1156 int64 object_store_id, | 1152 int64 object_store_id, |
1157 int64 index_id, | 1153 int64 index_id, |
1158 scoped_ptr<IndexedDBKeyRange> key_range, | 1154 scoped_ptr<IndexedDBKeyRange> key_range, |
1159 indexed_db::CursorDirection direction, | 1155 indexed_db::CursorDirection direction, |
1160 bool key_only, | 1156 bool key_only, |
1161 TaskType task_type, | 1157 TaskType task_type, |
1162 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) { | 1158 scoped_refptr<IndexedDBCallbacks> callbacks) { |
1163 IDB_TRACE("IndexedDBDatabase::OpenCursor"); | 1159 IDB_TRACE("IndexedDBDatabase::OpenCursor"); |
1164 TransactionMap::const_iterator trans_iterator = | 1160 TransactionMap::const_iterator trans_iterator = |
1165 transactions_.find(transaction_id); | 1161 transactions_.find(transaction_id); |
1166 if (trans_iterator == transactions_.end()) | 1162 if (trans_iterator == transactions_.end()) |
1167 return; | 1163 return; |
1168 IndexedDBTransaction* transaction = trans_iterator->second; | 1164 IndexedDBTransaction* transaction = trans_iterator->second; |
1169 | 1165 |
1170 transaction->ScheduleTask(new OpenCursorOperation( | 1166 transaction->ScheduleTask(new OpenCursorOperation( |
1171 backing_store_, | 1167 backing_store_, |
1172 id(), | 1168 id(), |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1225 } | 1221 } |
1226 | 1222 |
1227 IndexedDBDatabase::TaskType task_type( | 1223 IndexedDBDatabase::TaskType task_type( |
1228 static_cast<IndexedDBDatabase::TaskType>(task_type_)); | 1224 static_cast<IndexedDBDatabase::TaskType>(task_type_)); |
1229 scoped_refptr<IndexedDBCursor> cursor = IndexedDBCursor::Create( | 1225 scoped_refptr<IndexedDBCursor> cursor = IndexedDBCursor::Create( |
1230 backing_store_cursor.Pass(), cursor_type_, task_type, transaction); | 1226 backing_store_cursor.Pass(), cursor_type_, task_type, transaction); |
1231 callbacks_->OnSuccess( | 1227 callbacks_->OnSuccess( |
1232 cursor, cursor->key(), cursor->primary_key(), cursor->Value()); | 1228 cursor, cursor->key(), cursor->primary_key(), cursor->Value()); |
1233 } | 1229 } |
1234 | 1230 |
1235 void IndexedDBDatabase::Count( | 1231 void IndexedDBDatabase::Count(int64 transaction_id, |
1236 int64 transaction_id, | 1232 int64 object_store_id, |
1237 int64 object_store_id, | 1233 int64 index_id, |
1238 int64 index_id, | 1234 scoped_ptr<IndexedDBKeyRange> key_range, |
1239 scoped_ptr<IndexedDBKeyRange> key_range, | 1235 scoped_refptr<IndexedDBCallbacks> callbacks) { |
1240 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) { | |
1241 IDB_TRACE("IndexedDBDatabase::Count"); | 1236 IDB_TRACE("IndexedDBDatabase::Count"); |
1242 TransactionMap::const_iterator trans_iterator = | 1237 TransactionMap::const_iterator trans_iterator = |
1243 transactions_.find(transaction_id); | 1238 transactions_.find(transaction_id); |
1244 if (trans_iterator == transactions_.end()) | 1239 if (trans_iterator == transactions_.end()) |
1245 return; | 1240 return; |
1246 IndexedDBTransaction* transaction = trans_iterator->second; | 1241 IndexedDBTransaction* transaction = trans_iterator->second; |
1247 | 1242 |
1248 DCHECK(metadata_.object_stores.find(object_store_id) != | 1243 DCHECK(metadata_.object_stores.find(object_store_id) != |
1249 metadata_.object_stores.end()); | 1244 metadata_.object_stores.end()); |
1250 transaction->ScheduleTask(new CountOperation(backing_store_, | 1245 transaction->ScheduleTask(new CountOperation(backing_store_, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1285 ++count; | 1280 ++count; |
1286 } while (backing_store_cursor->ContinueFunction()); | 1281 } while (backing_store_cursor->ContinueFunction()); |
1287 | 1282 |
1288 callbacks_->OnSuccess(count); | 1283 callbacks_->OnSuccess(count); |
1289 } | 1284 } |
1290 | 1285 |
1291 void IndexedDBDatabase::DeleteRange( | 1286 void IndexedDBDatabase::DeleteRange( |
1292 int64 transaction_id, | 1287 int64 transaction_id, |
1293 int64 object_store_id, | 1288 int64 object_store_id, |
1294 scoped_ptr<IndexedDBKeyRange> key_range, | 1289 scoped_ptr<IndexedDBKeyRange> key_range, |
1295 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) { | 1290 scoped_refptr<IndexedDBCallbacks> callbacks) { |
1296 IDB_TRACE("IndexedDBDatabase::DeleteRange"); | 1291 IDB_TRACE("IndexedDBDatabase::DeleteRange"); |
1297 TransactionMap::const_iterator trans_iterator = | 1292 TransactionMap::const_iterator trans_iterator = |
1298 transactions_.find(transaction_id); | 1293 transactions_.find(transaction_id); |
1299 if (trans_iterator == transactions_.end()) | 1294 if (trans_iterator == transactions_.end()) |
1300 return; | 1295 return; |
1301 IndexedDBTransaction* transaction = trans_iterator->second; | 1296 IndexedDBTransaction* transaction = trans_iterator->second; |
1302 | 1297 |
1303 transaction->ScheduleTask(new DeleteRangeOperation( | 1298 transaction->ScheduleTask(new DeleteRangeOperation( |
1304 backing_store_, id(), object_store_id, key_range.Pass(), callbacks)); | 1299 backing_store_, id(), object_store_id, key_range.Pass(), callbacks)); |
1305 } | 1300 } |
(...skipping 18 matching lines...) Expand all Loading... |
1324 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionUnknownError, | 1319 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionUnknownError, |
1325 "Internal error deleting data in range")); | 1320 "Internal error deleting data in range")); |
1326 return; | 1321 return; |
1327 } | 1322 } |
1328 } while (backing_store_cursor->ContinueFunction()); | 1323 } while (backing_store_cursor->ContinueFunction()); |
1329 } | 1324 } |
1330 | 1325 |
1331 callbacks_->OnSuccess(); | 1326 callbacks_->OnSuccess(); |
1332 } | 1327 } |
1333 | 1328 |
1334 void IndexedDBDatabase::Clear( | 1329 void IndexedDBDatabase::Clear(int64 transaction_id, |
1335 int64 transaction_id, | 1330 int64 object_store_id, |
1336 int64 object_store_id, | 1331 scoped_refptr<IndexedDBCallbacks> callbacks) { |
1337 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) { | |
1338 IDB_TRACE("IndexedDBDatabase::Clear"); | 1332 IDB_TRACE("IndexedDBDatabase::Clear"); |
1339 TransactionMap::const_iterator trans_iterator = | 1333 TransactionMap::const_iterator trans_iterator = |
1340 transactions_.find(transaction_id); | 1334 transactions_.find(transaction_id); |
1341 if (trans_iterator == transactions_.end()) | 1335 if (trans_iterator == transactions_.end()) |
1342 return; | 1336 return; |
1343 IndexedDBTransaction* transaction = trans_iterator->second; | 1337 IndexedDBTransaction* transaction = trans_iterator->second; |
1344 DCHECK_NE(transaction->mode(), indexed_db::TRANSACTION_READ_ONLY); | 1338 DCHECK_NE(transaction->mode(), indexed_db::TRANSACTION_READ_ONLY); |
1345 | 1339 |
1346 transaction->ScheduleTask( | 1340 transaction->ScheduleTask( |
1347 new ClearOperation(backing_store_, id(), object_store_id, callbacks)); | 1341 new ClearOperation(backing_store_, id(), object_store_id, callbacks)); |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1529 transactions_[transaction_id] = transaction.get(); | 1523 transactions_[transaction_id] = transaction.get(); |
1530 } | 1524 } |
1531 | 1525 |
1532 bool IndexedDBDatabase::IsOpenConnectionBlocked() const { | 1526 bool IndexedDBDatabase::IsOpenConnectionBlocked() const { |
1533 return !pending_delete_calls_.empty() || | 1527 return !pending_delete_calls_.empty() || |
1534 running_version_change_transaction_ || | 1528 running_version_change_transaction_ || |
1535 pending_run_version_change_transaction_call_; | 1529 pending_run_version_change_transaction_call_; |
1536 } | 1530 } |
1537 | 1531 |
1538 void IndexedDBDatabase::OpenConnection( | 1532 void IndexedDBDatabase::OpenConnection( |
1539 scoped_refptr<IndexedDBCallbacksWrapper> callbacks, | 1533 scoped_refptr<IndexedDBCallbacks> callbacks, |
1540 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, | 1534 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, |
1541 int64 transaction_id, | 1535 int64 transaction_id, |
1542 int64 version) { | 1536 int64 version) { |
1543 const WebKit::WebIDBCallbacks::DataLoss kDataLoss = | 1537 const WebKit::WebIDBCallbacks::DataLoss kDataLoss = |
1544 WebKit::WebIDBCallbacks::DataLossNone; | 1538 WebKit::WebIDBCallbacks::DataLossNone; |
1545 OpenConnection( | 1539 OpenConnection( |
1546 callbacks, database_callbacks, transaction_id, version, kDataLoss); | 1540 callbacks, database_callbacks, transaction_id, version, kDataLoss); |
1547 } | 1541 } |
1548 | 1542 |
1549 void IndexedDBDatabase::OpenConnection( | 1543 void IndexedDBDatabase::OpenConnection( |
1550 scoped_refptr<IndexedDBCallbacksWrapper> callbacks, | 1544 scoped_refptr<IndexedDBCallbacks> callbacks, |
1551 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, | 1545 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, |
1552 int64 transaction_id, | 1546 int64 transaction_id, |
1553 int64 version, | 1547 int64 version, |
1554 WebKit::WebIDBCallbacks::DataLoss data_loss) { | 1548 WebKit::WebIDBCallbacks::DataLoss data_loss) { |
1555 DCHECK(backing_store_.get()); | 1549 DCHECK(backing_store_.get()); |
1556 | 1550 |
1557 // TODO(jsbell): Should have a priority queue so that higher version | 1551 // TODO(jsbell): Should have a priority queue so that higher version |
1558 // requests are processed first. http://crbug.com/225850 | 1552 // requests are processed first. http://crbug.com/225850 |
1559 if (IsOpenConnectionBlocked()) { | 1553 if (IsOpenConnectionBlocked()) { |
1560 // The backing store only detects data loss when it is first opened. The | 1554 // The backing store only detects data loss when it is first opened. The |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1627 ASCIIToUTF16(") is less than the existing version (") + | 1621 ASCIIToUTF16(") is less than the existing version (") + |
1628 Int64ToString16(metadata_.int_version) + ASCIIToUTF16(")."))); | 1622 Int64ToString16(metadata_.int_version) + ASCIIToUTF16(")."))); |
1629 return; | 1623 return; |
1630 } | 1624 } |
1631 DCHECK_EQ(version, metadata_.int_version); | 1625 DCHECK_EQ(version, metadata_.int_version); |
1632 database_callbacks_set_.insert(database_callbacks); | 1626 database_callbacks_set_.insert(database_callbacks); |
1633 callbacks->OnSuccess(this, this->metadata()); | 1627 callbacks->OnSuccess(this, this->metadata()); |
1634 } | 1628 } |
1635 | 1629 |
1636 void IndexedDBDatabase::RunVersionChangeTransaction( | 1630 void IndexedDBDatabase::RunVersionChangeTransaction( |
1637 scoped_refptr<IndexedDBCallbacksWrapper> callbacks, | 1631 scoped_refptr<IndexedDBCallbacks> callbacks, |
1638 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, | 1632 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, |
1639 int64 transaction_id, | 1633 int64 transaction_id, |
1640 int64 requested_version, | 1634 int64 requested_version, |
1641 WebKit::WebIDBCallbacks::DataLoss data_loss) { | 1635 WebKit::WebIDBCallbacks::DataLoss data_loss) { |
1642 | 1636 |
1643 DCHECK(callbacks.get()); | 1637 DCHECK(callbacks.get()); |
1644 DCHECK(database_callbacks_set_.has(database_callbacks)); | 1638 DCHECK(database_callbacks_set_.has(database_callbacks)); |
1645 if (ConnectionCount() > 1) { | 1639 if (ConnectionCount() > 1) { |
1646 DCHECK_NE(WebKit::WebIDBCallbacks::DataLossTotal, data_loss); | 1640 DCHECK_NE(WebKit::WebIDBCallbacks::DataLossTotal, data_loss); |
1647 // Front end ensures the event is not fired at connections that have | 1641 // Front end ensures the event is not fired at connections that have |
(...skipping 16 matching lines...) Expand all Loading... |
1664 return; | 1658 return; |
1665 } | 1659 } |
1666 RunVersionChangeTransactionFinal(callbacks, | 1660 RunVersionChangeTransactionFinal(callbacks, |
1667 database_callbacks, | 1661 database_callbacks, |
1668 transaction_id, | 1662 transaction_id, |
1669 requested_version, | 1663 requested_version, |
1670 data_loss); | 1664 data_loss); |
1671 } | 1665 } |
1672 | 1666 |
1673 void IndexedDBDatabase::RunVersionChangeTransactionFinal( | 1667 void IndexedDBDatabase::RunVersionChangeTransactionFinal( |
1674 scoped_refptr<IndexedDBCallbacksWrapper> callbacks, | 1668 scoped_refptr<IndexedDBCallbacks> callbacks, |
1675 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, | 1669 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, |
1676 int64 transaction_id, | 1670 int64 transaction_id, |
1677 int64 requested_version) { | 1671 int64 requested_version) { |
1678 const WebKit::WebIDBCallbacks::DataLoss kDataLoss = | 1672 const WebKit::WebIDBCallbacks::DataLoss kDataLoss = |
1679 WebKit::WebIDBCallbacks::DataLossNone; | 1673 WebKit::WebIDBCallbacks::DataLossNone; |
1680 RunVersionChangeTransactionFinal(callbacks, | 1674 RunVersionChangeTransactionFinal(callbacks, |
1681 database_callbacks, | 1675 database_callbacks, |
1682 transaction_id, | 1676 transaction_id, |
1683 requested_version, | 1677 requested_version, |
1684 kDataLoss); | 1678 kDataLoss); |
1685 } | 1679 } |
1686 | 1680 |
1687 void IndexedDBDatabase::RunVersionChangeTransactionFinal( | 1681 void IndexedDBDatabase::RunVersionChangeTransactionFinal( |
1688 scoped_refptr<IndexedDBCallbacksWrapper> callbacks, | 1682 scoped_refptr<IndexedDBCallbacks> callbacks, |
1689 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, | 1683 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, |
1690 int64 transaction_id, | 1684 int64 transaction_id, |
1691 int64 requested_version, | 1685 int64 requested_version, |
1692 WebKit::WebIDBCallbacks::DataLoss data_loss) { | 1686 WebKit::WebIDBCallbacks::DataLoss data_loss) { |
1693 | 1687 |
1694 std::vector<int64> object_store_ids; | 1688 std::vector<int64> object_store_ids; |
1695 CreateTransaction(transaction_id, | 1689 CreateTransaction(transaction_id, |
1696 database_callbacks, | 1690 database_callbacks, |
1697 object_store_ids, | 1691 object_store_ids, |
1698 indexed_db::TRANSACTION_VERSION_CHANGE); | 1692 indexed_db::TRANSACTION_VERSION_CHANGE); |
1699 scoped_refptr<IndexedDBTransaction> transaction = | 1693 scoped_refptr<IndexedDBTransaction> transaction = |
1700 transactions_[transaction_id]; | 1694 transactions_[transaction_id]; |
1701 | 1695 |
1702 transaction->ScheduleTask( | 1696 transaction->ScheduleTask( |
1703 new VersionChangeOperation(this, | 1697 new VersionChangeOperation(this, |
1704 transaction_id, | 1698 transaction_id, |
1705 requested_version, | 1699 requested_version, |
1706 callbacks, | 1700 callbacks, |
1707 database_callbacks, | 1701 database_callbacks, |
1708 data_loss), | 1702 data_loss), |
1709 new VersionChangeAbortOperation( | 1703 new VersionChangeAbortOperation( |
1710 this, metadata_.version, metadata_.int_version)); | 1704 this, metadata_.version, metadata_.int_version)); |
1711 | 1705 |
1712 DCHECK(!pending_second_half_open_); | 1706 DCHECK(!pending_second_half_open_); |
1713 } | 1707 } |
1714 | 1708 |
1715 void IndexedDBDatabase::DeleteDatabase( | 1709 void IndexedDBDatabase::DeleteDatabase( |
1716 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) { | 1710 scoped_refptr<IndexedDBCallbacks> callbacks) { |
1717 | 1711 |
1718 if (IsDeleteDatabaseBlocked()) { | 1712 if (IsDeleteDatabaseBlocked()) { |
1719 for (DatabaseCallbacksSet::const_iterator it = | 1713 for (DatabaseCallbacksSet::const_iterator it = |
1720 database_callbacks_set_.begin(); | 1714 database_callbacks_set_.begin(); |
1721 it != database_callbacks_set_.end(); | 1715 it != database_callbacks_set_.end(); |
1722 ++it) { | 1716 ++it) { |
1723 // Front end ensures the event is not fired at connections that have | 1717 // Front end ensures the event is not fired at connections that have |
1724 // close_pending set. | 1718 // close_pending set. |
1725 (*it)->OnVersionChange(metadata_.int_version, | 1719 (*it)->OnVersionChange(metadata_.int_version, |
1726 IndexedDBDatabaseMetadata::NO_INT_VERSION); | 1720 IndexedDBDatabaseMetadata::NO_INT_VERSION); |
1727 } | 1721 } |
1728 // TODO(jsbell): Only fire OnBlocked if there are open | 1722 // TODO(jsbell): Only fire OnBlocked if there are open |
1729 // connections after the VersionChangeEvents are received, not | 1723 // connections after the VersionChangeEvents are received, not |
1730 // just set up to fire. http://crbug.com/100123 | 1724 // just set up to fire. http://crbug.com/100123 |
1731 callbacks->OnBlocked(metadata_.int_version); | 1725 callbacks->OnBlocked(metadata_.int_version); |
1732 pending_delete_calls_.push_back(new PendingDeleteCall(callbacks)); | 1726 pending_delete_calls_.push_back(new PendingDeleteCall(callbacks)); |
1733 return; | 1727 return; |
1734 } | 1728 } |
1735 DeleteDatabaseFinal(callbacks); | 1729 DeleteDatabaseFinal(callbacks); |
1736 } | 1730 } |
1737 | 1731 |
1738 bool IndexedDBDatabase::IsDeleteDatabaseBlocked() const { | 1732 bool IndexedDBDatabase::IsDeleteDatabaseBlocked() const { |
1739 return !!ConnectionCount(); | 1733 return !!ConnectionCount(); |
1740 } | 1734 } |
1741 | 1735 |
1742 void IndexedDBDatabase::DeleteDatabaseFinal( | 1736 void IndexedDBDatabase::DeleteDatabaseFinal( |
1743 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) { | 1737 scoped_refptr<IndexedDBCallbacks> callbacks) { |
1744 DCHECK(!IsDeleteDatabaseBlocked()); | 1738 DCHECK(!IsDeleteDatabaseBlocked()); |
1745 DCHECK(backing_store_.get()); | 1739 DCHECK(backing_store_.get()); |
1746 if (!backing_store_->DeleteDatabase(metadata_.name)) { | 1740 if (!backing_store_->DeleteDatabase(metadata_.name)) { |
1747 callbacks->OnError( | 1741 callbacks->OnError( |
1748 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionUnknownError, | 1742 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionUnknownError, |
1749 "Internal error deleting database.")); | 1743 "Internal error deleting database.")); |
1750 return; | 1744 return; |
1751 } | 1745 } |
1752 metadata_.version = kNoStringVersion; | 1746 metadata_.version = kNoStringVersion; |
1753 metadata_.id = kInvalidId; | 1747 metadata_.id = kInvalidId; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1829 | 1823 |
1830 void IndexedDBDatabase::VersionChangeAbortOperation::Perform( | 1824 void IndexedDBDatabase::VersionChangeAbortOperation::Perform( |
1831 IndexedDBTransaction* transaction) { | 1825 IndexedDBTransaction* transaction) { |
1832 IDB_TRACE("VersionChangeAbortOperation"); | 1826 IDB_TRACE("VersionChangeAbortOperation"); |
1833 DCHECK(!transaction); | 1827 DCHECK(!transaction); |
1834 database_->metadata_.version = previous_version_; | 1828 database_->metadata_.version = previous_version_; |
1835 database_->metadata_.int_version = previous_int_version_; | 1829 database_->metadata_.int_version = previous_int_version_; |
1836 } | 1830 } |
1837 | 1831 |
1838 } // namespace content | 1832 } // namespace content |
OLD | NEW |