Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(200)

Side by Side Diff: content/browser/indexed_db/indexed_db_database.cc

Issue 2062203004: IDBObserver: Lifetime Management: Adding Observer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: post dmuprh review Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 void IndexedDBDatabase::Abort(int64_t transaction_id, 534 void IndexedDBDatabase::Abort(int64_t transaction_id,
535 const IndexedDBDatabaseError& error) { 535 const IndexedDBDatabaseError& error) {
536 IDB_TRACE1("IndexedDBDatabase::Abort(error)", "txn.id", transaction_id); 536 IDB_TRACE1("IndexedDBDatabase::Abort(error)", "txn.id", transaction_id);
537 // If the transaction is unknown, then it has already been aborted by the 537 // 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. 538 // backend before this call so it is safe to ignore it.
539 IndexedDBTransaction* transaction = GetTransaction(transaction_id); 539 IndexedDBTransaction* transaction = GetTransaction(transaction_id);
540 if (transaction) 540 if (transaction)
541 transaction->Abort(error); 541 transaction->Abort(error);
542 } 542 }
543 543
544 void IndexedDBDatabase::AddPendingObserver(int64_t transaction_id,
545 int64_t observer_id) {
546 IndexedDBTransaction* transaction = GetTransaction(transaction_id);
547 if (!transaction)
548 return;
549 transaction->AddPendingObserver(observer_id);
550 }
551
552 void IndexedDBDatabase::RemovePendingObservers(
553 IndexedDBConnection* connection,
554 const std::vector<int32_t>& pending_observer_ids) {
555 // TODO(palakj): Better Implementation needed.
dmurph 2016/06/23 21:53:04 Remove this todo. This is fine.
palakj1 2016/06/24 00:03:00 Done
556 TransactionMap::iterator it;
557 for (it = transactions_.begin(); it != transactions_.end(); it++) {
558 // Avoid call to RemovePendingObservers for transactions on other
559 // connections.
560 if (it->second->getConnection() == connection)
561 it->second->RemovePendingObservers(pending_observer_ids);
562 }
563 }
564
544 void IndexedDBDatabase::GetAll(int64_t transaction_id, 565 void IndexedDBDatabase::GetAll(int64_t transaction_id,
545 int64_t object_store_id, 566 int64_t object_store_id,
546 int64_t index_id, 567 int64_t index_id,
547 std::unique_ptr<IndexedDBKeyRange> key_range, 568 std::unique_ptr<IndexedDBKeyRange> key_range,
548 bool key_only, 569 bool key_only,
549 int64_t max_count, 570 int64_t max_count,
550 scoped_refptr<IndexedDBCallbacks> callbacks) { 571 scoped_refptr<IndexedDBCallbacks> callbacks) {
551 IDB_TRACE1("IndexedDBDatabase::GetAll", "txn.id", transaction_id); 572 IDB_TRACE1("IndexedDBDatabase::GetAll", "txn.id", transaction_id);
552 IndexedDBTransaction* transaction = GetTransaction(transaction_id); 573 IndexedDBTransaction* transaction = GetTransaction(transaction_id);
553 if (!transaction) 574 if (!transaction)
(...skipping 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1658 if (transactions_.find(transaction_id) != transactions_.end()) 1679 if (transactions_.find(transaction_id) != transactions_.end())
1659 return; 1680 return;
1660 1681
1661 UMA_HISTOGRAM_COUNTS_1000( 1682 UMA_HISTOGRAM_COUNTS_1000(
1662 "WebCore.IndexedDB.Database.OutstandingTransactionCount", 1683 "WebCore.IndexedDB.Database.OutstandingTransactionCount",
1663 transactions_.size()); 1684 transactions_.size());
1664 1685
1665 // The transaction will add itself to this database's coordinator, which 1686 // The transaction will add itself to this database's coordinator, which
1666 // manages the lifetime of the object. 1687 // manages the lifetime of the object.
1667 TransactionCreated(IndexedDBClassFactory::Get()->CreateIndexedDBTransaction( 1688 TransactionCreated(IndexedDBClassFactory::Get()->CreateIndexedDBTransaction(
1668 transaction_id, connection->callbacks(), 1689 transaction_id, connection->weakPtr(), connection->callbacks(),
1669 std::set<int64_t>(object_store_ids.begin(), object_store_ids.end()), mode, 1690 std::set<int64_t>(object_store_ids.begin(), object_store_ids.end()), mode,
1670 this, new IndexedDBBackingStore::Transaction(backing_store_.get()))); 1691 this, new IndexedDBBackingStore::Transaction(backing_store_.get())));
1671 } 1692 }
1672 1693
1673 void IndexedDBDatabase::TransactionCreated(IndexedDBTransaction* transaction) { 1694 void IndexedDBDatabase::TransactionCreated(IndexedDBTransaction* transaction) {
1674 transactions_[transaction->id()] = transaction; 1695 transactions_[transaction->id()] = transaction;
1675 } 1696 }
1676 1697
1677 bool IndexedDBDatabase::IsOpenConnectionBlocked() const { 1698 bool IndexedDBDatabase::IsOpenConnectionBlocked() const {
1678 return !pending_delete_calls_.empty() || 1699 return !pending_delete_calls_.empty() ||
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
1950 1971
1951 void IndexedDBDatabase::VersionChangeAbortOperation( 1972 void IndexedDBDatabase::VersionChangeAbortOperation(
1952 int64_t previous_version, 1973 int64_t previous_version,
1953 IndexedDBTransaction* transaction) { 1974 IndexedDBTransaction* transaction) {
1954 DCHECK(!transaction); 1975 DCHECK(!transaction);
1955 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation"); 1976 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation");
1956 metadata_.version = previous_version; 1977 metadata_.version = previous_version;
1957 } 1978 }
1958 1979
1959 } // namespace content 1980 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698