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

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

Issue 13949013: Implement download link in chrome://indexeddb-internals/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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_context_impl.cc
diff --git a/content/browser/indexed_db/indexed_db_context_impl.cc b/content/browser/indexed_db/indexed_db_context_impl.cc
index bc37cfa3656724ba10440580e01df0d033213906..5c92202f4985fa80ff4b9485e2019806d1526a07 100644
--- a/content/browser/indexed_db/indexed_db_context_impl.cc
+++ b/content/browser/indexed_db/indexed_db_context_impl.cc
@@ -130,30 +130,28 @@ std::vector<IndexedDBInfo> IndexedDBContextImpl::GetAllOriginsInfo() {
std::vector<IndexedDBInfo> result;
for (std::vector<GURL>::const_iterator iter = origins.begin();
iter != origins.end(); ++iter) {
- const GURL& origin = *iter;
+ const GURL& origin_url = *iter;
- string16 origin_id = DatabaseUtil::GetOriginIdentifier(origin);
- base::FilePath idb_directory = GetIndexedDBFilePath(origin_id);
- result.push_back(IndexedDBInfo(origin,
- GetOriginDiskUsage(origin),
- GetOriginLastModified(origin),
+ base::FilePath idb_directory = GetFilePath(origin_url);
+ result.push_back(IndexedDBInfo(origin_url,
+ GetOriginDiskUsage(origin_url),
+ GetOriginLastModified(origin_url),
idb_directory));
}
return result;
}
int64 IndexedDBContextImpl::GetOriginDiskUsage(const GURL& origin_url) {
- if (data_path_.empty() || !IsInOriginSet(origin_url))
+ if (data_path_.empty() || !HasOrigin(origin_url))
return 0;
EnsureDiskUsageCacheInitialized(origin_url);
return origin_size_map_[origin_url];
}
base::Time IndexedDBContextImpl::GetOriginLastModified(const GURL& origin_url) {
- if (data_path_.empty() || !IsInOriginSet(origin_url))
+ if (data_path_.empty() || !HasOrigin(origin_url))
return base::Time();
- string16 origin_id = DatabaseUtil::GetOriginIdentifier(origin_url);
- base::FilePath idb_directory = GetIndexedDBFilePath(origin_id);
+ base::FilePath idb_directory = GetFilePath(origin_url);
base::PlatformFileInfo file_info;
if (!file_util::GetFileInfo(idb_directory, &file_info))
return base::Time();
@@ -162,7 +160,26 @@ base::Time IndexedDBContextImpl::GetOriginLastModified(const GURL& origin_url) {
void IndexedDBContextImpl::DeleteForOrigin(const GURL& origin_url) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
- if (data_path_.empty() || !IsInOriginSet(origin_url))
+ ForceClose(origin_url);
+ if (data_path_.empty() || !HasOrigin(origin_url))
+ return;
+
+ base::FilePath idb_directory = GetFilePath(origin_url);
+ EnsureDiskUsageCacheInitialized(origin_url);
+ const bool recursive = true;
+ bool deleted = file_util::Delete(idb_directory, recursive);
+
+ QueryDiskAndUpdateQuotaUsage(origin_url);
+ if (deleted) {
+ RemoveFromOriginSet(origin_url);
+ origin_size_map_.erase(origin_url);
+ space_available_map_.erase(origin_url);
+ }
+}
+
+void IndexedDBContextImpl::ForceClose(const GURL& origin_url) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
+ if (data_path_.empty() || !HasOrigin(origin_url))
return;
if (connections_.find(origin_url) != connections_.end()) {
@@ -174,22 +191,14 @@ void IndexedDBContextImpl::DeleteForOrigin(const GURL& origin_url) {
connections.erase(it++);
db->forceClose();
}
- DCHECK(connections_[origin_url].size() == 0);
+ DCHECK_EQ(connections_[origin_url].size(), 0UL);
connections_.erase(origin_url);
}
+}
+base::FilePath IndexedDBContextImpl::GetFilePath(const GURL& origin_url) {
string16 origin_id = DatabaseUtil::GetOriginIdentifier(origin_url);
- base::FilePath idb_directory = GetIndexedDBFilePath(origin_id);
- EnsureDiskUsageCacheInitialized(origin_url);
- const bool recursive = true;
- bool deleted = file_util::Delete(idb_directory, recursive);
-
- QueryDiskAndUpdateQuotaUsage(origin_url);
- if (deleted) {
- RemoveFromOriginSet(origin_url);
- origin_size_map_.erase(origin_url);
- space_available_map_.erase(origin_url);
- }
+ return GetIndexedDBFilePath(origin_id);
}
base::FilePath IndexedDBContextImpl::GetFilePathForTesting(
@@ -199,7 +208,7 @@ base::FilePath IndexedDBContextImpl::GetFilePathForTesting(
void IndexedDBContextImpl::ConnectionOpened(const GURL& origin_url,
WebIDBDatabase* connection) {
- DCHECK(connections_[origin_url].count(connection) == 0);
+ DCHECK_EQ(connections_[origin_url].count(connection), 0UL);
if (quota_manager_proxy()) {
quota_manager_proxy()->NotifyStorageAccessed(
quota::QuotaClient::kIndexedDatabase, origin_url,
@@ -384,6 +393,11 @@ std::set<GURL>* IndexedDBContextImpl::GetOriginSet() {
return origin_set_.get();
}
+bool IndexedDBContextImpl::HasOrigin(const GURL& origin_url) {
+ std::set<GURL>* set = GetOriginSet();
+ return set->find(origin_url) != set->end();
+}
+
void IndexedDBContextImpl::ResetCaches() {
origin_set_.reset();
origin_size_map_.clear();

Powered by Google App Engine
This is Rietveld 408576698