Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FACTORY_IMPL_H_ | |
| 6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FACTORY_IMPL_H_ | |
| 7 | |
| 8 #include "content/browser/indexed_db/indexed_db_factory.h" | |
| 9 | |
| 10 namespace content { | |
| 11 | |
| 12 class IndexedDBContextImpl; | |
| 13 | |
| 14 class CONTENT_EXPORT IndexedDBFactoryImpl : public IndexedDBFactory { | |
| 15 public: | |
| 16 explicit IndexedDBFactoryImpl(IndexedDBContextImpl* context); | |
| 17 | |
| 18 virtual void ReleaseDatabase(const IndexedDBDatabase::Identifier& identifier, | |
|
jochen (gone - plz use gerrit)
2014/07/15 11:44:46
can you add an comment a la // IndexedDBFactory ov
cmumford
2014/07/15 16:11:47
Done.
| |
| 19 bool forcedClose) OVERRIDE; | |
| 20 | |
| 21 virtual void GetDatabaseNames( | |
| 22 scoped_refptr<IndexedDBCallbacks> callbacks, | |
| 23 const GURL& origin_url, | |
| 24 const base::FilePath& data_directory, | |
| 25 net::URLRequestContext* request_context) OVERRIDE; | |
| 26 virtual void Open(const base::string16& name, | |
| 27 const IndexedDBPendingConnection& connection, | |
| 28 net::URLRequestContext* request_context, | |
| 29 const GURL& origin_url, | |
| 30 const base::FilePath& data_directory) OVERRIDE; | |
| 31 | |
| 32 virtual void DeleteDatabase(const base::string16& name, | |
| 33 net::URLRequestContext* request_context, | |
| 34 scoped_refptr<IndexedDBCallbacks> callbacks, | |
| 35 const GURL& origin_url, | |
| 36 const base::FilePath& data_directory) OVERRIDE; | |
| 37 | |
| 38 virtual void HandleBackingStoreFailure(const GURL& origin_url) OVERRIDE; | |
| 39 virtual void HandleBackingStoreCorruption( | |
| 40 const GURL& origin_url, | |
| 41 const IndexedDBDatabaseError& error) OVERRIDE; | |
| 42 | |
| 43 virtual std::pair<OriginDBMapIterator, OriginDBMapIterator> | |
| 44 GetOpenDatabasesForOrigin(const GURL& origin_url) const OVERRIDE; | |
| 45 | |
| 46 virtual void ForceClose(const GURL& origin_url) OVERRIDE; | |
| 47 | |
| 48 // Called by the IndexedDBContext destructor so the factory can do cleanup. | |
| 49 virtual void ContextDestroyed() OVERRIDE; | |
| 50 | |
| 51 // Called by the IndexedDBActiveBlobRegistry. | |
| 52 virtual void ReportOutstandingBlobs(const GURL& origin_url, | |
| 53 bool blobs_outstanding) OVERRIDE; | |
| 54 | |
| 55 // Called by an IndexedDBDatabase when it is actually deleted. | |
| 56 virtual void DatabaseDeleted( | |
| 57 const IndexedDBDatabase::Identifier& identifier) OVERRIDE; | |
| 58 | |
| 59 virtual size_t GetConnectionCount(const GURL& origin_url) const OVERRIDE; | |
| 60 | |
| 61 protected: | |
| 62 virtual ~IndexedDBFactoryImpl(); | |
| 63 | |
| 64 virtual scoped_refptr<IndexedDBBackingStore> OpenBackingStore( | |
| 65 const GURL& origin_url, | |
| 66 const base::FilePath& data_directory, | |
| 67 net::URLRequestContext* request_context, | |
| 68 blink::WebIDBDataLoss* data_loss, | |
| 69 std::string* data_loss_reason, | |
| 70 bool* disk_full) OVERRIDE; | |
| 71 | |
| 72 virtual scoped_refptr<IndexedDBBackingStore> OpenBackingStoreHelper( | |
| 73 const GURL& origin_url, | |
| 74 const base::FilePath& data_directory, | |
| 75 net::URLRequestContext* request_context, | |
| 76 blink::WebIDBDataLoss* data_loss, | |
| 77 std::string* data_loss_message, | |
| 78 bool* disk_full, | |
| 79 bool first_time) OVERRIDE; | |
| 80 | |
| 81 void ReleaseBackingStore(const GURL& origin_url, bool immediate); | |
| 82 void CloseBackingStore(const GURL& origin_url); | |
| 83 IndexedDBContextImpl* context() const { return context_; } | |
| 84 | |
| 85 private: | |
| 86 FRIEND_TEST_ALL_PREFIXES(IndexedDBFactoryTest, | |
| 87 BackingStoreReleasedOnForcedClose); | |
| 88 FRIEND_TEST_ALL_PREFIXES(IndexedDBFactoryTest, | |
| 89 BackingStoreReleaseDelayedOnClose); | |
| 90 FRIEND_TEST_ALL_PREFIXES(IndexedDBFactoryTest, DatabaseFailedOpen); | |
| 91 FRIEND_TEST_ALL_PREFIXES(IndexedDBFactoryTest, | |
| 92 DeleteDatabaseClosesBackingStore); | |
| 93 FRIEND_TEST_ALL_PREFIXES(IndexedDBFactoryTest, | |
| 94 ForceCloseReleasesBackingStore); | |
| 95 FRIEND_TEST_ALL_PREFIXES(IndexedDBFactoryTest, | |
| 96 GetDatabaseNamesClosesBackingStore); | |
| 97 | |
| 98 // Called internally after a database is closed, with some delay. If this | |
| 99 // factory has the last reference, it will be released. | |
| 100 void MaybeCloseBackingStore(const GURL& origin_url); | |
| 101 bool HasLastBackingStoreReference(const GURL& origin_url) const; | |
| 102 | |
| 103 // Testing helpers, so unit tests don't need to grovel through internal state. | |
| 104 bool IsDatabaseOpen(const GURL& origin_url, const base::string16& name) const; | |
| 105 virtual bool IsBackingStoreOpen(const GURL& origin_url) const OVERRIDE; | |
| 106 bool IsBackingStorePendingClose(const GURL& origin_url) const; | |
| 107 void RemoveDatabaseFromMaps(const IndexedDBDatabase::Identifier& identifier); | |
| 108 | |
| 109 DISALLOW_COPY_AND_ASSIGN(IndexedDBFactoryImpl); | |
|
jochen (gone - plz use gerrit)
2014/07/15 11:44:46
should go at the very end
cmumford
2014/07/15 16:11:47
Done.
| |
| 110 | |
| 111 IndexedDBContextImpl* context_; | |
| 112 | |
| 113 typedef std::map<IndexedDBDatabase::Identifier, IndexedDBDatabase*> | |
| 114 IndexedDBDatabaseMap; | |
| 115 IndexedDBDatabaseMap database_map_; | |
| 116 OriginDBMap origin_dbs_; | |
| 117 | |
| 118 typedef std::map<GURL, scoped_refptr<IndexedDBBackingStore> > | |
| 119 IndexedDBBackingStoreMap; | |
| 120 IndexedDBBackingStoreMap backing_store_map_; | |
| 121 | |
| 122 std::set<scoped_refptr<IndexedDBBackingStore> > session_only_backing_stores_; | |
| 123 IndexedDBBackingStoreMap backing_stores_with_active_blobs_; | |
| 124 std::set<GURL> backends_opened_since_boot_; | |
| 125 }; | |
| 126 | |
| 127 } // namespace content | |
| 128 | |
| 129 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FACTORY_IMPL_H_ | |
| OLD | NEW |