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_H_ | 5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_TRANSACTION_H_ |
6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_TRANSACTION_H_ | 6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_TRANSACTION_H_ |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
9 #include <set> | 9 #include <set> |
10 #include <stack> | 10 #include <stack> |
11 #include <vector> | |
12 | 11 |
13 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
14 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
16 #include "content/browser/indexed_db/indexed_db_backing_store.h" | 15 #include "content/browser/indexed_db/indexed_db_backing_store.h" |
17 #include "content/browser/indexed_db/indexed_db_database.h" | 16 #include "content/browser/indexed_db/indexed_db_database.h" |
18 #include "content/browser/indexed_db/indexed_db_database_error.h" | 17 #include "content/browser/indexed_db/indexed_db_database_error.h" |
19 | 18 |
20 namespace content { | 19 namespace content { |
21 | 20 |
22 class IndexedDBCursor; | 21 class IndexedDBCursor; |
23 class IndexedDBDatabaseCallbacks; | 22 class IndexedDBDatabaseCallbacks; |
24 | 23 |
25 class IndexedDBTransaction : public base::RefCounted<IndexedDBTransaction> { | 24 class IndexedDBTransaction : public base::RefCounted<IndexedDBTransaction> { |
26 public: | 25 public: |
27 static scoped_refptr<IndexedDBTransaction> Create( | 26 IndexedDBTransaction(int64 id, |
28 int64 transaction_id, | 27 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks, |
29 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks, | 28 const std::set<int64>& object_store_ids, |
30 const std::vector<int64>& scope, | 29 indexed_db::TransactionMode, |
31 indexed_db::TransactionMode, | 30 IndexedDBDatabase* db); |
32 IndexedDBDatabase* db); | |
33 | 31 |
34 virtual void Abort(); | 32 virtual void Abort(); |
35 void Commit(); | 33 void Commit(); |
36 | 34 |
37 class Operation { | 35 class Operation { |
38 public: | 36 public: |
39 Operation() {} | 37 Operation() {} |
40 virtual ~Operation() {} | 38 virtual ~Operation() {} |
41 virtual void Perform(IndexedDBTransaction* transaction) = 0; | 39 virtual void Perform(IndexedDBTransaction* transaction) = 0; |
42 }; | 40 }; |
(...skipping 27 matching lines...) Expand all Loading... |
70 int64 id() const { return id_; } | 68 int64 id() const { return id_; } |
71 | 69 |
72 IndexedDBDatabase* database() const { return database_; } | 70 IndexedDBDatabase* database() const { return database_; } |
73 IndexedDBDatabaseCallbacks* connection() const { return callbacks_; } | 71 IndexedDBDatabaseCallbacks* connection() const { return callbacks_; } |
74 | 72 |
75 protected: | 73 protected: |
76 virtual ~IndexedDBTransaction(); | 74 virtual ~IndexedDBTransaction(); |
77 friend class base::RefCounted<IndexedDBTransaction>; | 75 friend class base::RefCounted<IndexedDBTransaction>; |
78 | 76 |
79 private: | 77 private: |
80 IndexedDBTransaction(int64 id, | |
81 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks, | |
82 const std::set<int64>& object_store_ids, | |
83 indexed_db::TransactionMode, | |
84 IndexedDBDatabase* db); | |
85 | |
86 enum State { | 78 enum State { |
87 UNUSED, // Created, but no tasks yet. | 79 UNUSED, // Created, but no tasks yet. |
88 START_PENDING, // Enqueued tasks, but backing store transaction not yet | 80 START_PENDING, // Enqueued tasks, but backing store transaction not yet |
89 // started. | 81 // started. |
90 RUNNING, // Backing store transaction started but not yet finished. | 82 RUNNING, // Backing store transaction started but not yet finished. |
91 FINISHED, // Either aborted or committed. | 83 FINISHED, // Either aborted or committed. |
92 }; | 84 }; |
93 | 85 |
94 void Start(); | 86 void Start(); |
95 | 87 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 | 134 |
143 bool should_process_queue_; | 135 bool should_process_queue_; |
144 int pending_preemptive_events_; | 136 int pending_preemptive_events_; |
145 | 137 |
146 std::set<IndexedDBCursor*> open_cursors_; | 138 std::set<IndexedDBCursor*> open_cursors_; |
147 }; | 139 }; |
148 | 140 |
149 } // namespace content | 141 } // namespace content |
150 | 142 |
151 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_TRANSACTION_H_ | 143 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_TRANSACTION_H_ |
OLD | NEW |