| 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_DATABASE_H_ | 5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DATABASE_H_ |
| 6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DATABASE_H_ | 6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DATABASE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 const base::string16& name, | 57 const base::string16& name, |
| 58 scoped_refptr<IndexedDBBackingStore> backing_store, | 58 scoped_refptr<IndexedDBBackingStore> backing_store, |
| 59 scoped_refptr<IndexedDBFactory> factory, | 59 scoped_refptr<IndexedDBFactory> factory, |
| 60 const Identifier& unique_identifier); | 60 const Identifier& unique_identifier); |
| 61 | 61 |
| 62 const Identifier& identifier() const { return identifier_; } | 62 const Identifier& identifier() const { return identifier_; } |
| 63 IndexedDBBackingStore* backing_store() { return backing_store_.get(); } | 63 IndexedDBBackingStore* backing_store() { return backing_store_.get(); } |
| 64 | 64 |
| 65 int64_t id() const { return metadata_.id; } | 65 int64_t id() const { return metadata_.id; } |
| 66 const base::string16& name() const { return metadata_.name; } | 66 const base::string16& name() const { return metadata_.name; } |
| 67 const url::Origin& origin() const { return identifier_.first; } |
| 67 | 68 |
| 68 void AddObjectStore(const IndexedDBObjectStoreMetadata& metadata, | 69 void AddObjectStore(const IndexedDBObjectStoreMetadata& metadata, |
| 69 int64_t new_max_object_store_id); | 70 int64_t new_max_object_store_id); |
| 70 void RemoveObjectStore(int64_t object_store_id); | 71 void RemoveObjectStore(int64_t object_store_id); |
| 71 void SetObjectStoreName(int64_t object_store_id, const base::string16& name); | 72 void SetObjectStoreName(int64_t object_store_id, const base::string16& name); |
| 72 void AddIndex(int64_t object_store_id, | 73 void AddIndex(int64_t object_store_id, |
| 73 const IndexedDBIndexMetadata& metadata, | 74 const IndexedDBIndexMetadata& metadata, |
| 74 int64_t new_max_index_id); | 75 int64_t new_max_index_id); |
| 75 void RemoveIndex(int64_t object_store_id, int64_t index_id); | 76 void RemoveIndex(int64_t object_store_id, int64_t index_id); |
| 76 void SetIndexName(int64_t object_store_id, | 77 void SetIndexName(int64_t object_store_id, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 IndexedDBTransactionCoordinator& transaction_coordinator() { | 129 IndexedDBTransactionCoordinator& transaction_coordinator() { |
| 129 return transaction_coordinator_; | 130 return transaction_coordinator_; |
| 130 } | 131 } |
| 131 const IndexedDBTransactionCoordinator& transaction_coordinator() const { | 132 const IndexedDBTransactionCoordinator& transaction_coordinator() const { |
| 132 return transaction_coordinator_; | 133 return transaction_coordinator_; |
| 133 } | 134 } |
| 134 | 135 |
| 135 void TransactionCreated(IndexedDBTransaction* transaction); | 136 void TransactionCreated(IndexedDBTransaction* transaction); |
| 136 void TransactionFinished(IndexedDBTransaction* transaction, bool committed); | 137 void TransactionFinished(IndexedDBTransaction* transaction, bool committed); |
| 137 | 138 |
| 138 // Called by transactions to report failure committing to the backing store. | |
| 139 void TransactionCommitFailed(const leveldb::Status& status); | |
| 140 | |
| 141 void AddPendingObserver(int64_t transaction_id, | 139 void AddPendingObserver(int64_t transaction_id, |
| 142 int32_t observer_id, | 140 int32_t observer_id, |
| 143 const IndexedDBObserver::Options& options); | 141 const IndexedDBObserver::Options& options); |
| 144 void RemovePendingObservers(IndexedDBConnection* connection, | 142 void RemovePendingObservers(IndexedDBConnection* connection, |
| 145 const std::vector<int32_t>& pending_observer_ids); | 143 const std::vector<int32_t>& pending_observer_ids); |
| 146 | 144 |
| 147 void FilterObservation(IndexedDBTransaction*, | 145 void FilterObservation(IndexedDBTransaction*, |
| 148 int64_t object_store_id, | 146 int64_t object_store_id, |
| 149 blink::WebIDBOperationType type, | 147 blink::WebIDBOperationType type, |
| 150 const IndexedDBKeyRange& key_range); | 148 const IndexedDBKeyRange& key_range); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 size_t ConnectionCount() const { return connections_.size(); } | 202 size_t ConnectionCount() const { return connections_.size(); } |
| 205 | 203 |
| 206 // Number of active open/delete calls (running or blocked on other | 204 // Number of active open/delete calls (running or blocked on other |
| 207 // connections). | 205 // connections). |
| 208 size_t ActiveOpenDeleteCount() const { return active_request_ ? 1 : 0; } | 206 size_t ActiveOpenDeleteCount() const { return active_request_ ? 1 : 0; } |
| 209 | 207 |
| 210 // Number of open/delete calls that are waiting their turn. | 208 // Number of open/delete calls that are waiting their turn. |
| 211 size_t PendingOpenDeleteCount() const { return pending_requests_.size(); } | 209 size_t PendingOpenDeleteCount() const { return pending_requests_.size(); } |
| 212 | 210 |
| 213 // Asynchronous tasks scheduled within transactions: | 211 // Asynchronous tasks scheduled within transactions: |
| 214 void CreateObjectStoreAbortOperation(int64_t object_store_id, | 212 void CreateObjectStoreAbortOperation(int64_t object_store_id); |
| 213 leveldb::Status DeleteObjectStoreOperation(int64_t object_store_id, |
| 214 IndexedDBTransaction* transaction); |
| 215 void DeleteObjectStoreAbortOperation( |
| 216 const IndexedDBObjectStoreMetadata& object_store_metadata); |
| 217 void RenameObjectStoreAbortOperation(int64_t object_store_id, |
| 218 const base::string16& old_name); |
| 219 leveldb::Status VersionChangeOperation( |
| 220 int64_t version, |
| 221 scoped_refptr<IndexedDBCallbacks> callbacks, |
| 222 IndexedDBTransaction* transaction); |
| 223 void VersionChangeAbortOperation(int64_t previous_version); |
| 224 leveldb::Status DeleteIndexOperation(int64_t object_store_id, |
| 225 int64_t index_id, |
| 215 IndexedDBTransaction* transaction); | 226 IndexedDBTransaction* transaction); |
| 216 void DeleteObjectStoreOperation(int64_t object_store_id, | 227 void CreateIndexAbortOperation(int64_t object_store_id, int64_t index_id); |
| 217 IndexedDBTransaction* transaction); | |
| 218 void DeleteObjectStoreAbortOperation( | |
| 219 const IndexedDBObjectStoreMetadata& object_store_metadata, | |
| 220 IndexedDBTransaction* transaction); | |
| 221 void RenameObjectStoreAbortOperation(int64_t object_store_id, | |
| 222 const base::string16& old_name, | |
| 223 IndexedDBTransaction* transaction); | |
| 224 void VersionChangeOperation(int64_t version, | |
| 225 scoped_refptr<IndexedDBCallbacks> callbacks, | |
| 226 IndexedDBTransaction* transaction); | |
| 227 void VersionChangeAbortOperation(int64_t previous_version, | |
| 228 IndexedDBTransaction* transaction); | |
| 229 void DeleteIndexOperation(int64_t object_store_id, | |
| 230 int64_t index_id, | |
| 231 IndexedDBTransaction* transaction); | |
| 232 void CreateIndexAbortOperation(int64_t object_store_id, | |
| 233 int64_t index_id, | |
| 234 IndexedDBTransaction* transaction); | |
| 235 void DeleteIndexAbortOperation(int64_t object_store_id, | 228 void DeleteIndexAbortOperation(int64_t object_store_id, |
| 236 const IndexedDBIndexMetadata& index_metadata, | 229 const IndexedDBIndexMetadata& index_metadata); |
| 237 IndexedDBTransaction* transaction); | |
| 238 void RenameIndexAbortOperation(int64_t object_store_id, | 230 void RenameIndexAbortOperation(int64_t object_store_id, |
| 239 int64_t index_id, | 231 int64_t index_id, |
| 240 const base::string16& old_name, | 232 const base::string16& old_name); |
| 233 leveldb::Status GetOperation(int64_t object_store_id, |
| 234 int64_t index_id, |
| 235 std::unique_ptr<IndexedDBKeyRange> key_range, |
| 236 indexed_db::CursorType cursor_type, |
| 237 scoped_refptr<IndexedDBCallbacks> callbacks, |
| 238 IndexedDBTransaction* transaction); |
| 239 leveldb::Status GetAllOperation(int64_t object_store_id, |
| 240 int64_t index_id, |
| 241 std::unique_ptr<IndexedDBKeyRange> key_range, |
| 242 indexed_db::CursorType cursor_type, |
| 243 int64_t max_count, |
| 244 scoped_refptr<IndexedDBCallbacks> callbacks, |
| 245 IndexedDBTransaction* transaction); |
| 246 struct PutOperationParams; |
| 247 leveldb::Status PutOperation(std::unique_ptr<PutOperationParams> params, |
| 248 IndexedDBTransaction* transaction); |
| 249 leveldb::Status SetIndexesReadyOperation(size_t index_count, |
| 250 IndexedDBTransaction* transaction); |
| 251 struct OpenCursorOperationParams; |
| 252 leveldb::Status OpenCursorOperation( |
| 253 std::unique_ptr<OpenCursorOperationParams> params, |
| 254 IndexedDBTransaction* transaction); |
| 255 leveldb::Status CountOperation(int64_t object_store_id, |
| 256 int64_t index_id, |
| 257 std::unique_ptr<IndexedDBKeyRange> key_range, |
| 258 scoped_refptr<IndexedDBCallbacks> callbacks, |
| 241 IndexedDBTransaction* transaction); | 259 IndexedDBTransaction* transaction); |
| 242 void GetOperation(int64_t object_store_id, | 260 leveldb::Status DeleteRangeOperation( |
| 243 int64_t index_id, | 261 int64_t object_store_id, |
| 244 std::unique_ptr<IndexedDBKeyRange> key_range, | 262 std::unique_ptr<IndexedDBKeyRange> key_range, |
| 245 indexed_db::CursorType cursor_type, | 263 scoped_refptr<IndexedDBCallbacks> callbacks, |
| 246 scoped_refptr<IndexedDBCallbacks> callbacks, | 264 IndexedDBTransaction* transaction); |
| 247 IndexedDBTransaction* transaction); | 265 leveldb::Status ClearOperation(int64_t object_store_id, |
| 248 void GetAllOperation(int64_t object_store_id, | 266 scoped_refptr<IndexedDBCallbacks> callbacks, |
| 249 int64_t index_id, | 267 IndexedDBTransaction* transaction); |
| 250 std::unique_ptr<IndexedDBKeyRange> key_range, | |
| 251 indexed_db::CursorType cursor_type, | |
| 252 int64_t max_count, | |
| 253 scoped_refptr<IndexedDBCallbacks> callbacks, | |
| 254 IndexedDBTransaction* transaction); | |
| 255 struct PutOperationParams; | |
| 256 void PutOperation(std::unique_ptr<PutOperationParams> params, | |
| 257 IndexedDBTransaction* transaction); | |
| 258 void SetIndexesReadyOperation(size_t index_count, | |
| 259 IndexedDBTransaction* transaction); | |
| 260 struct OpenCursorOperationParams; | |
| 261 void OpenCursorOperation(std::unique_ptr<OpenCursorOperationParams> params, | |
| 262 IndexedDBTransaction* transaction); | |
| 263 void CountOperation(int64_t object_store_id, | |
| 264 int64_t index_id, | |
| 265 std::unique_ptr<IndexedDBKeyRange> key_range, | |
| 266 scoped_refptr<IndexedDBCallbacks> callbacks, | |
| 267 IndexedDBTransaction* transaction); | |
| 268 void DeleteRangeOperation(int64_t object_store_id, | |
| 269 std::unique_ptr<IndexedDBKeyRange> key_range, | |
| 270 scoped_refptr<IndexedDBCallbacks> callbacks, | |
| 271 IndexedDBTransaction* transaction); | |
| 272 void ClearOperation(int64_t object_store_id, | |
| 273 scoped_refptr<IndexedDBCallbacks> callbacks, | |
| 274 IndexedDBTransaction* transaction); | |
| 275 | 268 |
| 276 protected: | 269 protected: |
| 270 friend class IndexedDBTransaction; |
| 271 |
| 277 IndexedDBDatabase(const base::string16& name, | 272 IndexedDBDatabase(const base::string16& name, |
| 278 scoped_refptr<IndexedDBBackingStore> backing_store, | 273 scoped_refptr<IndexedDBBackingStore> backing_store, |
| 279 scoped_refptr<IndexedDBFactory> factory, | 274 scoped_refptr<IndexedDBFactory> factory, |
| 280 const Identifier& unique_identifier); | 275 const Identifier& unique_identifier); |
| 281 virtual ~IndexedDBDatabase(); | 276 virtual ~IndexedDBDatabase(); |
| 282 | 277 |
| 283 // May be overridden in tests. | 278 // May be overridden in tests. |
| 284 virtual size_t GetMaxMessageSizeInBytes() const; | 279 virtual size_t GetMaxMessageSizeInBytes() const; |
| 285 | 280 |
| 281 IndexedDBFactory* factory() const { return factory_.get(); } |
| 282 |
| 286 private: | 283 private: |
| 287 friend class base::RefCounted<IndexedDBDatabase>; | 284 friend class base::RefCounted<IndexedDBDatabase>; |
| 288 friend class IndexedDBClassFactory; | 285 friend class IndexedDBClassFactory; |
| 289 | 286 |
| 290 class ConnectionRequest; | 287 class ConnectionRequest; |
| 291 class OpenRequest; | 288 class OpenRequest; |
| 292 class DeleteRequest; | 289 class DeleteRequest; |
| 293 | 290 |
| 294 leveldb::Status OpenInternal(); | 291 leveldb::Status OpenInternal(); |
| 295 | 292 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 // is executing. It prevents rentrant calls if the active request completes | 342 // is executing. It prevents rentrant calls if the active request completes |
| 346 // synchronously. | 343 // synchronously. |
| 347 bool processing_pending_requests_ = false; | 344 bool processing_pending_requests_ = false; |
| 348 | 345 |
| 349 DISALLOW_COPY_AND_ASSIGN(IndexedDBDatabase); | 346 DISALLOW_COPY_AND_ASSIGN(IndexedDBDatabase); |
| 350 }; | 347 }; |
| 351 | 348 |
| 352 } // namespace content | 349 } // namespace content |
| 353 | 350 |
| 354 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DATABASE_H_ | 351 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DATABASE_H_ |
| OLD | NEW |