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 <memory> | 10 #include <memory> |
(...skipping 10 matching lines...) Expand all Loading... | |
21 #include "content/browser/indexed_db/indexed_db_connection.h" | 21 #include "content/browser/indexed_db/indexed_db_connection.h" |
22 #include "content/browser/indexed_db/indexed_db_database.h" | 22 #include "content/browser/indexed_db/indexed_db_database.h" |
23 #include "content/browser/indexed_db/indexed_db_database_error.h" | 23 #include "content/browser/indexed_db/indexed_db_database_error.h" |
24 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h" | 24 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h" |
25 | 25 |
26 namespace content { | 26 namespace content { |
27 | 27 |
28 class BlobWriteCallbackImpl; | 28 class BlobWriteCallbackImpl; |
29 class IndexedDBCursor; | 29 class IndexedDBCursor; |
30 class IndexedDBDatabaseCallbacks; | 30 class IndexedDBDatabaseCallbacks; |
31 class IndexedDBObservation; | |
31 class IndexedDBObserver; | 32 class IndexedDBObserver; |
33 class IndexedDBObserverChanges; | |
32 | 34 |
33 class CONTENT_EXPORT IndexedDBTransaction | 35 class CONTENT_EXPORT IndexedDBTransaction |
34 : public NON_EXPORTED_BASE(base::RefCounted<IndexedDBTransaction>) { | 36 : public NON_EXPORTED_BASE(base::RefCounted<IndexedDBTransaction>) { |
35 public: | 37 public: |
38 // using Changes = IndexedDBDatabase::Changes; | |
Marijn Kruisselbrink
2016/07/08 23:57:57
don't add commented out code?
palakj1
2016/07/11 05:33:26
Done.
| |
39 | |
36 typedef base::Callback<void(IndexedDBTransaction*)> Operation; | 40 typedef base::Callback<void(IndexedDBTransaction*)> Operation; |
37 | 41 |
38 enum State { | 42 enum State { |
39 CREATED, // Created, but not yet started by coordinator. | 43 CREATED, // Created, but not yet started by coordinator. |
40 STARTED, // Started by the coordinator. | 44 STARTED, // Started by the coordinator. |
41 COMMITTING, // In the process of committing, possibly waiting for blobs | 45 COMMITTING, // In the process of committing, possibly waiting for blobs |
42 // to be written. | 46 // to be written. |
43 FINISHED, // Either aborted or committed. | 47 FINISHED, // Either aborted or committed. |
44 }; | 48 }; |
45 | 49 |
(...skipping 16 matching lines...) Expand all Loading... | |
62 void UnregisterOpenCursor(IndexedDBCursor* cursor); | 66 void UnregisterOpenCursor(IndexedDBCursor* cursor); |
63 void AddPreemptiveEvent() { pending_preemptive_events_++; } | 67 void AddPreemptiveEvent() { pending_preemptive_events_++; } |
64 void DidCompletePreemptiveEvent() { | 68 void DidCompletePreemptiveEvent() { |
65 pending_preemptive_events_--; | 69 pending_preemptive_events_--; |
66 DCHECK_GE(pending_preemptive_events_, 0); | 70 DCHECK_GE(pending_preemptive_events_, 0); |
67 } | 71 } |
68 void AddPendingObserver(int32_t observer_id); | 72 void AddPendingObserver(int32_t observer_id); |
69 // Delete pending observers with ID's listed in |pending_observer_ids|. | 73 // Delete pending observers with ID's listed in |pending_observer_ids|. |
70 void RemovePendingObservers(const std::vector<int32_t>& pending_observer_ids); | 74 void RemovePendingObservers(const std::vector<int32_t>& pending_observer_ids); |
71 | 75 |
76 // Adds observation for the connection. | |
77 void AddObservation(int32_t connection_id, | |
78 std::unique_ptr<IndexedDBObservation>); | |
79 // Adds the last observation index to observer_id's list of recorded | |
80 // observation indices. | |
81 void RecordObserverForLastObservation(int32_t observer_id, | |
82 int32_t connection_id); | |
83 | |
72 IndexedDBBackingStore::Transaction* BackingStoreTransaction() { | 84 IndexedDBBackingStore::Transaction* BackingStoreTransaction() { |
73 return transaction_.get(); | 85 return transaction_.get(); |
74 } | 86 } |
75 int64_t id() const { return id_; } | 87 int64_t id() const { return id_; } |
76 | 88 |
77 IndexedDBDatabase* database() const { return database_.get(); } | 89 IndexedDBDatabase* database() const { return database_.get(); } |
78 IndexedDBDatabaseCallbacks* callbacks() const { return callbacks_.get(); } | 90 IndexedDBDatabaseCallbacks* callbacks() const { return callbacks_.get(); } |
79 IndexedDBConnection* connection() const { return connection_.get(); } | 91 IndexedDBConnection* connection() const { return connection_.get(); } |
80 | 92 |
81 State state() const { return state_; } | 93 State state() const { return state_; } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 bool used_; | 149 bool used_; |
138 State state_; | 150 State state_; |
139 bool commit_pending_; | 151 bool commit_pending_; |
140 base::WeakPtr<IndexedDBConnection> connection_; | 152 base::WeakPtr<IndexedDBConnection> connection_; |
141 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks_; | 153 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks_; |
142 scoped_refptr<IndexedDBDatabase> database_; | 154 scoped_refptr<IndexedDBDatabase> database_; |
143 | 155 |
144 // Observers in pending queue do not listen to changes until activated. | 156 // Observers in pending queue do not listen to changes until activated. |
145 std::vector<std::unique_ptr<IndexedDBObserver>> pending_observers_; | 157 std::vector<std::unique_ptr<IndexedDBObserver>> pending_observers_; |
146 | 158 |
159 typedef std::map<int32_t, std::unique_ptr<IndexedDBObserverChanges>> | |
Marijn Kruisselbrink
2016/07/08 23:57:57
using instead of typedef
palakj1
2016/07/11 05:33:26
done.
| |
160 ConnectionChangeMap; | |
161 ConnectionChangeMap connection_changes_map_; | |
162 | |
147 class TaskQueue { | 163 class TaskQueue { |
148 public: | 164 public: |
149 TaskQueue(); | 165 TaskQueue(); |
150 ~TaskQueue(); | 166 ~TaskQueue(); |
151 bool empty() const { return queue_.empty(); } | 167 bool empty() const { return queue_.empty(); } |
152 void push(Operation task) { queue_.push(task); } | 168 void push(Operation task) { queue_.push(task); } |
153 Operation pop(); | 169 Operation pop(); |
154 void clear(); | 170 void clear(); |
155 | 171 |
156 private: | 172 private: |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
190 // requests are processed before the timer fires, assume the script is | 206 // requests are processed before the timer fires, assume the script is |
191 // unresponsive and abort to unblock the transaction queue. | 207 // unresponsive and abort to unblock the transaction queue. |
192 base::OneShotTimer timeout_timer_; | 208 base::OneShotTimer timeout_timer_; |
193 | 209 |
194 Diagnostics diagnostics_; | 210 Diagnostics diagnostics_; |
195 }; | 211 }; |
196 | 212 |
197 } // namespace content | 213 } // namespace content |
198 | 214 |
199 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_TRANSACTION_H_ | 215 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_TRANSACTION_H_ |
OLD | NEW |