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 | 8 |
9 #include <limits> | 9 #include <limits> |
10 #include <memory> | 10 #include <memory> |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 | 472 |
473 IndexedDBTransaction* IndexedDBDatabase::GetTransaction( | 473 IndexedDBTransaction* IndexedDBDatabase::GetTransaction( |
474 int64_t transaction_id) const { | 474 int64_t transaction_id) const { |
475 const auto& trans_iterator = transactions_.find(transaction_id); | 475 const auto& trans_iterator = transactions_.find(transaction_id); |
476 if (trans_iterator == transactions_.end()) | 476 if (trans_iterator == transactions_.end()) |
477 return NULL; | 477 return NULL; |
478 return trans_iterator->second; | 478 return trans_iterator->second; |
479 } | 479 } |
480 | 480 |
481 bool IndexedDBDatabase::ValidateObjectStoreId(int64_t object_store_id) const { | 481 bool IndexedDBDatabase::ValidateObjectStoreId(int64_t object_store_id) const { |
482 if (!ContainsKey(metadata_.object_stores, object_store_id)) { | 482 if (!base::ContainsKey(metadata_.object_stores, object_store_id)) { |
483 DLOG(ERROR) << "Invalid object_store_id"; | 483 DLOG(ERROR) << "Invalid object_store_id"; |
484 return false; | 484 return false; |
485 } | 485 } |
486 return true; | 486 return true; |
487 } | 487 } |
488 | 488 |
489 bool IndexedDBDatabase::ValidateObjectStoreIdAndIndexId( | 489 bool IndexedDBDatabase::ValidateObjectStoreIdAndIndexId( |
490 int64_t object_store_id, | 490 int64_t object_store_id, |
491 int64_t index_id) const { | 491 int64_t index_id) const { |
492 if (!ValidateObjectStoreId(object_store_id)) | 492 if (!ValidateObjectStoreId(object_store_id)) |
493 return false; | 493 return false; |
494 const IndexedDBObjectStoreMetadata& object_store_metadata = | 494 const IndexedDBObjectStoreMetadata& object_store_metadata = |
495 metadata_.object_stores.find(object_store_id)->second; | 495 metadata_.object_stores.find(object_store_id)->second; |
496 if (!ContainsKey(object_store_metadata.indexes, index_id)) { | 496 if (!base::ContainsKey(object_store_metadata.indexes, index_id)) { |
497 DLOG(ERROR) << "Invalid index_id"; | 497 DLOG(ERROR) << "Invalid index_id"; |
498 return false; | 498 return false; |
499 } | 499 } |
500 return true; | 500 return true; |
501 } | 501 } |
502 | 502 |
503 bool IndexedDBDatabase::ValidateObjectStoreIdAndOptionalIndexId( | 503 bool IndexedDBDatabase::ValidateObjectStoreIdAndOptionalIndexId( |
504 int64_t object_store_id, | 504 int64_t object_store_id, |
505 int64_t index_id) const { | 505 int64_t index_id) const { |
506 if (!ValidateObjectStoreId(object_store_id)) | 506 if (!ValidateObjectStoreId(object_store_id)) |
507 return false; | 507 return false; |
508 const IndexedDBObjectStoreMetadata& object_store_metadata = | 508 const IndexedDBObjectStoreMetadata& object_store_metadata = |
509 metadata_.object_stores.find(object_store_id)->second; | 509 metadata_.object_stores.find(object_store_id)->second; |
510 if (index_id != IndexedDBIndexMetadata::kInvalidId && | 510 if (index_id != IndexedDBIndexMetadata::kInvalidId && |
511 !ContainsKey(object_store_metadata.indexes, index_id)) { | 511 !base::ContainsKey(object_store_metadata.indexes, index_id)) { |
512 DLOG(ERROR) << "Invalid index_id"; | 512 DLOG(ERROR) << "Invalid index_id"; |
513 return false; | 513 return false; |
514 } | 514 } |
515 return true; | 515 return true; |
516 } | 516 } |
517 | 517 |
518 bool IndexedDBDatabase::ValidateObjectStoreIdAndNewIndexId( | 518 bool IndexedDBDatabase::ValidateObjectStoreIdAndNewIndexId( |
519 int64_t object_store_id, | 519 int64_t object_store_id, |
520 int64_t index_id) const { | 520 int64_t index_id) const { |
521 if (!ValidateObjectStoreId(object_store_id)) | 521 if (!ValidateObjectStoreId(object_store_id)) |
522 return false; | 522 return false; |
523 const IndexedDBObjectStoreMetadata& object_store_metadata = | 523 const IndexedDBObjectStoreMetadata& object_store_metadata = |
524 metadata_.object_stores.find(object_store_id)->second; | 524 metadata_.object_stores.find(object_store_id)->second; |
525 if (ContainsKey(object_store_metadata.indexes, index_id)) { | 525 if (base::ContainsKey(object_store_metadata.indexes, index_id)) { |
526 DLOG(ERROR) << "Invalid index_id"; | 526 DLOG(ERROR) << "Invalid index_id"; |
527 return false; | 527 return false; |
528 } | 528 } |
529 return true; | 529 return true; |
530 } | 530 } |
531 | 531 |
532 void IndexedDBDatabase::CreateObjectStore(int64_t transaction_id, | 532 void IndexedDBDatabase::CreateObjectStore(int64_t transaction_id, |
533 int64_t object_store_id, | 533 int64_t object_store_id, |
534 const base::string16& name, | 534 const base::string16& name, |
535 const IndexedDBKeyPath& key_path, | 535 const IndexedDBKeyPath& key_path, |
536 bool auto_increment) { | 536 bool auto_increment) { |
537 IDB_TRACE1("IndexedDBDatabase::CreateObjectStore", "txn.id", transaction_id); | 537 IDB_TRACE1("IndexedDBDatabase::CreateObjectStore", "txn.id", transaction_id); |
538 IndexedDBTransaction* transaction = GetTransaction(transaction_id); | 538 IndexedDBTransaction* transaction = GetTransaction(transaction_id); |
539 if (!transaction) | 539 if (!transaction) |
540 return; | 540 return; |
541 DCHECK_EQ(transaction->mode(), blink::WebIDBTransactionModeVersionChange); | 541 DCHECK_EQ(transaction->mode(), blink::WebIDBTransactionModeVersionChange); |
542 | 542 |
543 if (ContainsKey(metadata_.object_stores, object_store_id)) { | 543 if (base::ContainsKey(metadata_.object_stores, object_store_id)) { |
544 DLOG(ERROR) << "Invalid object_store_id"; | 544 DLOG(ERROR) << "Invalid object_store_id"; |
545 return; | 545 return; |
546 } | 546 } |
547 | 547 |
548 UMA_HISTOGRAM_ENUMERATION("WebCore.IndexedDB.Schema.ObjectStore.KeyPathType", | 548 UMA_HISTOGRAM_ENUMERATION("WebCore.IndexedDB.Schema.ObjectStore.KeyPathType", |
549 HistogramKeyPathType(key_path), KEY_PATH_TYPE_MAX); | 549 HistogramKeyPathType(key_path), KEY_PATH_TYPE_MAX); |
550 UMA_HISTOGRAM_BOOLEAN("WebCore.IndexedDB.Schema.ObjectStore.AutoIncrement", | 550 UMA_HISTOGRAM_BOOLEAN("WebCore.IndexedDB.Schema.ObjectStore.AutoIncrement", |
551 auto_increment); | 551 auto_increment); |
552 | 552 |
553 // Store creation is done synchronously, as it may be followed by | 553 // Store creation is done synchronously, as it may be followed by |
(...skipping 1450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2004 | 2004 |
2005 void IndexedDBDatabase::VersionChangeAbortOperation( | 2005 void IndexedDBDatabase::VersionChangeAbortOperation( |
2006 int64_t previous_version, | 2006 int64_t previous_version, |
2007 IndexedDBTransaction* transaction) { | 2007 IndexedDBTransaction* transaction) { |
2008 DCHECK(!transaction); | 2008 DCHECK(!transaction); |
2009 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation"); | 2009 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation"); |
2010 metadata_.version = previous_version; | 2010 metadata_.version = previous_version; |
2011 } | 2011 } |
2012 | 2012 |
2013 } // namespace content | 2013 } // namespace content |
OLD | NEW |