| 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 fb6953b6c9530161c8e18ecfe9babd1820d3872b..40656984ebad692930744cbafde37acb7acc1fa8 100644
|
| --- a/content/browser/indexed_db/indexed_db_context_impl.cc
|
| +++ b/content/browser/indexed_db/indexed_db_context_impl.cc
|
| @@ -14,6 +14,7 @@
|
| #include "base/string_util.h"
|
| #include "base/utf_string_conversions.h"
|
| #include "content/browser/indexed_db/indexed_db_quota_client.h"
|
| +#include "content/browser/indexed_db/webidbfactory_impl.h"
|
| #include "content/public/browser/browser_thread.h"
|
| #include "content/public/browser/indexed_db_info.h"
|
| #include "content/public/common/content_switches.h"
|
| @@ -40,15 +41,14 @@ const base::FilePath::CharType IndexedDBContextImpl::kIndexedDBExtension[] =
|
|
|
| namespace {
|
|
|
| -void GetAllOriginsAndPaths(
|
| - const base::FilePath& indexeddb_path,
|
| - std::vector<GURL>* origins,
|
| - std::vector<base::FilePath>* file_paths) {
|
| +void GetAllOriginsAndPaths(const base::FilePath& indexeddb_path,
|
| + std::vector<GURL>* origins,
|
| + std::vector<base::FilePath>* file_paths) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
|
| if (indexeddb_path.empty())
|
| return;
|
| - file_util::FileEnumerator file_enumerator(indexeddb_path,
|
| - false, file_util::FileEnumerator::DIRECTORIES);
|
| + file_util::FileEnumerator file_enumerator(
|
| + indexeddb_path, false, file_util::FileEnumerator::DIRECTORIES);
|
| for (base::FilePath file_path = file_enumerator.Next(); !file_path.empty();
|
| file_path = file_enumerator.Next()) {
|
| if (file_path.Extension() == IndexedDBContextImpl::kIndexedDBExtension) {
|
| @@ -74,7 +74,8 @@ void ClearSessionOnlyOrigins(
|
| std::vector<base::FilePath>::const_iterator file_path_iter =
|
| file_paths.begin();
|
| for (std::vector<GURL>::const_iterator iter = origins.begin();
|
| - iter != origins.end(); ++iter, ++file_path_iter) {
|
| + iter != origins.end();
|
| + ++iter, ++file_path_iter) {
|
| if (!special_storage_policy->IsStorageSessionOnly(*iter))
|
| continue;
|
| if (special_storage_policy->IsStorageProtected(*iter))
|
| @@ -108,7 +109,10 @@ WebIDBFactory* IndexedDBContextImpl::GetIDBFactory() {
|
| // Prime our cache of origins with existing databases so we can
|
| // detect when dbs are newly created.
|
| GetOriginSet();
|
| - idb_factory_.reset(WebIDBFactory::create());
|
| + if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kNewIndexedDB))
|
| + idb_factory_.reset(new content::WebIDBFactoryImpl());
|
| + else
|
| + idb_factory_.reset(WebIDBFactory::create());
|
| }
|
| return idb_factory_.get();
|
| }
|
| @@ -118,7 +122,8 @@ std::vector<GURL> IndexedDBContextImpl::GetAllOrigins() {
|
| std::vector<GURL> origins;
|
| std::set<GURL>* origins_set = GetOriginSet();
|
| for (std::set<GURL>::const_iterator iter = origins_set->begin();
|
| - iter != origins_set->end(); ++iter) {
|
| + iter != origins_set->end();
|
| + ++iter) {
|
| origins.push_back(*iter);
|
| }
|
| return origins;
|
| @@ -128,7 +133,8 @@ std::vector<IndexedDBInfo> IndexedDBContextImpl::GetAllOriginsInfo() {
|
| std::vector<GURL> origins = GetAllOrigins();
|
| std::vector<IndexedDBInfo> result;
|
| for (std::vector<GURL>::const_iterator iter = origins.begin();
|
| - iter != origins.end(); ++iter) {
|
| + iter != origins.end();
|
| + ++iter) {
|
| const GURL& origin_url = *iter;
|
|
|
| base::FilePath idb_directory = GetFilePath(origin_url);
|
| @@ -202,7 +208,7 @@ base::FilePath IndexedDBContextImpl::GetFilePath(const GURL& origin_url) {
|
| }
|
|
|
| base::FilePath IndexedDBContextImpl::GetFilePathForTesting(
|
| - const string16& origin_id) const {
|
| + const string16& origin_id) const {
|
| return GetIndexedDBFilePath(origin_id);
|
| }
|
|
|
| @@ -211,7 +217,8 @@ void IndexedDBContextImpl::ConnectionOpened(const GURL& origin_url,
|
| DCHECK_EQ(connections_[origin_url].count(connection), 0UL);
|
| if (quota_manager_proxy()) {
|
| quota_manager_proxy()->NotifyStorageAccessed(
|
| - quota::QuotaClient::kIndexedDatabase, origin_url,
|
| + quota::QuotaClient::kIndexedDatabase,
|
| + origin_url,
|
| quota::kStorageTypeTemporary);
|
| }
|
| connections_[origin_url].insert(connection);
|
| @@ -232,7 +239,8 @@ void IndexedDBContextImpl::ConnectionClosed(const GURL& origin_url,
|
| return;
|
| if (quota_manager_proxy()) {
|
| quota_manager_proxy()->NotifyStorageAccessed(
|
| - quota::QuotaClient::kIndexedDatabase, origin_url,
|
| + quota::QuotaClient::kIndexedDatabase,
|
| + origin_url,
|
| quota::kStorageTypeTemporary);
|
| }
|
| connections_[origin_url].erase(connection);
|
| @@ -271,8 +279,8 @@ quota::QuotaManagerProxy* IndexedDBContextImpl::quota_manager_proxy() {
|
| IndexedDBContextImpl::~IndexedDBContextImpl() {
|
| WebKit::WebIDBFactory* factory = idb_factory_.release();
|
| if (factory) {
|
| - if (!BrowserThread::DeleteSoon(BrowserThread::WEBKIT_DEPRECATED,
|
| - FROM_HERE, factory))
|
| + if (!BrowserThread::DeleteSoon(
|
| + BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, factory))
|
| delete factory;
|
| }
|
|
|
| @@ -293,18 +301,17 @@ IndexedDBContextImpl::~IndexedDBContextImpl() {
|
| // No WEBKIT thread here means we are running in a unit test where no clean
|
| // up is needed.
|
| BrowserThread::PostTask(
|
| - BrowserThread::WEBKIT_DEPRECATED, FROM_HERE,
|
| - base::Bind(&ClearSessionOnlyOrigins,
|
| - data_path_,
|
| - special_storage_policy_));
|
| + BrowserThread::WEBKIT_DEPRECATED,
|
| + FROM_HERE,
|
| + base::Bind(
|
| + &ClearSessionOnlyOrigins, data_path_, special_storage_policy_));
|
| }
|
|
|
| base::FilePath IndexedDBContextImpl::GetIndexedDBFilePath(
|
| const string16& origin_id) const {
|
| DCHECK(!data_path_.empty());
|
| - base::FilePath::StringType id =
|
| - webkit_base::WebStringToFilePathString(origin_id).append(
|
| - FILE_PATH_LITERAL(".indexeddb"));
|
| + base::FilePath::StringType id = webkit_base::WebStringToFilePathString(
|
| + origin_id).append(FILE_PATH_LITERAL(".indexeddb"));
|
| return data_path_.Append(id.append(kIndexedDBExtension));
|
| }
|
|
|
| @@ -331,18 +338,20 @@ void IndexedDBContextImpl::QueryDiskAndUpdateQuotaUsage(
|
| if (difference) {
|
| origin_size_map_[origin_url] = current_disk_usage;
|
| // quota_manager_proxy() is NULL in unit tests.
|
| - if (quota_manager_proxy())
|
| + if (quota_manager_proxy()) {
|
| quota_manager_proxy()->NotifyStorageModified(
|
| quota::QuotaClient::kIndexedDatabase,
|
| origin_url,
|
| quota::kStorageTypeTemporary,
|
| difference);
|
| + }
|
| }
|
| }
|
|
|
| void IndexedDBContextImpl::GotUsageAndQuota(const GURL& origin_url,
|
| quota::QuotaStatusCode status,
|
| - int64 usage, int64 quota) {
|
| + int64 usage,
|
| + int64 quota) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| DCHECK(status == quota::kQuotaStatusOk || status == quota::kQuotaErrorAbort)
|
| << "status was " << status;
|
| @@ -350,13 +359,17 @@ void IndexedDBContextImpl::GotUsageAndQuota(const GURL& origin_url,
|
| // We seem to no longer care to wait around for the answer.
|
| return;
|
| }
|
| - BrowserThread::PostTask(
|
| - BrowserThread::WEBKIT_DEPRECATED, FROM_HERE,
|
| - base::Bind(&IndexedDBContextImpl::GotUpdatedQuota, this, origin_url,
|
| - usage, quota));
|
| + BrowserThread::PostTask(BrowserThread::WEBKIT_DEPRECATED,
|
| + FROM_HERE,
|
| + base::Bind(&IndexedDBContextImpl::GotUpdatedQuota,
|
| + this,
|
| + origin_url,
|
| + usage,
|
| + quota));
|
| }
|
|
|
| -void IndexedDBContextImpl::GotUpdatedQuota(const GURL& origin_url, int64 usage,
|
| +void IndexedDBContextImpl::GotUpdatedQuota(const GURL& origin_url,
|
| + int64 usage,
|
| int64 quota) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
|
| space_available_map_[origin_url] = quota - usage;
|
| @@ -365,11 +378,13 @@ void IndexedDBContextImpl::GotUpdatedQuota(const GURL& origin_url, int64 usage,
|
| void IndexedDBContextImpl::QueryAvailableQuota(const GURL& origin_url) {
|
| if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
|
| - if (quota_manager_proxy())
|
| + if (quota_manager_proxy()) {
|
| BrowserThread::PostTask(
|
| - BrowserThread::IO, FROM_HERE,
|
| - base::Bind(&IndexedDBContextImpl::QueryAvailableQuota, this,
|
| - origin_url));
|
| + BrowserThread::IO,
|
| + FROM_HERE,
|
| + base::Bind(
|
| + &IndexedDBContextImpl::QueryAvailableQuota, this, origin_url));
|
| + }
|
| return;
|
| }
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| @@ -387,7 +402,8 @@ std::set<GURL>* IndexedDBContextImpl::GetOriginSet() {
|
| std::vector<GURL> origins;
|
| GetAllOriginsAndPaths(data_path_, &origins, NULL);
|
| for (std::vector<GURL>::const_iterator iter = origins.begin();
|
| - iter != origins.end(); ++iter) {
|
| + iter != origins.end();
|
| + ++iter) {
|
| origin_set_->insert(*iter);
|
| }
|
| }
|
|
|