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