OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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_CONNECTION_H_ | 5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONNECTION_H_ |
6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONNECTION_H_ | 6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONNECTION_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <set> | 9 #include <set> |
10 #include <unordered_map> | 10 #include <unordered_map> |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 | 70 |
71 IndexedDBTransaction* GetTransaction(int64_t id) const; | 71 IndexedDBTransaction* GetTransaction(int64_t id) const; |
72 | 72 |
73 base::WeakPtr<IndexedDBTransaction> AddTransactionForTesting( | 73 base::WeakPtr<IndexedDBTransaction> AddTransactionForTesting( |
74 std::unique_ptr<IndexedDBTransaction> transaction); | 74 std::unique_ptr<IndexedDBTransaction> transaction); |
75 | 75 |
76 // We ignore calls where the id doesn't exist to facilitate the AbortAll call. | 76 // We ignore calls where the id doesn't exist to facilitate the AbortAll call. |
77 // TODO(dmurph): Change that so this doesn't need to ignore unknown ids. | 77 // TODO(dmurph): Change that so this doesn't need to ignore unknown ids. |
78 void RemoveTransaction(int64_t id); | 78 void RemoveTransaction(int64_t id); |
79 | 79 |
| 80 // Returns a new transaction id for an observer transaction. |
| 81 // Unique per connection. |
| 82 int64_t NewObserverTransactionId(); |
| 83 |
80 private: | 84 private: |
81 const int32_t id_; | 85 const int32_t id_; |
82 | 86 |
| 87 // The renderer-created transactions are in the right 32 bits of the |
| 88 // transaction id, and the observer (browser-created) transactions are in the |
| 89 // left 32 bits. |
| 90 // This keeps track of the left 32 bits. Unsigned for defined overflow. |
| 91 uint32_t next_observer_transaction_id_ = 1; |
| 92 |
83 // The process id of the child process this connection is associated with. | 93 // The process id of the child process this connection is associated with. |
84 // Tracked for IndexedDBContextImpl::GetAllOriginsDetails and debugging. | 94 // Tracked for IndexedDBContextImpl::GetAllOriginsDetails and debugging. |
85 const int child_process_id_; | 95 const int child_process_id_; |
86 | 96 |
87 // NULL in some unit tests, and after the connection is closed. | 97 // NULL in some unit tests, and after the connection is closed. |
88 scoped_refptr<IndexedDBDatabase> database_; | 98 scoped_refptr<IndexedDBDatabase> database_; |
89 | 99 |
90 // The connection owns transactions created on this connection. | 100 // The connection owns transactions created on this connection. |
91 std::unordered_map<int64_t, std::unique_ptr<IndexedDBTransaction>> | 101 std::unordered_map<int64_t, std::unique_ptr<IndexedDBTransaction>> |
92 transactions_; | 102 transactions_; |
93 | 103 |
94 // The callbacks_ member is cleared when the connection is closed. | 104 // The callbacks_ member is cleared when the connection is closed. |
95 // May be NULL in unit tests. | 105 // May be NULL in unit tests. |
96 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks_; | 106 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks_; |
97 std::vector<std::unique_ptr<IndexedDBObserver>> active_observers_; | 107 std::vector<std::unique_ptr<IndexedDBObserver>> active_observers_; |
98 base::WeakPtrFactory<IndexedDBConnection> weak_factory_; | 108 base::WeakPtrFactory<IndexedDBConnection> weak_factory_; |
99 | 109 |
100 DISALLOW_COPY_AND_ASSIGN(IndexedDBConnection); | 110 DISALLOW_COPY_AND_ASSIGN(IndexedDBConnection); |
101 }; | 111 }; |
102 | 112 |
103 } // namespace content | 113 } // namespace content |
104 | 114 |
105 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONNECTION_H_ | 115 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONNECTION_H_ |
OLD | NEW |