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

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

Issue 203833003: Add the IndexedDBActiveBlobRegistry, currently unused, to enable future blob (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Code review feedback rolled in. Created 6 years, 9 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.cc
diff --git a/content/browser/indexed_db/indexed_db_factory.cc b/content/browser/indexed_db/indexed_db_factory.cc
index 86af571319c65643c5a4acec2d533455f915c390..2e926580ed850d8550d6c464620489b42f103988 100644
--- a/content/browser/indexed_db/indexed_db_factory.cc
+++ b/content/browser/indexed_db/indexed_db_factory.cc
@@ -59,6 +59,15 @@ void IndexedDBFactory::ReleaseDatabase(
void IndexedDBFactory::ReleaseBackingStore(const GURL& origin_url,
bool immediate) {
+ if (immediate) {
+ IndexedDBBackingStoreMap::iterator it =
+ backing_stores_with_active_blobs_.find(origin_url);
+ if (it != backing_stores_with_active_blobs_.end()) {
+ it->second->active_blob_registry()->ForceShutdown();
+ backing_stores_with_active_blobs_.erase(it);
+ }
+ }
+
// Only close if this is the last reference.
if (!HasLastBackingStoreReference(origin_url))
return;
@@ -133,13 +142,36 @@ void IndexedDBFactory::ContextDestroyed() {
++it)
it->second->close_timer()->Stop();
backing_store_map_.clear();
+ backing_stores_with_active_blobs_.clear();
context_ = NULL;
}
+void IndexedDBFactory::ReportOutstandingBlobs(const GURL& origin_url,
+ bool blobs_outstanding) {
+ if (!context_)
+ return;
+ if (blobs_outstanding) {
+ DCHECK(!backing_stores_with_active_blobs_.count(origin_url));
+ IndexedDBBackingStoreMap::iterator it = backing_store_map_.find(origin_url);
+ if (it != backing_store_map_.end())
+ backing_stores_with_active_blobs_.insert(*it);
+ else
+ DCHECK(false);
+ } else {
+ IndexedDBBackingStoreMap::iterator it =
+ backing_stores_with_active_blobs_.find(origin_url);
+ if (it != backing_stores_with_active_blobs_.end()) {
+ backing_stores_with_active_blobs_.erase(it);
+ ReleaseBackingStore(origin_url, false /* immediate */);
+ }
+ }
+}
+
void IndexedDBFactory::GetDatabaseNames(
scoped_refptr<IndexedDBCallbacks> callbacks,
const GURL& origin_url,
- const base::FilePath& data_directory) {
+ const base::FilePath& data_directory,
+ base::TaskRunner* task_runner) {
IDB_TRACE("IndexedDBFactory::GetDatabaseNames");
// TODO(dgrogan): Plumb data_loss back to script eventually?
blink::WebIDBDataLoss data_loss;
@@ -150,7 +182,8 @@ void IndexedDBFactory::GetDatabaseNames(
data_directory,
&data_loss,
&data_loss_message,
- &disk_full);
+ &disk_full,
+ task_runner);
if (!backing_store) {
callbacks->OnError(
IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionUnknownError,
@@ -168,7 +201,8 @@ void IndexedDBFactory::DeleteDatabase(
const base::string16& name,
scoped_refptr<IndexedDBCallbacks> callbacks,
const GURL& origin_url,
- const base::FilePath& data_directory) {
+ const base::FilePath& data_directory,
+ base::TaskRunner* task_runner) {
IDB_TRACE("IndexedDBFactory::DeleteDatabase");
IndexedDBDatabase::Identifier unique_identifier(origin_url, name);
IndexedDBDatabaseMap::iterator it = database_map_.find(unique_identifier);
@@ -188,7 +222,8 @@ void IndexedDBFactory::DeleteDatabase(
data_directory,
&data_loss,
&data_loss_message,
- &disk_full);
+ &disk_full,
+ task_runner);
if (!backing_store) {
callbacks->OnError(
IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionUnknownError,
@@ -258,7 +293,8 @@ scoped_refptr<IndexedDBBackingStore> IndexedDBFactory::OpenBackingStore(
const base::FilePath& data_directory,
blink::WebIDBDataLoss* data_loss,
std::string* data_loss_message,
- bool* disk_full) {
+ bool* disk_full,
+ base::TaskRunner* task_runner) {
const bool open_in_memory = data_directory.empty();
IndexedDBBackingStoreMap::iterator it2 = backing_store_map_.find(origin_url);
@@ -269,13 +305,16 @@ scoped_refptr<IndexedDBBackingStore> IndexedDBFactory::OpenBackingStore(
scoped_refptr<IndexedDBBackingStore> backing_store;
if (open_in_memory) {
- backing_store = IndexedDBBackingStore::OpenInMemory(origin_url);
+ backing_store =
+ IndexedDBBackingStore::OpenInMemory(origin_url, task_runner);
} else {
- backing_store = IndexedDBBackingStore::Open(origin_url,
+ backing_store = IndexedDBBackingStore::Open(this,
+ origin_url,
data_directory,
data_loss,
data_loss_message,
- disk_full);
+ disk_full,
+ task_runner);
}
if (backing_store.get()) {
@@ -297,7 +336,8 @@ scoped_refptr<IndexedDBBackingStore> IndexedDBFactory::OpenBackingStore(
void IndexedDBFactory::Open(const base::string16& name,
const IndexedDBPendingConnection& connection,
const GURL& origin_url,
- const base::FilePath& data_directory) {
+ const base::FilePath& data_directory,
+ base::TaskRunner* task_runner) {
IDB_TRACE("IndexedDBFactory::Open");
scoped_refptr<IndexedDBDatabase> database;
IndexedDBDatabase::Identifier unique_identifier(origin_url, name);
@@ -313,7 +353,8 @@ void IndexedDBFactory::Open(const base::string16& name,
data_directory,
&data_loss,
&data_loss_message,
- &disk_full);
+ &disk_full,
+ task_runner);
if (!backing_store) {
if (disk_full) {
connection.callbacks->OnError(

Powered by Google App Engine
This is Rietveld 408576698