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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
| 10 #include <map> |
10 #include <memory> | 11 #include <memory> |
11 #include <queue> | 12 #include <queue> |
12 #include <set> | 13 #include <set> |
13 #include <stack> | 14 #include <stack> |
| 15 #include <vector> |
14 | 16 |
15 #include "base/gtest_prod_util.h" | 17 #include "base/gtest_prod_util.h" |
16 #include "base/macros.h" | 18 #include "base/macros.h" |
17 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
18 #include "base/time/time.h" | 20 #include "base/time/time.h" |
19 #include "base/timer/timer.h" | 21 #include "base/timer/timer.h" |
20 #include "content/browser/indexed_db/indexed_db_backing_store.h" | 22 #include "content/browser/indexed_db/indexed_db_backing_store.h" |
21 #include "content/browser/indexed_db/indexed_db_connection.h" | 23 #include "content/browser/indexed_db/indexed_db_connection.h" |
22 #include "content/browser/indexed_db/indexed_db_database.h" | 24 #include "content/browser/indexed_db/indexed_db_database.h" |
23 #include "content/browser/indexed_db/indexed_db_database_error.h" | 25 #include "content/browser/indexed_db/indexed_db_database_error.h" |
24 #include "content/browser/indexed_db/indexed_db_observer.h" | 26 #include "content/browser/indexed_db/indexed_db_observer.h" |
25 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h" | 27 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h" |
26 | 28 |
27 namespace content { | 29 namespace content { |
28 | 30 |
29 class BlobWriteCallbackImpl; | 31 class BlobWriteCallbackImpl; |
30 class IndexedDBCursor; | 32 class IndexedDBCursor; |
31 class IndexedDBDatabaseCallbacks; | 33 class IndexedDBChangeHandler; |
32 class IndexedDBObservation; | 34 class IndexedDBObservation; |
33 class IndexedDBObserverChanges; | 35 class IndexedDBObserverChanges; |
34 | 36 |
35 class CONTENT_EXPORT IndexedDBTransaction | 37 class CONTENT_EXPORT IndexedDBTransaction |
36 : public NON_EXPORTED_BASE(base::RefCounted<IndexedDBTransaction>) { | 38 : public NON_EXPORTED_BASE(base::RefCounted<IndexedDBTransaction>) { |
37 public: | 39 public: |
38 typedef base::Callback<void(IndexedDBTransaction*)> Operation; | 40 typedef base::Callback<void(IndexedDBTransaction*)> Operation; |
39 | 41 |
40 enum State { | 42 enum State { |
41 CREATED, // Created, but not yet started by coordinator. | 43 CREATED, // Created, but not yet started by coordinator. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 // observation indices. | 81 // observation indices. |
80 void RecordObserverForLastObservation(int32_t connection_id, | 82 void RecordObserverForLastObservation(int32_t connection_id, |
81 int32_t observer_id); | 83 int32_t observer_id); |
82 | 84 |
83 IndexedDBBackingStore::Transaction* BackingStoreTransaction() { | 85 IndexedDBBackingStore::Transaction* BackingStoreTransaction() { |
84 return transaction_.get(); | 86 return transaction_.get(); |
85 } | 87 } |
86 int64_t id() const { return id_; } | 88 int64_t id() const { return id_; } |
87 | 89 |
88 IndexedDBDatabase* database() const { return database_.get(); } | 90 IndexedDBDatabase* database() const { return database_.get(); } |
89 IndexedDBDatabaseCallbacks* callbacks() const { return callbacks_.get(); } | 91 IndexedDBChangeHandler* change_handler() const { |
| 92 return change_handler_.get(); |
| 93 } |
90 IndexedDBConnection* connection() const { return connection_.get(); } | 94 IndexedDBConnection* connection() const { return connection_.get(); } |
91 | 95 |
92 State state() const { return state_; } | 96 State state() const { return state_; } |
93 bool IsTimeoutTimerRunning() const { return timeout_timer_.IsRunning(); } | 97 bool IsTimeoutTimerRunning() const { return timeout_timer_.IsRunning(); } |
94 | 98 |
95 struct Diagnostics { | 99 struct Diagnostics { |
96 base::Time creation_time; | 100 base::Time creation_time; |
97 base::Time start_time; | 101 base::Time start_time; |
98 int tasks_scheduled; | 102 int tasks_scheduled; |
99 int tasks_completed; | 103 int tasks_completed; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 void Timeout(); | 146 void Timeout(); |
143 | 147 |
144 const int64_t id_; | 148 const int64_t id_; |
145 const std::set<int64_t> object_store_ids_; | 149 const std::set<int64_t> object_store_ids_; |
146 const blink::WebIDBTransactionMode mode_; | 150 const blink::WebIDBTransactionMode mode_; |
147 | 151 |
148 bool used_; | 152 bool used_; |
149 State state_; | 153 State state_; |
150 bool commit_pending_; | 154 bool commit_pending_; |
151 base::WeakPtr<IndexedDBConnection> connection_; | 155 base::WeakPtr<IndexedDBConnection> connection_; |
152 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks_; | 156 scoped_refptr<IndexedDBChangeHandler> change_handler_; |
153 scoped_refptr<IndexedDBDatabase> database_; | 157 scoped_refptr<IndexedDBDatabase> database_; |
154 | 158 |
155 // Observers in pending queue do not listen to changes until activated. | 159 // Observers in pending queue do not listen to changes until activated. |
156 std::vector<std::unique_ptr<IndexedDBObserver>> pending_observers_; | 160 std::vector<std::unique_ptr<IndexedDBObserver>> pending_observers_; |
157 std::map<int32_t, std::unique_ptr<IndexedDBObserverChanges>> | 161 std::map<int32_t, std::unique_ptr<IndexedDBObserverChanges>> |
158 connection_changes_map_; | 162 connection_changes_map_; |
159 | 163 |
160 class TaskQueue { | 164 class TaskQueue { |
161 public: | 165 public: |
162 TaskQueue(); | 166 TaskQueue(); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 // requests are processed before the timer fires, assume the script is | 207 // requests are processed before the timer fires, assume the script is |
204 // unresponsive and abort to unblock the transaction queue. | 208 // unresponsive and abort to unblock the transaction queue. |
205 base::OneShotTimer timeout_timer_; | 209 base::OneShotTimer timeout_timer_; |
206 | 210 |
207 Diagnostics diagnostics_; | 211 Diagnostics diagnostics_; |
208 }; | 212 }; |
209 | 213 |
210 } // namespace content | 214 } // namespace content |
211 | 215 |
212 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_TRANSACTION_H_ | 216 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_TRANSACTION_H_ |
OLD | NEW |