Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(723)

Unified Diff: content/browser/indexed_db/indexed_db_factory.h

Issue 313883003: Split IndexedDBFactory into virtual base + impl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added protected IndexedDBFactory constructor prototype. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/indexed_db/indexed_db_factory.h
diff --git a/content/browser/indexed_db/indexed_db_factory.h b/content/browser/indexed_db/indexed_db_factory.h
index c2177de7e567c3f7fd98d5a04d7648cb0e41172c..f3c2840be3f13f6cb03dde541d3c784941020a8a 100644
--- a/content/browser/indexed_db/indexed_db_factory.h
+++ b/content/browser/indexed_db/indexed_db_factory.h
@@ -27,7 +27,6 @@ class URLRequestContext;
namespace content {
class IndexedDBBackingStore;
-class IndexedDBContextImpl;
struct IndexedDBPendingConnection;
class CONTENT_EXPORT IndexedDBFactory
@@ -36,52 +35,53 @@ class CONTENT_EXPORT IndexedDBFactory
typedef std::multimap<GURL, IndexedDBDatabase*> OriginDBMap;
typedef OriginDBMap::const_iterator OriginDBMapIterator;
- explicit IndexedDBFactory(IndexedDBContextImpl* context);
-
- void ReleaseDatabase(const IndexedDBDatabase::Identifier& identifier,
- bool forcedClose);
-
- void GetDatabaseNames(scoped_refptr<IndexedDBCallbacks> callbacks,
- const GURL& origin_url,
- const base::FilePath& data_directory,
- net::URLRequestContext* request_context);
- void Open(const base::string16& name,
- const IndexedDBPendingConnection& connection,
- net::URLRequestContext* request_context,
- const GURL& origin_url,
- const base::FilePath& data_directory);
-
- void DeleteDatabase(const base::string16& name,
- net::URLRequestContext* request_context,
- scoped_refptr<IndexedDBCallbacks> callbacks,
- const GURL& origin_url,
- const base::FilePath& data_directory);
-
- void HandleBackingStoreFailure(const GURL& origin_url);
- void HandleBackingStoreCorruption(const GURL& origin_url,
- const IndexedDBDatabaseError& error);
+ virtual void ReleaseDatabase(const IndexedDBDatabase::Identifier& identifier,
+ bool forcedClose) = 0;
+
+ virtual void GetDatabaseNames(scoped_refptr<IndexedDBCallbacks> callbacks,
+ const GURL& origin_url,
+ const base::FilePath& data_directory,
+ net::URLRequestContext* request_context) = 0;
+ virtual void Open(const base::string16& name,
+ const IndexedDBPendingConnection& connection,
+ net::URLRequestContext* request_context,
+ const GURL& origin_url,
+ const base::FilePath& data_directory) = 0;
+
+ virtual void DeleteDatabase(const base::string16& name,
+ net::URLRequestContext* request_context,
+ scoped_refptr<IndexedDBCallbacks> callbacks,
+ const GURL& origin_url,
+ const base::FilePath& data_directory) = 0;
+
+ virtual void HandleBackingStoreFailure(const GURL& origin_url) = 0;
+ virtual void HandleBackingStoreCorruption(
+ const GURL& origin_url,
+ const IndexedDBDatabaseError& error) = 0;
- std::pair<OriginDBMapIterator, OriginDBMapIterator> GetOpenDatabasesForOrigin(
- const GURL& origin_url) const;
+ virtual std::pair<OriginDBMapIterator, OriginDBMapIterator>
+ GetOpenDatabasesForOrigin(const GURL& origin_url) const = 0;
- void ForceClose(const GURL& origin_url);
+ virtual void ForceClose(const GURL& origin_url) = 0;
// Called by the IndexedDBContext destructor so the factory can do cleanup.
- void ContextDestroyed();
+ virtual void ContextDestroyed() = 0;
// Called by the IndexedDBActiveBlobRegistry.
virtual void ReportOutstandingBlobs(const GURL& origin_url,
- bool blobs_outstanding);
+ bool blobs_outstanding) = 0;
// Called by an IndexedDBDatabase when it is actually deleted.
- void DatabaseDeleted(const IndexedDBDatabase::Identifier& identifier);
+ virtual void DatabaseDeleted(
+ const IndexedDBDatabase::Identifier& identifier) = 0;
- size_t GetConnectionCount(const GURL& origin_url) const;
+ virtual size_t GetConnectionCount(const GURL& origin_url) const = 0;
protected:
friend class base::RefCountedThreadSafe<IndexedDBFactory>;
- virtual ~IndexedDBFactory();
+ IndexedDBFactory() {}
jochen (gone - plz use gerrit) 2014/07/15 11:44:46 no need for a ctor on an interface
cmumford 2014/07/15 16:11:47 W/o it I get this error: error: constructor for '
+ virtual ~IndexedDBFactory() {}
jochen (gone - plz use gerrit) 2014/07/15 11:44:46 the dtor can be public as well
cmumford 2014/07/15 16:11:47 I think that describing as not an interface satisf
virtual scoped_refptr<IndexedDBBackingStore> OpenBackingStore(
const GURL& origin_url,
@@ -89,7 +89,7 @@ class CONTENT_EXPORT IndexedDBFactory
net::URLRequestContext* request_context,
blink::WebIDBDataLoss* data_loss,
std::string* data_loss_reason,
- bool* disk_full);
+ bool* disk_full) = 0;
virtual scoped_refptr<IndexedDBBackingStore> OpenBackingStoreHelper(
const GURL& origin_url,
@@ -98,53 +98,13 @@ class CONTENT_EXPORT IndexedDBFactory
blink::WebIDBDataLoss* data_loss,
std::string* data_loss_message,
bool* disk_full,
- bool first_time);
-
- void ReleaseBackingStore(const GURL& origin_url, bool immediate);
- void CloseBackingStore(const GURL& origin_url);
- IndexedDBContextImpl* context() const { return context_; }
+ bool first_time) = 0;
private:
- FRIEND_TEST_ALL_PREFIXES(IndexedDBFactoryTest,
- BackingStoreReleasedOnForcedClose);
- FRIEND_TEST_ALL_PREFIXES(IndexedDBFactoryTest,
- BackingStoreReleaseDelayedOnClose);
- FRIEND_TEST_ALL_PREFIXES(IndexedDBFactoryTest, DatabaseFailedOpen);
- FRIEND_TEST_ALL_PREFIXES(IndexedDBFactoryTest,
- DeleteDatabaseClosesBackingStore);
- FRIEND_TEST_ALL_PREFIXES(IndexedDBFactoryTest,
- ForceCloseReleasesBackingStore);
- FRIEND_TEST_ALL_PREFIXES(IndexedDBFactoryTest,
- GetDatabaseNamesClosesBackingStore);
FRIEND_TEST_ALL_PREFIXES(IndexedDBTest,
ForceCloseOpenDatabasesOnCommitFailure);
- // Called internally after a database is closed, with some delay. If this
- // factory has the last reference, it will be released.
- void MaybeCloseBackingStore(const GURL& origin_url);
- bool HasLastBackingStoreReference(const GURL& origin_url) const;
-
- // Testing helpers, so unit tests don't need to grovel through internal state.
- bool IsDatabaseOpen(const GURL& origin_url,
- const base::string16& name) const;
- bool IsBackingStoreOpen(const GURL& origin_url) const;
- bool IsBackingStorePendingClose(const GURL& origin_url) const;
- void RemoveDatabaseFromMaps(const IndexedDBDatabase::Identifier& identifier);
-
- IndexedDBContextImpl* context_;
-
- typedef std::map<IndexedDBDatabase::Identifier,
- IndexedDBDatabase*> IndexedDBDatabaseMap;
- IndexedDBDatabaseMap database_map_;
- OriginDBMap origin_dbs_;
-
- typedef std::map<GURL, scoped_refptr<IndexedDBBackingStore> >
- IndexedDBBackingStoreMap;
- IndexedDBBackingStoreMap backing_store_map_;
-
- std::set<scoped_refptr<IndexedDBBackingStore> > session_only_backing_stores_;
- IndexedDBBackingStoreMap backing_stores_with_active_blobs_;
- std::set<GURL> backends_opened_since_boot_;
+ virtual bool IsBackingStoreOpen(const GURL& origin_url) const = 0;
DISALLOW_COPY_AND_ASSIGN(IndexedDBFactory);
};

Powered by Google App Engine
This is Rietveld 408576698