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

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: 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 20d18c2dea0b519eafff49017f0cd28dc10fd078..4e597c748f5f94fd759972cdc70d0dda475e8536 100644
--- a/content/browser/indexed_db/indexed_db_factory.h
+++ b/content/browser/indexed_db/indexed_db_factory.h
@@ -25,7 +25,6 @@ class URLRequestContext;
namespace content {
class IndexedDBBackingStore;
-class IndexedDBContextImpl;
struct IndexedDBPendingConnection;
class CONTENT_EXPORT IndexedDBFactory
@@ -34,52 +33,52 @@ 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();
+ virtual ~IndexedDBFactory() {}
virtual scoped_refptr<IndexedDBBackingStore> OpenBackingStore(
const GURL& origin_url,
@@ -87,7 +86,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,
@@ -96,53 +95,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;
jsbell 2014/07/17 18:45:46 Since this is an impl detail, not part of the inte
cmumford 2014/07/17 20:11:52 Yeah, I'm not a fan of downcasting like this, but
};
} // namespace content
« no previous file with comments | « content/browser/indexed_db/indexed_db_context_impl.cc ('k') | content/browser/indexed_db/indexed_db_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698