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 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 #include "base/timer/timer.h" | 16 #include "base/timer/timer.h" |
17 #include "content/browser/indexed_db/indexed_db_backing_store.h" | 17 #include "content/browser/indexed_db/indexed_db_backing_store.h" |
18 #include "content/browser/indexed_db/indexed_db_database.h" | 18 #include "content/browser/indexed_db/indexed_db_database.h" |
19 #include "content/browser/indexed_db/indexed_db_database_error.h" | 19 #include "content/browser/indexed_db/indexed_db_database_error.h" |
| 20 #include "third_party/WebKit/public/platform/WebIDBTypes.h" |
20 | 21 |
21 namespace content { | 22 namespace content { |
22 | 23 |
23 class BlobWriteCallbackImpl; | 24 class BlobWriteCallbackImpl; |
24 class IndexedDBCursor; | 25 class IndexedDBCursor; |
25 class IndexedDBDatabaseCallbacks; | 26 class IndexedDBDatabaseCallbacks; |
26 | 27 |
27 class CONTENT_EXPORT IndexedDBTransaction | 28 class CONTENT_EXPORT IndexedDBTransaction |
28 : public NON_EXPORTED_BASE(base::RefCounted<IndexedDBTransaction>) { | 29 : public NON_EXPORTED_BASE(base::RefCounted<IndexedDBTransaction>) { |
29 public: | 30 public: |
30 typedef base::Callback<void(IndexedDBTransaction*)> Operation; | 31 typedef base::Callback<void(IndexedDBTransaction*)> Operation; |
31 | 32 |
32 IndexedDBTransaction( | 33 IndexedDBTransaction( |
33 int64 id, | 34 int64 id, |
34 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks, | 35 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks, |
35 const std::set<int64>& object_store_ids, | 36 const std::set<int64>& object_store_ids, |
36 indexed_db::TransactionMode, | 37 blink::WebIDBTransactionMode, |
37 IndexedDBDatabase* db, | 38 IndexedDBDatabase* db, |
38 IndexedDBBackingStore::Transaction* backing_store_transaction); | 39 IndexedDBBackingStore::Transaction* backing_store_transaction); |
39 | 40 |
40 virtual void Abort(); | 41 virtual void Abort(); |
41 void Commit(); | 42 void Commit(); |
42 void Abort(const IndexedDBDatabaseError& error); | 43 void Abort(const IndexedDBDatabaseError& error); |
43 | 44 |
44 // Called by the transaction coordinator when this transaction is unblocked. | 45 // Called by the transaction coordinator when this transaction is unblocked. |
45 void Start(); | 46 void Start(); |
46 | 47 |
47 indexed_db::TransactionMode mode() const { return mode_; } | 48 blink::WebIDBTransactionMode mode() const { return mode_; } |
48 const std::set<int64>& scope() const { return object_store_ids_; } | 49 const std::set<int64>& scope() const { return object_store_ids_; } |
49 | 50 |
50 void ScheduleTask(Operation task) { | 51 void ScheduleTask(Operation task) { |
51 ScheduleTask(IndexedDBDatabase::NORMAL_TASK, task); | 52 ScheduleTask(blink::WebIDBTaskTypeNormal, task); |
52 } | 53 } |
53 void ScheduleTask(IndexedDBDatabase::TaskType, Operation task); | 54 void ScheduleTask(blink::WebIDBTaskType, Operation task); |
54 void ScheduleAbortTask(Operation abort_task); | 55 void ScheduleAbortTask(Operation abort_task); |
55 void RegisterOpenCursor(IndexedDBCursor* cursor); | 56 void RegisterOpenCursor(IndexedDBCursor* cursor); |
56 void UnregisterOpenCursor(IndexedDBCursor* cursor); | 57 void UnregisterOpenCursor(IndexedDBCursor* cursor); |
57 void AddPreemptiveEvent() { pending_preemptive_events_++; } | 58 void AddPreemptiveEvent() { pending_preemptive_events_++; } |
58 void DidCompletePreemptiveEvent() { | 59 void DidCompletePreemptiveEvent() { |
59 pending_preemptive_events_--; | 60 pending_preemptive_events_--; |
60 DCHECK_GE(pending_preemptive_events_, 0); | 61 DCHECK_GE(pending_preemptive_events_, 0); |
61 } | 62 } |
62 IndexedDBBackingStore::Transaction* BackingStoreTransaction() { | 63 IndexedDBBackingStore::Transaction* BackingStoreTransaction() { |
63 return transaction_.get(); | 64 return transaction_.get(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 bool HasPendingTasks() const; | 107 bool HasPendingTasks() const; |
107 | 108 |
108 void BlobWriteComplete(bool success); | 109 void BlobWriteComplete(bool success); |
109 void ProcessTaskQueue(); | 110 void ProcessTaskQueue(); |
110 void CloseOpenCursors(); | 111 void CloseOpenCursors(); |
111 void CommitPhaseTwo(); | 112 void CommitPhaseTwo(); |
112 void Timeout(); | 113 void Timeout(); |
113 | 114 |
114 const int64 id_; | 115 const int64 id_; |
115 const std::set<int64> object_store_ids_; | 116 const std::set<int64> object_store_ids_; |
116 const indexed_db::TransactionMode mode_; | 117 const blink::WebIDBTransactionMode mode_; |
117 | 118 |
118 bool used_; | 119 bool used_; |
119 State state_; | 120 State state_; |
120 bool commit_pending_; | 121 bool commit_pending_; |
121 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks_; | 122 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks_; |
122 scoped_refptr<IndexedDBDatabase> database_; | 123 scoped_refptr<IndexedDBDatabase> database_; |
123 | 124 |
124 class TaskQueue { | 125 class TaskQueue { |
125 public: | 126 public: |
126 TaskQueue(); | 127 TaskQueue(); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 // requests are processed before the timer fires, assume the script is | 168 // requests are processed before the timer fires, assume the script is |
168 // unresponsive and abort to unblock the transaction queue. | 169 // unresponsive and abort to unblock the transaction queue. |
169 base::OneShotTimer<IndexedDBTransaction> timeout_timer_; | 170 base::OneShotTimer<IndexedDBTransaction> timeout_timer_; |
170 | 171 |
171 Diagnostics diagnostics_; | 172 Diagnostics diagnostics_; |
172 }; | 173 }; |
173 | 174 |
174 } // namespace content | 175 } // namespace content |
175 | 176 |
176 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_TRANSACTION_H_ | 177 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_TRANSACTION_H_ |
OLD | NEW |