| 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 <list> | 8 #include <list> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "content/browser/indexed_db/indexed_db.h" | 15 #include "content/browser/indexed_db/indexed_db.h" |
| 16 #include "content/browser/indexed_db/indexed_db_backing_store.h" | 16 #include "content/browser/indexed_db/indexed_db_backing_store.h" |
| 17 #include "content/browser/indexed_db/indexed_db_callbacks.h" | 17 #include "content/browser/indexed_db/indexed_db_callbacks.h" |
| 18 #include "content/browser/indexed_db/indexed_db_metadata.h" | 18 #include "content/browser/indexed_db/indexed_db_metadata.h" |
| 19 #include "content/browser/indexed_db/indexed_db_transaction_coordinator.h" | 19 #include "content/browser/indexed_db/indexed_db_transaction_coordinator.h" |
| 20 #include "content/browser/indexed_db/list_set.h" | 20 #include "content/browser/indexed_db/list_set.h" |
| 21 #include "url/gurl.h" | 21 #include "url/gurl.h" |
| 22 | 22 |
| 23 namespace content { | 23 namespace content { |
| 24 | 24 |
| 25 class IndexedDBBlobInfo; |
| 25 class IndexedDBConnection; | 26 class IndexedDBConnection; |
| 26 class IndexedDBDatabaseCallbacks; | 27 class IndexedDBDatabaseCallbacks; |
| 27 class IndexedDBFactory; | 28 class IndexedDBFactory; |
| 28 class IndexedDBKey; | 29 class IndexedDBKey; |
| 29 class IndexedDBKeyPath; | 30 class IndexedDBKeyPath; |
| 30 class IndexedDBKeyRange; | 31 class IndexedDBKeyRange; |
| 31 class IndexedDBTransaction; | 32 class IndexedDBTransaction; |
| 33 struct IndexedDBValue; |
| 32 | 34 |
| 33 class CONTENT_EXPORT IndexedDBDatabase | 35 class CONTENT_EXPORT IndexedDBDatabase |
| 34 : NON_EXPORTED_BASE(public base::RefCounted<IndexedDBDatabase>) { | 36 : NON_EXPORTED_BASE(public base::RefCounted<IndexedDBDatabase>) { |
| 35 public: | 37 public: |
| 36 enum TaskType { | 38 enum TaskType { |
| 37 NORMAL_TASK = 0, | 39 NORMAL_TASK = 0, |
| 38 PREEMPTIVE_TASK | 40 PREEMPTIVE_TASK |
| 39 }; | 41 }; |
| 40 | 42 |
| 41 enum PutMode { | 43 enum PutMode { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 67 int64 new_max_object_store_id); | 69 int64 new_max_object_store_id); |
| 68 void RemoveObjectStore(int64 object_store_id); | 70 void RemoveObjectStore(int64 object_store_id); |
| 69 void AddIndex(int64 object_store_id, | 71 void AddIndex(int64 object_store_id, |
| 70 const IndexedDBIndexMetadata& metadata, | 72 const IndexedDBIndexMetadata& metadata, |
| 71 int64 new_max_index_id); | 73 int64 new_max_index_id); |
| 72 void RemoveIndex(int64 object_store_id, int64 index_id); | 74 void RemoveIndex(int64 object_store_id, int64 index_id); |
| 73 | 75 |
| 74 void OpenConnection( | 76 void OpenConnection( |
| 75 scoped_refptr<IndexedDBCallbacks> callbacks, | 77 scoped_refptr<IndexedDBCallbacks> callbacks, |
| 76 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, | 78 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, |
| 79 int child_process_id, |
| 77 int64 transaction_id, | 80 int64 transaction_id, |
| 78 int64 version); | 81 int64 version); |
| 79 void OpenConnection( | 82 void OpenConnection( |
| 80 scoped_refptr<IndexedDBCallbacks> callbacks, | 83 scoped_refptr<IndexedDBCallbacks> callbacks, |
| 81 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, | 84 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, |
| 85 int child_process_id, |
| 82 int64 transaction_id, | 86 int64 transaction_id, |
| 83 int64 version, | 87 int64 version, |
| 84 blink::WebIDBDataLoss data_loss, | 88 blink::WebIDBDataLoss data_loss, |
| 85 std::string data_loss_message); | 89 std::string data_loss_message); |
| 86 void DeleteDatabase(scoped_refptr<IndexedDBCallbacks> callbacks); | 90 void DeleteDatabase(scoped_refptr<IndexedDBCallbacks> callbacks); |
| 87 const IndexedDBDatabaseMetadata& metadata() const { return metadata_; } | 91 const IndexedDBDatabaseMetadata& metadata() const { return metadata_; } |
| 88 | 92 |
| 89 void CreateObjectStore(int64 transaction_id, | 93 void CreateObjectStore(int64 transaction_id, |
| 90 int64 object_store_id, | 94 int64 object_store_id, |
| 91 const string16& name, | 95 const string16& name, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 void TransactionCommitFailed(); | 131 void TransactionCommitFailed(); |
| 128 | 132 |
| 129 void Get(int64 transaction_id, | 133 void Get(int64 transaction_id, |
| 130 int64 object_store_id, | 134 int64 object_store_id, |
| 131 int64 index_id, | 135 int64 index_id, |
| 132 scoped_ptr<IndexedDBKeyRange> key_range, | 136 scoped_ptr<IndexedDBKeyRange> key_range, |
| 133 bool key_only, | 137 bool key_only, |
| 134 scoped_refptr<IndexedDBCallbacks> callbacks); | 138 scoped_refptr<IndexedDBCallbacks> callbacks); |
| 135 void Put(int64 transaction_id, | 139 void Put(int64 transaction_id, |
| 136 int64 object_store_id, | 140 int64 object_store_id, |
| 137 std::string* value, | 141 IndexedDBValue* value, |
| 142 ScopedVector<webkit_blob::BlobDataHandle>* handles, |
| 138 scoped_ptr<IndexedDBKey> key, | 143 scoped_ptr<IndexedDBKey> key, |
| 139 PutMode mode, | 144 PutMode mode, |
| 140 scoped_refptr<IndexedDBCallbacks> callbacks, | 145 scoped_refptr<IndexedDBCallbacks> callbacks, |
| 141 const std::vector<int64>& index_ids, | 146 const std::vector<int64>& index_ids, |
| 142 const std::vector<IndexKeys>& index_keys); | 147 const std::vector<IndexKeys>& index_keys); |
| 143 void SetIndexKeys(int64 transaction_id, | 148 void SetIndexKeys(int64 transaction_id, |
| 144 int64 object_store_id, | 149 int64 object_store_id, |
| 145 scoped_ptr<IndexedDBKey> primary_key, | 150 scoped_ptr<IndexedDBKey> primary_key, |
| 146 const std::vector<int64>& index_ids, | 151 const std::vector<int64>& index_ids, |
| 147 const std::vector<IndexKeys>& index_keys); | 152 const std::vector<IndexKeys>& index_keys); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 scoped_ptr<IndexedDBConnection> connection, | 272 scoped_ptr<IndexedDBConnection> connection, |
| 268 int64 transaction_id, | 273 int64 transaction_id, |
| 269 int64 requested_version, | 274 int64 requested_version, |
| 270 blink::WebIDBDataLoss data_loss, | 275 blink::WebIDBDataLoss data_loss, |
| 271 std::string data_loss_message); | 276 std::string data_loss_message); |
| 272 void ProcessPendingCalls(); | 277 void ProcessPendingCalls(); |
| 273 | 278 |
| 274 bool IsDeleteDatabaseBlocked() const; | 279 bool IsDeleteDatabaseBlocked() const; |
| 275 void DeleteDatabaseFinal(scoped_refptr<IndexedDBCallbacks> callbacks); | 280 void DeleteDatabaseFinal(scoped_refptr<IndexedDBCallbacks> callbacks); |
| 276 | 281 |
| 282 scoped_ptr<IndexedDBConnection> CreateConnection( |
| 283 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, |
| 284 int child_process_id); |
| 277 IndexedDBTransaction* GetTransaction(int64 transaction_id) const; | 285 IndexedDBTransaction* GetTransaction(int64 transaction_id) const; |
| 278 | 286 |
| 279 bool ValidateObjectStoreId(int64 object_store_id) const; | 287 bool ValidateObjectStoreId(int64 object_store_id) const; |
| 280 bool ValidateObjectStoreIdAndIndexId(int64 object_store_id, | 288 bool ValidateObjectStoreIdAndIndexId(int64 object_store_id, |
| 281 int64 index_id) const; | 289 int64 index_id) const; |
| 282 bool ValidateObjectStoreIdAndOptionalIndexId(int64 object_store_id, | 290 bool ValidateObjectStoreIdAndOptionalIndexId(int64 object_store_id, |
| 283 int64 index_id) const; | 291 int64 index_id) const; |
| 284 bool ValidateObjectStoreIdAndNewIndexId(int64 object_store_id, | 292 bool ValidateObjectStoreIdAndNewIndexId(int64 object_store_id, |
| 285 int64 index_id) const; | 293 int64 index_id) const; |
| 286 | 294 |
| 287 scoped_refptr<IndexedDBBackingStore> backing_store_; | 295 scoped_refptr<IndexedDBBackingStore> backing_store_; |
| 288 IndexedDBDatabaseMetadata metadata_; | 296 IndexedDBDatabaseMetadata metadata_; |
| 289 | 297 |
| 290 const Identifier identifier_; | 298 const Identifier identifier_; |
| 291 // This might not need to be a scoped_refptr since the factory's lifetime is | 299 // This might not need to be a scoped_refptr since the factory's lifetime is |
| 292 // that of the page group, but it's better to be conservitive than sorry. | 300 // that of the page group, but it's better to be conservative than sorry. |
| 293 scoped_refptr<IndexedDBFactory> factory_; | 301 scoped_refptr<IndexedDBFactory> factory_; |
| 294 | 302 |
| 295 IndexedDBTransactionCoordinator transaction_coordinator_; | 303 IndexedDBTransactionCoordinator transaction_coordinator_; |
| 296 IndexedDBTransaction* running_version_change_transaction_; | 304 IndexedDBTransaction* running_version_change_transaction_; |
| 297 | 305 |
| 298 typedef std::map<int64, IndexedDBTransaction*> TransactionMap; | 306 typedef std::map<int64, IndexedDBTransaction*> TransactionMap; |
| 299 TransactionMap transactions_; | 307 TransactionMap transactions_; |
| 300 | 308 |
| 301 class PendingOpenCall; | 309 class PendingOpenCall; |
| 302 typedef std::list<PendingOpenCall*> PendingOpenCallList; | 310 typedef std::list<PendingOpenCall*> PendingOpenCallList; |
| 303 PendingOpenCallList pending_open_calls_; | 311 PendingOpenCallList pending_open_calls_; |
| 304 | 312 |
| 305 class PendingUpgradeCall; | 313 class PendingUpgradeCall; |
| 306 scoped_ptr<PendingUpgradeCall> pending_run_version_change_transaction_call_; | 314 scoped_ptr<PendingUpgradeCall> pending_run_version_change_transaction_call_; |
| 307 class PendingSuccessCall; | 315 class PendingSuccessCall; |
| 308 scoped_ptr<PendingSuccessCall> pending_second_half_open_; | 316 scoped_ptr<PendingSuccessCall> pending_second_half_open_; |
| 309 | 317 |
| 310 class PendingDeleteCall; | 318 class PendingDeleteCall; |
| 311 typedef std::list<PendingDeleteCall*> PendingDeleteCallList; | 319 typedef std::list<PendingDeleteCall*> PendingDeleteCallList; |
| 312 PendingDeleteCallList pending_delete_calls_; | 320 PendingDeleteCallList pending_delete_calls_; |
| 313 | 321 |
| 314 typedef list_set<IndexedDBConnection*> ConnectionSet; | 322 typedef list_set<IndexedDBConnection*> ConnectionSet; |
| 315 ConnectionSet connections_; | 323 ConnectionSet connections_; |
| 316 }; | 324 }; |
| 317 | 325 |
| 318 } // namespace content | 326 } // namespace content |
| 319 | 327 |
| 320 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DATABASE_H_ | 328 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DATABASE_H_ |
| OLD | NEW |