// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "webkit/browser/fileapi/quota/quota_backend_impl.h"
+#include "storage/browser/fileapi/quota/quota_backend_impl.h"
#include <string>
#include "base/files/scoped_temp_dir.h"
#include "base/message_loop/message_loop.h"
+#include "storage/browser/fileapi/file_system_usage_cache.h"
+#include "storage/browser/fileapi/obfuscated_file_util.h"
+#include "storage/browser/quota/quota_manager_proxy.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/leveldatabase/src/helpers/memenv/memenv.h"
#include "third_party/leveldatabase/src/include/leveldb/env.h"
-#include "webkit/browser/fileapi/file_system_usage_cache.h"
-#include "webkit/browser/fileapi/obfuscated_file_util.h"
-#include "webkit/browser/quota/quota_manager_proxy.h"
-using fileapi::FileSystemUsageCache;
-using fileapi::ObfuscatedFileUtil;
-using fileapi::QuotaBackendImpl;
-using fileapi::SandboxFileSystemBackendDelegate;
+using storage::FileSystemUsageCache;
+using storage::ObfuscatedFileUtil;
+using storage::QuotaBackendImpl;
+using storage::SandboxFileSystemBackendDelegate;
namespace content {
return accepted;
}
-class MockQuotaManagerProxy : public quota::QuotaManagerProxy {
+class MockQuotaManagerProxy : public storage::QuotaManagerProxy {
public:
MockQuotaManagerProxy()
: QuotaManagerProxy(NULL, NULL),
// We don't mock them.
virtual void NotifyOriginInUse(const GURL& origin) OVERRIDE {}
virtual void NotifyOriginNoLongerInUse(const GURL& origin) OVERRIDE {}
- virtual void SetUsageCacheEnabled(quota::QuotaClient::ID client_id,
+ virtual void SetUsageCacheEnabled(storage::QuotaClient::ID client_id,
const GURL& origin,
- quota::StorageType type,
+ storage::StorageType type,
bool enabled) OVERRIDE {}
- virtual void NotifyStorageModified(
- quota::QuotaClient::ID client_id,
- const GURL& origin,
- quota::StorageType type,
- int64 delta) OVERRIDE {
+ virtual void NotifyStorageModified(storage::QuotaClient::ID client_id,
+ const GURL& origin,
+ storage::StorageType type,
+ int64 delta) OVERRIDE {
++storage_modified_count_;
usage_ += delta;
ASSERT_LE(usage_, quota_);
virtual void GetUsageAndQuota(
base::SequencedTaskRunner* original_task_runner,
const GURL& origin,
- quota::StorageType type,
+ storage::StorageType type,
const GetUsageAndQuotaCallback& callback) OVERRIDE {
- callback.Run(quota::kQuotaStatusOk, usage_, quota_);
+ callback.Run(storage::kQuotaStatusOk, usage_, quota_);
}
int storage_modified_count() { return storage_modified_count_; }
protected:
void InitializeForOriginAndType(const GURL& origin,
- fileapi::FileSystemType type) {
+ storage::FileSystemType type) {
ASSERT_TRUE(file_util_->InitOriginDatabase(origin, true /* create */));
ASSERT_TRUE(file_util_->origin_database_ != NULL);
}
base::FilePath GetUsageCachePath(const GURL& origin,
- fileapi::FileSystemType type) {
+ storage::FileSystemType type) {
base::FilePath path;
base::File::Error error =
backend_->GetUsageCachePath(origin, type, &path);
};
TEST_F(QuotaBackendImplTest, ReserveQuota_Basic) {
- fileapi::FileSystemType type = fileapi::kFileSystemTypeTemporary;
+ storage::FileSystemType type = storage::kFileSystemTypeTemporary;
InitializeForOriginAndType(GURL(kOrigin), type);
quota_manager_proxy_->set_quota(10000);
}
TEST_F(QuotaBackendImplTest, ReserveQuota_NoSpace) {
- fileapi::FileSystemType type = fileapi::kFileSystemTypeTemporary;
+ storage::FileSystemType type = storage::kFileSystemTypeTemporary;
InitializeForOriginAndType(GURL(kOrigin), type);
quota_manager_proxy_->set_quota(100);
}
TEST_F(QuotaBackendImplTest, ReserveQuota_Revert) {
- fileapi::FileSystemType type = fileapi::kFileSystemTypeTemporary;
+ storage::FileSystemType type = storage::kFileSystemTypeTemporary;
InitializeForOriginAndType(GURL(kOrigin), type);
quota_manager_proxy_->set_quota(10000);
}
TEST_F(QuotaBackendImplTest, ReleaseReservedQuota) {
- fileapi::FileSystemType type = fileapi::kFileSystemTypeTemporary;
+ storage::FileSystemType type = storage::kFileSystemTypeTemporary;
InitializeForOriginAndType(GURL(kOrigin), type);
const int64 kInitialUsage = 2000;
quota_manager_proxy_->set_usage(kInitialUsage);
}
TEST_F(QuotaBackendImplTest, CommitQuotaUsage) {
- fileapi::FileSystemType type = fileapi::kFileSystemTypeTemporary;
+ storage::FileSystemType type = storage::kFileSystemTypeTemporary;
InitializeForOriginAndType(GURL(kOrigin), type);
quota_manager_proxy_->set_quota(10000);
base::FilePath path = GetUsageCachePath(GURL(kOrigin), type);
}
TEST_F(QuotaBackendImplTest, DirtyCount) {
- fileapi::FileSystemType type = fileapi::kFileSystemTypeTemporary;
+ storage::FileSystemType type = storage::kFileSystemTypeTemporary;
InitializeForOriginAndType(GURL(kOrigin), type);
base::FilePath path = GetUsageCachePath(GURL(kOrigin), type);