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, and the |
| 88 // browser-created transactions are in the left 32 bits. |
| 89 int64_t next_observer_transaction_id_ = 1ll << 32; |
| 90 |
83 // The process id of the child process this connection is associated with. | 91 // The process id of the child process this connection is associated with. |
84 // Tracked for IndexedDBContextImpl::GetAllOriginsDetails and debugging. | 92 // Tracked for IndexedDBContextImpl::GetAllOriginsDetails and debugging. |
85 const int child_process_id_; | 93 const int child_process_id_; |
86 | 94 |
87 // NULL in some unit tests, and after the connection is closed. | 95 // NULL in some unit tests, and after the connection is closed. |
88 scoped_refptr<IndexedDBDatabase> database_; | 96 scoped_refptr<IndexedDBDatabase> database_; |
89 | 97 |
90 // The connection owns transactions created on this connection. | 98 // The connection owns transactions created on this connection. |
91 std::unordered_map<int64_t, std::unique_ptr<IndexedDBTransaction>> | 99 std::unordered_map<int64_t, std::unique_ptr<IndexedDBTransaction>> |
92 transactions_; | 100 transactions_; |
93 | 101 |
94 // The callbacks_ member is cleared when the connection is closed. | 102 // The callbacks_ member is cleared when the connection is closed. |
95 // May be NULL in unit tests. | 103 // May be NULL in unit tests. |
96 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks_; | 104 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks_; |
97 std::vector<std::unique_ptr<IndexedDBObserver>> active_observers_; | 105 std::vector<std::unique_ptr<IndexedDBObserver>> active_observers_; |
98 base::WeakPtrFactory<IndexedDBConnection> weak_factory_; | 106 base::WeakPtrFactory<IndexedDBConnection> weak_factory_; |
99 | 107 |
100 DISALLOW_COPY_AND_ASSIGN(IndexedDBConnection); | 108 DISALLOW_COPY_AND_ASSIGN(IndexedDBConnection); |
101 }; | 109 }; |
102 | 110 |
103 } // namespace content | 111 } // namespace content |
104 | 112 |
105 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONNECTION_H_ | 113 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONNECTION_H_ |
OLD | NEW |