OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_TRANSACTION_COORDINATOR_H_ |
| 6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_TRANSACTION_COORDINATOR_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <set> |
| 10 |
| 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "content/browser/indexed_db/list_set.h" |
| 14 |
| 15 namespace content { |
| 16 |
| 17 class IndexedDBTransaction; |
| 18 |
| 19 // Transactions are executed in the order the were created. |
| 20 class IndexedDBTransactionCoordinator { |
| 21 public: |
| 22 IndexedDBTransactionCoordinator(); |
| 23 ~IndexedDBTransactionCoordinator(); |
| 24 |
| 25 // Called by transactions as they start and finish. |
| 26 void DidCreateTransaction(IndexedDBTransaction* transaction); |
| 27 void DidStartTransaction(IndexedDBTransaction* transaction); |
| 28 void DidFinishTransaction(IndexedDBTransaction* transaction); |
| 29 |
| 30 #ifndef NDEBUG |
| 31 bool IsActive(IndexedDBTransaction* transaction); |
| 32 #endif |
| 33 |
| 34 // TODO(jsbell): API to handle closed connections. http://crbug.com/241821 |
| 35 |
| 36 private: |
| 37 void ProcessStartedTransactions(); |
| 38 bool CanRunTransaction(IndexedDBTransaction* transaction); |
| 39 |
| 40 // This is just an efficient way to keep references to all transactions. |
| 41 std::map<IndexedDBTransaction*, scoped_refptr<IndexedDBTransaction> > |
| 42 transactions_; |
| 43 // Transactions in different states are grouped below. |
| 44 list_set<IndexedDBTransaction*> queued_transactions_; |
| 45 std::set<IndexedDBTransaction*> started_transactions_; |
| 46 }; |
| 47 |
| 48 } // namespace content |
| 49 |
| 50 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_TRANSACTION_COORDINATOR_H_ |
OLD | NEW |