Chromium Code Reviews| 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_FACTORY_H_ | 5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FACTORY_H_ |
| 6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FACTORY_H_ | 6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FACTORY_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 43 const GURL& origin_url, | 43 const GURL& origin_url, |
| 44 const base::FilePath& data_directory); | 44 const base::FilePath& data_directory); |
| 45 | 45 |
| 46 void DeleteDatabase(const base::string16& name, | 46 void DeleteDatabase(const base::string16& name, |
| 47 scoped_refptr<IndexedDBCallbacks> callbacks, | 47 scoped_refptr<IndexedDBCallbacks> callbacks, |
| 48 const GURL& origin_url, | 48 const GURL& origin_url, |
| 49 const base::FilePath& data_directory); | 49 const base::FilePath& data_directory); |
| 50 | 50 |
| 51 void HandleBackingStoreFailure(const GURL& origin_url); | 51 void HandleBackingStoreFailure(const GURL& origin_url); |
| 52 | 52 |
| 53 // Iterates over all databases; for diagnostics only. | 53 typedef std::multimap<GURL, IndexedDBDatabase*> OriginDbMap; |
|
jsbell
2014/01/03 00:34:25
Nit: capitalize 'DB' or spell it out (i.e. 'Databa
cmumford
2014/01/03 21:34:01
Done.
| |
| 54 std::vector<IndexedDBDatabase*> GetOpenDatabasesForOrigin( | 54 typedef OriginDbMap::const_iterator OriginDbMapIterator; |
| 55 const GURL& origin_url) const; | 55 std::pair<OriginDbMapIterator, OriginDbMapIterator> |
| 56 GetOpenDatabasesForOrigin(const GURL& origin_url) const; | |
| 56 | 57 |
| 57 // Called by IndexedDBContext after all connections are closed, to | 58 // Called by IndexedDBContext after all connections are closed, to |
| 58 // ensure the backing store closed immediately. | 59 // ensure the backing store closed immediately. |
| 59 void ForceClose(const GURL& origin_url); | 60 void ForceClose(const GURL& origin_url); |
| 60 | 61 |
| 61 // Called by the IndexedDBContext destructor so the factory can do cleanup. | 62 // Called by the IndexedDBContext destructor so the factory can do cleanup. |
| 62 void ContextDestroyed(); | 63 void ContextDestroyed(); |
| 63 | 64 |
| 64 // Called by an IndexedDBDatabase when it is actually deleted. | 65 // Called by an IndexedDBDatabase when it is actually deleted. |
| 65 void DatabaseDeleted(const IndexedDBDatabase::Identifier& identifier); | 66 void DatabaseDeleted(const IndexedDBDatabase::Identifier& identifier); |
| 66 | 67 |
| 68 size_t GetConnectionCount(const GURL& origin_url) const; | |
| 69 | |
| 67 protected: | 70 protected: |
| 68 friend class base::RefCountedThreadSafe<IndexedDBFactory>; | 71 friend class base::RefCountedThreadSafe<IndexedDBFactory>; |
| 69 | 72 |
| 70 virtual ~IndexedDBFactory(); | 73 virtual ~IndexedDBFactory(); |
| 71 | 74 |
| 72 virtual scoped_refptr<IndexedDBBackingStore> OpenBackingStore( | 75 virtual scoped_refptr<IndexedDBBackingStore> OpenBackingStore( |
| 73 const GURL& origin_url, | 76 const GURL& origin_url, |
| 74 const base::FilePath& data_directory, | 77 const base::FilePath& data_directory, |
| 75 blink::WebIDBDataLoss* data_loss, | 78 blink::WebIDBDataLoss* data_loss, |
| 76 std::string* data_loss_reason, | 79 std::string* data_loss_reason, |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 97 // Called internally after a database is closed, with some delay. If this | 100 // Called internally after a database is closed, with some delay. If this |
| 98 // factory has the last reference, it will be released. | 101 // factory has the last reference, it will be released. |
| 99 void MaybeCloseBackingStore(const GURL& origin_url); | 102 void MaybeCloseBackingStore(const GURL& origin_url); |
| 100 bool HasLastBackingStoreReference(const GURL& origin_url) const; | 103 bool HasLastBackingStoreReference(const GURL& origin_url) const; |
| 101 | 104 |
| 102 // Testing helpers, so unit tests don't need to grovel through internal state. | 105 // Testing helpers, so unit tests don't need to grovel through internal state. |
| 103 bool IsDatabaseOpen(const GURL& origin_url, | 106 bool IsDatabaseOpen(const GURL& origin_url, |
| 104 const base::string16& name) const; | 107 const base::string16& name) const; |
| 105 bool IsBackingStoreOpen(const GURL& origin_url) const; | 108 bool IsBackingStoreOpen(const GURL& origin_url) const; |
| 106 bool IsBackingStorePendingClose(const GURL& origin_url) const; | 109 bool IsBackingStorePendingClose(const GURL& origin_url) const; |
| 110 void RemoveDatabaseFromMaps(const IndexedDBDatabase::Identifier& identifier); | |
| 107 | 111 |
| 108 IndexedDBContextImpl* context_; | 112 IndexedDBContextImpl* context_; |
| 109 | 113 |
| 110 typedef std::map<IndexedDBDatabase::Identifier, | 114 typedef std::map<IndexedDBDatabase::Identifier, |
| 111 IndexedDBDatabase*> IndexedDBDatabaseMap; | 115 IndexedDBDatabase*> IndexedDBDatabaseMap; |
| 112 IndexedDBDatabaseMap database_map_; | 116 IndexedDBDatabaseMap database_map_; |
| 117 OriginDbMap origin_dbs_; | |
| 113 | 118 |
| 114 typedef std::map<GURL, scoped_refptr<IndexedDBBackingStore> > | 119 typedef std::map<GURL, scoped_refptr<IndexedDBBackingStore> > |
| 115 IndexedDBBackingStoreMap; | 120 IndexedDBBackingStoreMap; |
| 116 IndexedDBBackingStoreMap backing_store_map_; | 121 IndexedDBBackingStoreMap backing_store_map_; |
| 117 | 122 |
| 118 std::set<scoped_refptr<IndexedDBBackingStore> > session_only_backing_stores_; | 123 std::set<scoped_refptr<IndexedDBBackingStore> > session_only_backing_stores_; |
| 119 }; | 124 }; |
| 120 | 125 |
| 121 } // namespace content | 126 } // namespace content |
| 122 | 127 |
| 123 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FACTORY_H_ | 128 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FACTORY_H_ |
| OLD | NEW |