Roll DEPS for PDFium to 19ae17578f99621100a26dac3e2c7c3dbf7c7cd1
[chromium-blink-merge.git] / content / browser / indexed_db / indexed_db_transaction_coordinator.h
blob890541dfd243b8a5d964a41b17d1e8c75ba5666a
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.
5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_TRANSACTION_COORDINATOR_H_
6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_TRANSACTION_COORDINATOR_H_
8 #include <map>
9 #include <set>
10 #include <vector>
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "content/browser/indexed_db/list_set.h"
16 namespace content {
18 class IndexedDBTransaction;
20 // Transactions are executed in the order the were created.
21 class IndexedDBTransactionCoordinator {
22 public:
23 IndexedDBTransactionCoordinator();
24 ~IndexedDBTransactionCoordinator();
26 // Called by transactions as they start and finish.
27 void DidCreateTransaction(scoped_refptr<IndexedDBTransaction> transaction);
28 void DidFinishTransaction(IndexedDBTransaction* transaction);
30 bool IsRunningVersionChangeTransaction() const;
32 #ifndef NDEBUG
33 bool IsActive(IndexedDBTransaction* transaction);
34 #endif
36 // Makes a snapshot of the transaction queue. For diagnostics only.
37 std::vector<const IndexedDBTransaction*> GetTransactions() const;
39 private:
40 typedef list_set<scoped_refptr<IndexedDBTransaction> > TransactionSet;
42 void ProcessQueuedTransactions();
43 bool CanStartTransaction(IndexedDBTransaction* const transaction,
44 const std::set<int64>& locked_scope) const;
46 // Transactions in different states are grouped below.
47 // list_set is used to provide stable ordering; required by spec
48 // for the queue, convenience for diagnostics for the rest.
49 TransactionSet queued_transactions_;
50 TransactionSet started_transactions_;
52 DISALLOW_COPY_AND_ASSIGN(IndexedDBTransactionCoordinator);
55 } // namespace content
57 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_TRANSACTION_COORDINATOR_H_