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 16 matching lines...) Expand all Loading... |
27 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h" | 27 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h" |
28 | 28 |
29 namespace content { | 29 namespace content { |
30 | 30 |
31 class BlobWriteCallbackImpl; | 31 class BlobWriteCallbackImpl; |
32 class IndexedDBCursor; | 32 class IndexedDBCursor; |
33 class IndexedDBDatabaseCallbacks; | 33 class IndexedDBDatabaseCallbacks; |
34 | 34 |
35 class CONTENT_EXPORT IndexedDBTransaction { | 35 class CONTENT_EXPORT IndexedDBTransaction { |
36 public: | 36 public: |
37 using Operation = base::Callback<leveldb::Status(IndexedDBTransaction*)>; | 37 using Operation = base::OnceCallback<leveldb::Status(IndexedDBTransaction*)>; |
38 using AbortOperation = base::Closure; | 38 using AbortOperation = base::OnceClosure; |
39 | 39 |
40 enum State { | 40 enum State { |
41 CREATED, // Created, but not yet started by coordinator. | 41 CREATED, // Created, but not yet started by coordinator. |
42 STARTED, // Started by the coordinator. | 42 STARTED, // Started by the coordinator. |
43 COMMITTING, // In the process of committing, possibly waiting for blobs | 43 COMMITTING, // In the process of committing, possibly waiting for blobs |
44 // to be written. | 44 // to be written. |
45 FINISHED, // Either aborted or committed. | 45 FINISHED, // Either aborted or committed. |
46 }; | 46 }; |
47 | 47 |
48 virtual ~IndexedDBTransaction(); | 48 virtual ~IndexedDBTransaction(); |
49 | 49 |
50 leveldb::Status Commit(); | 50 leveldb::Status Commit(); |
51 | 51 |
52 // This object is destroyed by this method. | 52 // This object is destroyed by this method. |
53 void Abort(const IndexedDBDatabaseError& error); | 53 void Abort(const IndexedDBDatabaseError& error); |
54 | 54 |
55 // Called by the transaction coordinator when this transaction is unblocked. | 55 // Called by the transaction coordinator when this transaction is unblocked. |
56 void Start(); | 56 void Start(); |
57 | 57 |
58 // Grabs a snapshot from the database immediately, then starts the | 58 // Grabs a snapshot from the database immediately, then starts the |
59 // transaction. | 59 // transaction. |
60 void GrabSnapshotThenStart(); | 60 void GrabSnapshotThenStart(); |
61 | 61 |
62 blink::WebIDBTransactionMode mode() const { return mode_; } | 62 blink::WebIDBTransactionMode mode() const { return mode_; } |
63 const std::set<int64_t>& scope() const { return object_store_ids_; } | 63 const std::set<int64_t>& scope() const { return object_store_ids_; } |
64 | 64 |
65 // Tasks cannot call Commit. | 65 // Tasks cannot call Commit. |
66 void ScheduleTask(Operation task) { | 66 void ScheduleTask(Operation task) { |
67 ScheduleTask(blink::kWebIDBTaskTypeNormal, task); | 67 ScheduleTask(blink::kWebIDBTaskTypeNormal, std::move(task)); |
68 } | 68 } |
69 void ScheduleTask(blink::WebIDBTaskType, Operation task); | 69 void ScheduleTask(blink::WebIDBTaskType, Operation task); |
70 void ScheduleAbortTask(AbortOperation abort_task); | 70 void ScheduleAbortTask(AbortOperation abort_task); |
71 void RegisterOpenCursor(IndexedDBCursor* cursor); | 71 void RegisterOpenCursor(IndexedDBCursor* cursor); |
72 void UnregisterOpenCursor(IndexedDBCursor* cursor); | 72 void UnregisterOpenCursor(IndexedDBCursor* cursor); |
73 void AddPreemptiveEvent() { pending_preemptive_events_++; } | 73 void AddPreemptiveEvent() { pending_preemptive_events_++; } |
74 void DidCompletePreemptiveEvent() { | 74 void DidCompletePreemptiveEvent() { |
75 pending_preemptive_events_--; | 75 pending_preemptive_events_--; |
76 DCHECK_GE(pending_preemptive_events_, 0); | 76 DCHECK_GE(pending_preemptive_events_, 0); |
77 } | 77 } |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 base::OneShotTimer timeout_timer_; | 222 base::OneShotTimer timeout_timer_; |
223 | 223 |
224 Diagnostics diagnostics_; | 224 Diagnostics diagnostics_; |
225 | 225 |
226 base::WeakPtrFactory<IndexedDBTransaction> ptr_factory_; | 226 base::WeakPtrFactory<IndexedDBTransaction> ptr_factory_; |
227 }; | 227 }; |
228 | 228 |
229 } // namespace content | 229 } // namespace content |
230 | 230 |
231 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_TRANSACTION_H_ | 231 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_TRANSACTION_H_ |
OLD | NEW |