| 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 11 matching lines...) Expand all Loading... |
| 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 "content/browser/indexed_db/indexed_db_observer.h" | 24 #include "content/browser/indexed_db/indexed_db_observer.h" |
| 25 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h" | 25 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h" |
| 26 | 26 |
| 27 namespace content { | 27 namespace content { |
| 28 | 28 |
| 29 class BlobWriteCallbackImpl; | 29 class BlobWriteCallbackImpl; |
| 30 class IndexedDBCursor; | 30 class IndexedDBCursor; |
| 31 class IndexedDBDatabaseCallbacks; | 31 class IndexedDBDatabaseCallbacks; |
| 32 class IndexedDBObservation; | |
| 33 class IndexedDBObserverChanges; | |
| 34 | 32 |
| 35 class CONTENT_EXPORT IndexedDBTransaction | 33 class CONTENT_EXPORT IndexedDBTransaction |
| 36 : public NON_EXPORTED_BASE(base::RefCounted<IndexedDBTransaction>) { | 34 : public NON_EXPORTED_BASE(base::RefCounted<IndexedDBTransaction>) { |
| 37 public: | 35 public: |
| 38 typedef base::Callback<void(IndexedDBTransaction*)> Operation; | 36 typedef base::Callback<void(IndexedDBTransaction*)> Operation; |
| 39 | 37 |
| 40 enum State { | 38 enum State { |
| 41 CREATED, // Created, but not yet started by coordinator. | 39 CREATED, // Created, but not yet started by coordinator. |
| 42 STARTED, // Started by the coordinator. | 40 STARTED, // Started by the coordinator. |
| 43 COMMITTING, // In the process of committing, possibly waiting for blobs | 41 COMMITTING, // In the process of committing, possibly waiting for blobs |
| (...skipping 23 matching lines...) Expand all Loading... |
| 67 pending_preemptive_events_--; | 65 pending_preemptive_events_--; |
| 68 DCHECK_GE(pending_preemptive_events_, 0); | 66 DCHECK_GE(pending_preemptive_events_, 0); |
| 69 } | 67 } |
| 70 void AddPendingObserver(int32_t observer_id, | 68 void AddPendingObserver(int32_t observer_id, |
| 71 const IndexedDBObserver::Options& options); | 69 const IndexedDBObserver::Options& options); |
| 72 // Delete pending observers with ID's listed in |pending_observer_ids|. | 70 // Delete pending observers with ID's listed in |pending_observer_ids|. |
| 73 void RemovePendingObservers(const std::vector<int32_t>& pending_observer_ids); | 71 void RemovePendingObservers(const std::vector<int32_t>& pending_observer_ids); |
| 74 | 72 |
| 75 // Adds observation for the connection. | 73 // Adds observation for the connection. |
| 76 void AddObservation(int32_t connection_id, | 74 void AddObservation(int32_t connection_id, |
| 77 std::unique_ptr<IndexedDBObservation>); | 75 ::indexed_db::mojom::ObservationPtr observation); |
| 78 // Adds the last observation index to observer_id's list of recorded | 76 // Adds the last observation index to observer_id's list of recorded |
| 79 // observation indices. | 77 // observation indices. |
| 80 void RecordObserverForLastObservation(int32_t connection_id, | 78 void RecordObserverForLastObservation(int32_t connection_id, |
| 81 int32_t observer_id); | 79 int32_t observer_id); |
| 82 | 80 |
| 83 IndexedDBBackingStore::Transaction* BackingStoreTransaction() { | 81 IndexedDBBackingStore::Transaction* BackingStoreTransaction() { |
| 84 return transaction_.get(); | 82 return transaction_.get(); |
| 85 } | 83 } |
| 86 int64_t id() const { return id_; } | 84 int64_t id() const { return id_; } |
| 87 | 85 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 | 145 |
| 148 bool used_; | 146 bool used_; |
| 149 State state_; | 147 State state_; |
| 150 bool commit_pending_; | 148 bool commit_pending_; |
| 151 base::WeakPtr<IndexedDBConnection> connection_; | 149 base::WeakPtr<IndexedDBConnection> connection_; |
| 152 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks_; | 150 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks_; |
| 153 scoped_refptr<IndexedDBDatabase> database_; | 151 scoped_refptr<IndexedDBDatabase> database_; |
| 154 | 152 |
| 155 // Observers in pending queue do not listen to changes until activated. | 153 // Observers in pending queue do not listen to changes until activated. |
| 156 std::vector<std::unique_ptr<IndexedDBObserver>> pending_observers_; | 154 std::vector<std::unique_ptr<IndexedDBObserver>> pending_observers_; |
| 157 std::map<int32_t, std::unique_ptr<IndexedDBObserverChanges>> | 155 std::map<int32_t, ::indexed_db::mojom::ObserverChangesPtr> |
| 158 connection_changes_map_; | 156 connection_changes_map_; |
| 159 | 157 |
| 160 class TaskQueue { | 158 class TaskQueue { |
| 161 public: | 159 public: |
| 162 TaskQueue(); | 160 TaskQueue(); |
| 163 ~TaskQueue(); | 161 ~TaskQueue(); |
| 164 bool empty() const { return queue_.empty(); } | 162 bool empty() const { return queue_.empty(); } |
| 165 void push(Operation task) { queue_.push(task); } | 163 void push(Operation task) { queue_.push(task); } |
| 166 Operation pop(); | 164 Operation pop(); |
| 167 void clear(); | 165 void clear(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 // requests are processed before the timer fires, assume the script is | 201 // requests are processed before the timer fires, assume the script is |
| 204 // unresponsive and abort to unblock the transaction queue. | 202 // unresponsive and abort to unblock the transaction queue. |
| 205 base::OneShotTimer timeout_timer_; | 203 base::OneShotTimer timeout_timer_; |
| 206 | 204 |
| 207 Diagnostics diagnostics_; | 205 Diagnostics diagnostics_; |
| 208 }; | 206 }; |
| 209 | 207 |
| 210 } // namespace content | 208 } // namespace content |
| 211 | 209 |
| 212 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_TRANSACTION_H_ | 210 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_TRANSACTION_H_ |
| OLD | NEW |