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 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_TRANSACTION_COORDINATOR_H_ | 5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_TRANSACTION_COORDINATOR_H_ |
6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_TRANSACTION_COORDINATOR_H_ | 6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_TRANSACTION_COORDINATOR_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <memory> | 11 #include <memory> |
12 #include <set> | 12 #include <set> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "content/browser/indexed_db/list_set.h" | 16 #include "content/browser/indexed_db/list_set.h" |
| 17 #include "content/common/content_export.h" |
17 | 18 |
18 namespace content { | 19 namespace content { |
19 | 20 |
20 class IndexedDBTransaction; | 21 class IndexedDBTransaction; |
| 22 class IndexedDBTransactionCoordinatorTest; |
21 | 23 |
22 // Transactions are executed in the order the were created. | 24 // Transactions are executed in the order the were created. |
23 class IndexedDBTransactionCoordinator { | 25 class CONTENT_EXPORT IndexedDBTransactionCoordinator { |
24 public: | 26 public: |
25 IndexedDBTransactionCoordinator(); | 27 IndexedDBTransactionCoordinator(); |
26 ~IndexedDBTransactionCoordinator(); | 28 ~IndexedDBTransactionCoordinator(); |
27 | 29 |
28 // Called by transactions as they start and finish. | 30 // Called by transactions as they start and finish. |
29 void DidCreateTransaction(IndexedDBTransaction* transaction); | 31 void DidCreateTransaction(IndexedDBTransaction* transaction); |
| 32 void DidCreateObserverTransaction(IndexedDBTransaction* transaction); |
30 void DidFinishTransaction(IndexedDBTransaction* transaction); | 33 void DidFinishTransaction(IndexedDBTransaction* transaction); |
31 | 34 |
32 bool IsRunningVersionChangeTransaction() const; | 35 bool IsRunningVersionChangeTransaction() const; |
33 | 36 |
34 #ifndef NDEBUG | 37 #ifndef NDEBUG |
35 bool IsActive(IndexedDBTransaction* transaction); | 38 bool IsActive(IndexedDBTransaction* transaction); |
36 #endif | 39 #endif |
37 | 40 |
38 // Makes a snapshot of the transaction queue. For diagnostics only. | 41 // Makes a snapshot of the transaction queue. For diagnostics only. |
39 std::vector<const IndexedDBTransaction*> GetTransactions() const; | 42 std::vector<const IndexedDBTransaction*> GetTransactions() const; |
40 | 43 |
41 private: | 44 private: |
| 45 friend class IndexedDBTransactionCoordinatorTest; |
| 46 |
42 void ProcessQueuedTransactions(); | 47 void ProcessQueuedTransactions(); |
43 bool CanStartTransaction(IndexedDBTransaction* const transaction, | 48 bool CanStartTransaction(IndexedDBTransaction* const transaction, |
44 const std::set<int64_t>& locked_scope) const; | 49 const std::set<int64_t>& locked_scope) const; |
45 | 50 |
46 // Transactions in different states are grouped below. | 51 // Transactions in different states are grouped below. |
47 // list_set is used to provide stable ordering; required by spec | 52 // list_set is used to provide stable ordering; required by spec |
48 // for the queue, convenience for diagnostics for the rest. | 53 // for the queue, convenience for diagnostics for the rest. |
49 list_set<IndexedDBTransaction*> queued_transactions_; | 54 list_set<IndexedDBTransaction*> queued_transactions_; |
50 list_set<IndexedDBTransaction*> started_transactions_; | 55 list_set<IndexedDBTransaction*> started_transactions_; |
51 | 56 |
52 DISALLOW_COPY_AND_ASSIGN(IndexedDBTransactionCoordinator); | 57 DISALLOW_COPY_AND_ASSIGN(IndexedDBTransactionCoordinator); |
53 }; | 58 }; |
54 | 59 |
55 } // namespace content | 60 } // namespace content |
56 | 61 |
57 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_TRANSACTION_COORDINATOR_H_ | 62 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_TRANSACTION_COORDINATOR_H_ |
OLD | NEW |