Chromium Code Reviews| 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 11 matching lines...) Expand all Loading... | |
| 22 #include "base/stl_util.h" | 22 #include "base/stl_util.h" |
| 23 #include "base/strings/string_number_conversions.h" | 23 #include "base/strings/string_number_conversions.h" |
| 24 #include "base/strings/utf_string_conversions.h" | 24 #include "base/strings/utf_string_conversions.h" |
| 25 #include "content/browser/indexed_db/indexed_db_blob_info.h" | 25 #include "content/browser/indexed_db/indexed_db_blob_info.h" |
| 26 #include "content/browser/indexed_db/indexed_db_class_factory.h" | 26 #include "content/browser/indexed_db/indexed_db_class_factory.h" |
| 27 #include "content/browser/indexed_db/indexed_db_connection.h" | 27 #include "content/browser/indexed_db/indexed_db_connection.h" |
| 28 #include "content/browser/indexed_db/indexed_db_context_impl.h" | 28 #include "content/browser/indexed_db/indexed_db_context_impl.h" |
| 29 #include "content/browser/indexed_db/indexed_db_cursor.h" | 29 #include "content/browser/indexed_db/indexed_db_cursor.h" |
| 30 #include "content/browser/indexed_db/indexed_db_factory.h" | 30 #include "content/browser/indexed_db/indexed_db_factory.h" |
| 31 #include "content/browser/indexed_db/indexed_db_index_writer.h" | 31 #include "content/browser/indexed_db/indexed_db_index_writer.h" |
| 32 #include "content/browser/indexed_db/indexed_db_observer.h" | |
| 32 #include "content/browser/indexed_db/indexed_db_pending_connection.h" | 33 #include "content/browser/indexed_db/indexed_db_pending_connection.h" |
| 33 #include "content/browser/indexed_db/indexed_db_return_value.h" | 34 #include "content/browser/indexed_db/indexed_db_return_value.h" |
| 34 #include "content/browser/indexed_db/indexed_db_tracing.h" | 35 #include "content/browser/indexed_db/indexed_db_tracing.h" |
| 35 #include "content/browser/indexed_db/indexed_db_transaction.h" | 36 #include "content/browser/indexed_db/indexed_db_transaction.h" |
| 36 #include "content/browser/indexed_db/indexed_db_value.h" | 37 #include "content/browser/indexed_db/indexed_db_value.h" |
| 37 #include "content/common/indexed_db/indexed_db_constants.h" | 38 #include "content/common/indexed_db/indexed_db_constants.h" |
| 38 #include "content/common/indexed_db/indexed_db_key_path.h" | 39 #include "content/common/indexed_db/indexed_db_key_path.h" |
| 39 #include "content/common/indexed_db/indexed_db_key_range.h" | 40 #include "content/common/indexed_db/indexed_db_key_range.h" |
| 40 #include "content/public/common/content_switches.h" | 41 #include "content/public/common/content_switches.h" |
| 41 #include "storage/browser/blob/blob_data_handle.h" | 42 #include "storage/browser/blob/blob_data_handle.h" |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 534 void IndexedDBDatabase::Abort(int64_t transaction_id, | 535 void IndexedDBDatabase::Abort(int64_t transaction_id, |
| 535 const IndexedDBDatabaseError& error) { | 536 const IndexedDBDatabaseError& error) { |
| 536 IDB_TRACE1("IndexedDBDatabase::Abort(error)", "txn.id", transaction_id); | 537 IDB_TRACE1("IndexedDBDatabase::Abort(error)", "txn.id", transaction_id); |
| 537 // If the transaction is unknown, then it has already been aborted by the | 538 // If the transaction is unknown, then it has already been aborted by the |
| 538 // backend before this call so it is safe to ignore it. | 539 // backend before this call so it is safe to ignore it. |
| 539 IndexedDBTransaction* transaction = GetTransaction(transaction_id); | 540 IndexedDBTransaction* transaction = GetTransaction(transaction_id); |
| 540 if (transaction) | 541 if (transaction) |
| 541 transaction->Abort(error); | 542 transaction->Abort(error); |
| 542 } | 543 } |
| 543 | 544 |
| 545 void IndexedDBDatabase::Observe(int64_t transaction_id, int64_t observer_id) { | |
| 546 IndexedDBTransaction* transaction = GetTransaction(transaction_id); | |
| 547 if (!transaction) | |
| 548 return; | |
| 549 transaction->AddPendingObserver(observer_id, | |
| 550 new IndexedDBObserver(observer_id)); | |
| 551 } | |
| 552 | |
| 553 void IndexedDBDatabase::Unobserve(std::vector<int64_t> observersToRemove) { | |
| 554 // TODO (palakj): Remove observer from pending_observer queue of transactions | |
| 555 typedef std::map<int64_t, IndexedDBObserver*>::iterator Iterator; | |
| 556 for (uint32_t i = 0; i < observersToRemove.size(); i++) { | |
| 557 Iterator obs = active_observers_.find(observersToRemove[i]); | |
|
dmurph
2016/06/17 09:05:06
replace these with active_observers_.erase(observe
palakj1
2016/06/18 05:13:40
Done
| |
| 558 active_observers_.erase(obs); | |
| 559 } | |
| 560 } | |
| 561 | |
| 544 void IndexedDBDatabase::GetAll(int64_t transaction_id, | 562 void IndexedDBDatabase::GetAll(int64_t transaction_id, |
| 545 int64_t object_store_id, | 563 int64_t object_store_id, |
| 546 int64_t index_id, | 564 int64_t index_id, |
| 547 std::unique_ptr<IndexedDBKeyRange> key_range, | 565 std::unique_ptr<IndexedDBKeyRange> key_range, |
| 548 bool key_only, | 566 bool key_only, |
| 549 int64_t max_count, | 567 int64_t max_count, |
| 550 scoped_refptr<IndexedDBCallbacks> callbacks) { | 568 scoped_refptr<IndexedDBCallbacks> callbacks) { |
| 551 IDB_TRACE1("IndexedDBDatabase::GetAll", "txn.id", transaction_id); | 569 IDB_TRACE1("IndexedDBDatabase::GetAll", "txn.id", transaction_id); |
| 552 IndexedDBTransaction* transaction = GetTransaction(transaction_id); | 570 IndexedDBTransaction* transaction = GetTransaction(transaction_id); |
| 553 if (!transaction) | 571 if (!transaction) |
| (...skipping 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1950 | 1968 |
| 1951 void IndexedDBDatabase::VersionChangeAbortOperation( | 1969 void IndexedDBDatabase::VersionChangeAbortOperation( |
| 1952 int64_t previous_version, | 1970 int64_t previous_version, |
| 1953 IndexedDBTransaction* transaction) { | 1971 IndexedDBTransaction* transaction) { |
| 1954 DCHECK(!transaction); | 1972 DCHECK(!transaction); |
| 1955 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation"); | 1973 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation"); |
| 1956 metadata_.version = previous_version; | 1974 metadata_.version = previous_version; |
| 1957 } | 1975 } |
| 1958 | 1976 |
| 1959 } // namespace content | 1977 } // namespace content |
| OLD | NEW |