Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: content/browser/indexed_db/indexed_db_transaction.h

Issue 2941353002: Indexed DB: Use BindOnce / OnceCallback / OnceClosure where applicable (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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_
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_quota_client.cc ('k') | content/browser/indexed_db/indexed_db_transaction.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698