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