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

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

Issue 2601983002: [IndexedDB] Adding transaction and value support to observers (Closed)
Patch Set: added comments and bug link Created 3 years, 11 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>
11 #include <queue> 11 #include <queue>
12 #include <set> 12 #include <set>
13 #include <stack> 13 #include <stack>
14 14
15 #include "base/gtest_prod_util.h" 15 #include "base/gtest_prod_util.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
18 #include "base/memory/weak_ptr.h" 18 #include "base/memory/weak_ptr.h"
19 #include "base/time/time.h" 19 #include "base/time/time.h"
20 #include "base/timer/timer.h" 20 #include "base/timer/timer.h"
21 #include "content/browser/indexed_db/indexed_db_backing_store.h" 21 #include "content/browser/indexed_db/indexed_db_backing_store.h"
22 #include "content/browser/indexed_db/indexed_db_connection.h" 22 #include "content/browser/indexed_db/indexed_db_connection.h"
23 #include "content/browser/indexed_db/indexed_db_database.h" 23 #include "content/browser/indexed_db/indexed_db_database.h"
24 #include "content/browser/indexed_db/indexed_db_database_error.h" 24 #include "content/browser/indexed_db/indexed_db_database_error.h"
25 #include "content/browser/indexed_db/indexed_db_observer.h" 25 #include "content/browser/indexed_db/indexed_db_observer.h"
26 #include "content/common/indexed_db/indexed_db.mojom.h"
26 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h" 27 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h"
27 28
28 namespace content { 29 namespace content {
29 30
30 class BlobWriteCallbackImpl; 31 class BlobWriteCallbackImpl;
31 class IndexedDBCursor; 32 class IndexedDBCursor;
32 class IndexedDBDatabaseCallbacks; 33 class IndexedDBDatabaseCallbacks;
33 34
34 class CONTENT_EXPORT IndexedDBTransaction { 35 class CONTENT_EXPORT IndexedDBTransaction {
35 public: 36 public:
(...skipping 12 matching lines...) Expand all
48 49
49 leveldb::Status Commit(); 50 leveldb::Status Commit();
50 51
51 // This object is destroyed by these method calls. 52 // This object is destroyed by these method calls.
52 virtual void Abort(); 53 virtual void Abort();
53 void Abort(const IndexedDBDatabaseError& error); 54 void Abort(const IndexedDBDatabaseError& error);
54 55
55 // Called by the transaction coordinator when this transaction is unblocked. 56 // Called by the transaction coordinator when this transaction is unblocked.
56 void Start(); 57 void Start();
57 58
59 // Grabs a snapshot from the database immediately, then starts the
60 // transaction.
61 void GrabSnapshotThenStart();
62
58 blink::WebIDBTransactionMode mode() const { return mode_; } 63 blink::WebIDBTransactionMode mode() const { return mode_; }
59 const std::set<int64_t>& scope() const { return object_store_ids_; } 64 const std::set<int64_t>& scope() const { return object_store_ids_; }
60 65
61 // Tasks cannot call Commit. 66 // Tasks cannot call Commit.
62 void ScheduleTask(Operation task) { 67 void ScheduleTask(Operation task) {
63 ScheduleTask(blink::WebIDBTaskTypeNormal, task); 68 ScheduleTask(blink::WebIDBTaskTypeNormal, task);
64 } 69 }
65 void ScheduleTask(blink::WebIDBTaskType, Operation task); 70 void ScheduleTask(blink::WebIDBTaskType, Operation task);
66 void ScheduleAbortTask(AbortOperation abort_task); 71 void ScheduleAbortTask(AbortOperation abort_task);
67 void RegisterOpenCursor(IndexedDBCursor* cursor); 72 void RegisterOpenCursor(IndexedDBCursor* cursor);
68 void UnregisterOpenCursor(IndexedDBCursor* cursor); 73 void UnregisterOpenCursor(IndexedDBCursor* cursor);
69 void AddPreemptiveEvent() { pending_preemptive_events_++; } 74 void AddPreemptiveEvent() { pending_preemptive_events_++; }
70 void DidCompletePreemptiveEvent() { 75 void DidCompletePreemptiveEvent() {
71 pending_preemptive_events_--; 76 pending_preemptive_events_--;
72 DCHECK_GE(pending_preemptive_events_, 0); 77 DCHECK_GE(pending_preemptive_events_, 0);
73 } 78 }
74 void AddPendingObserver(int32_t observer_id, 79 void AddPendingObserver(int32_t observer_id,
75 const IndexedDBObserver::Options& options); 80 const IndexedDBObserver::Options& options);
76 // Delete pending observers with ID's listed in |pending_observer_ids|. 81 // Delete pending observers with ID's listed in |pending_observer_ids|.
77 void RemovePendingObservers(const std::vector<int32_t>& pending_observer_ids); 82 void RemovePendingObservers(const std::vector<int32_t>& pending_observer_ids);
78 83
79 // Adds observation for the connection. 84 // Adds observation for the connection.
80 void AddObservation(int32_t connection_id, 85 void AddObservation(int32_t connection_id,
81 ::indexed_db::mojom::ObservationPtr observation); 86 ::indexed_db::mojom::ObservationPtr observation);
82 // Adds the last observation index to observer_id's list of recorded 87
83 // observation indices. 88 ::indexed_db::mojom::ObserverChangesPtr* GetPendingChangesForConnection(
84 void RecordObserverForLastObservation(int32_t connection_id, 89 int32_t connection_id);
85 int32_t observer_id);
86 90
87 IndexedDBBackingStore::Transaction* BackingStoreTransaction() { 91 IndexedDBBackingStore::Transaction* BackingStoreTransaction() {
88 return transaction_.get(); 92 return transaction_.get();
89 } 93 }
90 int64_t id() const { return id_; } 94 int64_t id() const { return id_; }
91 95
92 IndexedDBDatabase* database() const { return database_.get(); } 96 IndexedDBDatabase* database() const { return database_.get(); }
93 IndexedDBDatabaseCallbacks* callbacks() const { return callbacks_.get(); } 97 IndexedDBDatabaseCallbacks* callbacks() const { return callbacks_.get(); }
94 IndexedDBConnection* connection() const { return connection_; } 98 IndexedDBConnection* connection() const { return connection_; }
95 99
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 base::OneShotTimer timeout_timer_; 223 base::OneShotTimer timeout_timer_;
220 224
221 Diagnostics diagnostics_; 225 Diagnostics diagnostics_;
222 226
223 base::WeakPtrFactory<IndexedDBTransaction> ptr_factory_; 227 base::WeakPtrFactory<IndexedDBTransaction> ptr_factory_;
224 }; 228 };
225 229
226 } // namespace content 230 } // namespace content
227 231
228 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_TRANSACTION_H_ 232 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_TRANSACTION_H_
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_observer.h ('k') | content/browser/indexed_db/indexed_db_transaction.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698