summaryrefslogtreecommitdiffstats
path: root/webkit/fileapi
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-02 20:08:18 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-02 20:08:18 +0000
commitfcc35653955e36b6a6d9cab579ba548e44d0fce1 (patch)
treec7f08a2aa850c40ade93e47f8ed690c719505e65 /webkit/fileapi
parent834f9def130038aeb8ff8fbf3d55c37a31ec319e (diff)
downloadchromium_src-fcc35653955e36b6a6d9cab579ba548e44d0fce1.zip
chromium_src-fcc35653955e36b6a6d9cab579ba548e44d0fce1.tar.gz
chromium_src-fcc35653955e36b6a6d9cab579ba548e44d0fce1.tar.bz2
Revert 76578 (accidental commit by the commit bot) - Add a function for usage tracking. It's based on the bug 6426001.
BUG= TEST= Review URL: http://codereview.chromium.org/6453001 TBR=dmikurube@google.com Review URL: http://codereview.chromium.org/6588129 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76594 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/fileapi')
-rw-r--r--webkit/fileapi/file_system_usage_cache.cc120
-rw-r--r--webkit/fileapi/file_system_usage_cache.h46
-rw-r--r--webkit/fileapi/file_system_usage_cache_unittest.cc145
-rw-r--r--webkit/fileapi/file_system_usage_tracker.cc20
-rw-r--r--webkit/fileapi/file_system_usage_tracker_unittest.cc225
-rw-r--r--webkit/fileapi/webkit_fileapi.gypi3
6 files changed, 8 insertions, 551 deletions
diff --git a/webkit/fileapi/file_system_usage_cache.cc b/webkit/fileapi/file_system_usage_cache.cc
deleted file mode 100644
index 05fbea6..0000000
--- a/webkit/fileapi/file_system_usage_cache.cc
+++ /dev/null
@@ -1,120 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "webkit/fileapi/file_system_usage_cache.h"
-
-#include "base/file_path.h"
-#include "base/file_util.h"
-#include "base/pickle.h"
-
-namespace fileapi {
-
-const char FileSystemUsageCache::kUsageFileName[] = ".usage";
-const char FileSystemUsageCache::kUsageFileHeader[] = "FSU0";
-const int FileSystemUsageCache::kUsageFileHeaderSize = 4;
-const int FileSystemUsageCache::kUsageFileSize =
- sizeof(Pickle::Header) +
- FileSystemUsageCache::kUsageFileHeaderSize +
- sizeof(int32) + sizeof(int64);
-
-// static
-int64 FileSystemUsageCache::GetUsage(const FilePath& usage_file_path) {
- uint32 dirty = 0;
- int64 fs_usage;
- fs_usage = Read(usage_file_path, &dirty);
-
- if (fs_usage < 0 || dirty > 0)
- return -1;
-
- return fs_usage;
-}
-
-// static
-bool FileSystemUsageCache::IncrementDirty(const FilePath& usage_file_path) {
- uint32 dirty = 0;
- int64 fs_usage;
- fs_usage = Read(usage_file_path, &dirty);
-
- if (fs_usage < 0)
- return false;
-
- return Write(usage_file_path, dirty + 1, fs_usage) >= 0;
-}
-
-// static
-bool FileSystemUsageCache::DecrementDirty(const FilePath& usage_file_path) {
- uint32 dirty = 0;
- int64 fs_usage;
- fs_usage = Read(usage_file_path, &dirty);
-
- if (fs_usage < 0 || dirty <= 0)
- return false;
-
- return Write(usage_file_path, dirty - 1, fs_usage) >= 0;
-}
-
-// static
-int FileSystemUsageCache::UpdateUsage(const FilePath& usage_file_path,
- int64 fs_usage) {
- return Write(usage_file_path, 0, fs_usage);
-}
-
-// static
-bool FileSystemUsageCache::Exists(const FilePath& usage_file_path) {
- return file_util::PathExists(usage_file_path);
-}
-
-// static
-bool FileSystemUsageCache::Delete(const FilePath& usage_file_path) {
- return file_util::Delete(usage_file_path, true);
-}
-
-// static
-int64 FileSystemUsageCache::Read(const FilePath& usage_file_path,
- uint32* dirty) {
- char buffer[kUsageFileSize];
- const char *header;
- file_util::ReadFile(usage_file_path, buffer, kUsageFileSize);
- Pickle read_pickle(buffer, kUsageFileSize);
- void* iter = NULL;
- int64 fs_usage;
-
- if (!read_pickle.ReadBytes(&iter, &header, kUsageFileHeaderSize) ||
- !read_pickle.ReadUInt32(&iter, dirty) ||
- !read_pickle.ReadInt64(&iter, &fs_usage))
- return -1;
-
- if (header[0] != kUsageFileHeader[0] ||
- header[1] != kUsageFileHeader[1] ||
- header[2] != kUsageFileHeader[2] ||
- header[3] != kUsageFileHeader[3])
- return -1;
-
- return fs_usage;
-}
-
-// static
-int FileSystemUsageCache::Write(const FilePath& usage_file_path,
- uint32 dirty, int64 fs_usage) {
- Pickle write_pickle;
- write_pickle.WriteBytes(kUsageFileHeader, kUsageFileHeaderSize);
- write_pickle.WriteUInt32(dirty);
- write_pickle.WriteInt64(fs_usage);
-
- FilePath temporary_usage_file_path;
- file_util::CreateTemporaryFileInDir(usage_file_path.DirName(),
- &temporary_usage_file_path);
- int bytes_written = file_util::WriteFile(temporary_usage_file_path,
- (const char *)write_pickle.data(),
- write_pickle.size());
- if (bytes_written != kUsageFileSize)
- return -1;
-
- if (file_util::ReplaceFile(temporary_usage_file_path, usage_file_path))
- return bytes_written;
- else
- return -1;
-}
-
-}
diff --git a/webkit/fileapi/file_system_usage_cache.h b/webkit/fileapi/file_system_usage_cache.h
deleted file mode 100644
index 32fc9b8..0000000
--- a/webkit/fileapi/file_system_usage_cache.h
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef WEBKIT_FILEAPI_FILE_SYSTEM_USAGE_CACHE_H_
-#define WEBKIT_FILEAPI_FILE_SYSTEM_USAGE_CACHE_H_
-
-#include "base/basictypes.h"
-#include "base/file_path.h"
-
-namespace fileapi {
-
-class FileSystemUsageCache {
- public:
- // Gets the size described in the .usage file.
- // Returns less than zero if the size is not availble.
- static int64 GetUsage(const FilePath& usage_file_path);
-
- // Increments or decrements the "dirty" entry in the .usage file.
- // Returns false if no .usage is available.
- static bool IncrementDirty(const FilePath& usage_file_path);
- static bool DecrementDirty(const FilePath& usage_file_path);
-
- // Updates the size described in the .usage file.
- static int UpdateUsage(const FilePath& usage_file_path, int64 fs_usage);
-
- static bool Exists(const FilePath& usage_file_path);
- static bool Delete(const FilePath& usage_file_path);
-
- static const char kUsageFileName[];
- static const char kUsageFileHeader[];
- static const int kUsageFileSize;
- static const int kUsageFileHeaderSize;
-
- private:
- // Read the size and the "dirty" entry described in the .usage file.
- // Returns less than zero if no .usage file is available.
- static int64 Read(const FilePath& usage_file_path, uint32* dirty);
-
- static int Write(const FilePath& usage_file_path,
- uint32 dirty, int64 fs_usage);
-};
-
-} // namespace fileapi
-
-#endif // WEBKIT_FILEAPI_FILE_SYSTEM_USAGE_CACHE_H_
diff --git a/webkit/fileapi/file_system_usage_cache_unittest.cc b/webkit/fileapi/file_system_usage_cache_unittest.cc
deleted file mode 100644
index f74bdbb..0000000
--- a/webkit/fileapi/file_system_usage_cache_unittest.cc
+++ /dev/null
@@ -1,145 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "webkit/fileapi/file_system_usage_cache.h"
-
-#include "base/basictypes.h"
-#include "base/file_util.h"
-#include "base/scoped_temp_dir.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-using namespace fileapi;
-
-class FileSystemUsageCacheTest : public testing::Test {
- public:
- FileSystemUsageCacheTest() {}
-
- void SetUp() {
- ASSERT_TRUE(data_dir_.CreateUniqueTempDir());
- }
-
-protected:
- FilePath GetUsageFilePath() {
- return data_dir_.path().AppendASCII(FileSystemUsageCache::kUsageFileName);
- }
-
- private:
- ScopedTempDir data_dir_;
-
- DISALLOW_COPY_AND_ASSIGN(FileSystemUsageCacheTest);
-};
-
-TEST_F(FileSystemUsageCacheTest, CreateTest) {
- FilePath usage_file_path = GetUsageFilePath();
- EXPECT_EQ(FileSystemUsageCache::kUsageFileSize,
- FileSystemUsageCache::UpdateUsage(usage_file_path, 0));
-}
-
-TEST_F(FileSystemUsageCacheTest, SetSizeTest) {
- static const int64 size = 240122;
- FilePath usage_file_path = GetUsageFilePath();
- ASSERT_EQ(FileSystemUsageCache::kUsageFileSize,
- FileSystemUsageCache::UpdateUsage(usage_file_path, size));
- EXPECT_EQ(size, FileSystemUsageCache::GetUsage(usage_file_path));
-}
-
-TEST_F(FileSystemUsageCacheTest, SetLargeSizeTest) {
- static const int64 size = kint64max;
- FilePath usage_file_path = GetUsageFilePath();
- ASSERT_EQ(FileSystemUsageCache::kUsageFileSize,
- FileSystemUsageCache::UpdateUsage(usage_file_path, size));
- EXPECT_EQ(size, FileSystemUsageCache::GetUsage(usage_file_path));
-}
-
-TEST_F(FileSystemUsageCacheTest, IncAndGetSizeTest) {
- FilePath usage_file_path = GetUsageFilePath();
- ASSERT_EQ(FileSystemUsageCache::kUsageFileSize,
- FileSystemUsageCache::UpdateUsage(usage_file_path, 98214));
- ASSERT_EQ(true,
- FileSystemUsageCache::IncrementDirty(usage_file_path));
- EXPECT_EQ(-1, FileSystemUsageCache::GetUsage(usage_file_path));
-}
-
-TEST_F(FileSystemUsageCacheTest, DecAndGetSizeTest) {
- static const int64 size = 71839;
- FilePath usage_file_path = GetUsageFilePath();
- ASSERT_EQ(FileSystemUsageCache::kUsageFileSize,
- FileSystemUsageCache::UpdateUsage(usage_file_path, size));
- // DecrementDirty for dirty = 0 is invalid. It returns false.
- ASSERT_EQ(false,
- FileSystemUsageCache::DecrementDirty(usage_file_path));
- EXPECT_EQ(size, FileSystemUsageCache::GetUsage(usage_file_path));
-}
-
-TEST_F(FileSystemUsageCacheTest, IncDecAndGetSizeTest) {
- static const int64 size = 198491;
- FilePath usage_file_path = GetUsageFilePath();
- ASSERT_EQ(FileSystemUsageCache::kUsageFileSize,
- FileSystemUsageCache::UpdateUsage(usage_file_path, size));
- ASSERT_EQ(true,
- FileSystemUsageCache::IncrementDirty(usage_file_path));
- ASSERT_EQ(true,
- FileSystemUsageCache::DecrementDirty(usage_file_path));
- EXPECT_EQ(size, FileSystemUsageCache::GetUsage(usage_file_path));
-}
-
-TEST_F(FileSystemUsageCacheTest, DecIncAndGetSizeTest) {
- FilePath usage_file_path = GetUsageFilePath();
- ASSERT_EQ(FileSystemUsageCache::kUsageFileSize,
- FileSystemUsageCache::UpdateUsage(usage_file_path, 854238));
- // DecrementDirty for dirty = 0 is invalid. It returns false.
- ASSERT_EQ(false,
- FileSystemUsageCache::DecrementDirty(usage_file_path));
- ASSERT_EQ(true,
- FileSystemUsageCache::IncrementDirty(usage_file_path));
- // It tests DecrementDirty (which returns false) has no effect, i.e
- // does not make dirty = -1 after DecrementDirty.
- EXPECT_EQ(-1, FileSystemUsageCache::GetUsage(usage_file_path));
-}
-
-TEST_F(FileSystemUsageCacheTest, ManyIncsSameDecsAndGetSizeTest) {
- static const int64 size = 82412;
- FilePath usage_file_path = GetUsageFilePath();
- ASSERT_EQ(FileSystemUsageCache::kUsageFileSize,
- FileSystemUsageCache::UpdateUsage(usage_file_path, size));
- for (int i = 0; i < 20; i++) {
- ASSERT_EQ(true,
- FileSystemUsageCache::IncrementDirty(usage_file_path));
- }
- for (int i = 0; i < 20; i++) {
- ASSERT_EQ(true,
- FileSystemUsageCache::DecrementDirty(usage_file_path));
- }
- EXPECT_EQ(size, FileSystemUsageCache::GetUsage(usage_file_path));
-}
-
-TEST_F(FileSystemUsageCacheTest, ManyIncsLessDecsAndGetSizeTest) {
- FilePath usage_file_path = GetUsageFilePath();
- ASSERT_EQ(FileSystemUsageCache::kUsageFileSize,
- FileSystemUsageCache::UpdateUsage(usage_file_path, 19319));
- for (int i = 0; i < 20; i++) {
- ASSERT_EQ(true,
- FileSystemUsageCache::IncrementDirty(usage_file_path));
- }
- for (int i = 0; i < 19; i++) {
- ASSERT_EQ(true,
- FileSystemUsageCache::DecrementDirty(usage_file_path));
- }
- EXPECT_EQ(-1, FileSystemUsageCache::GetUsage(usage_file_path));
-}
-
-TEST_F(FileSystemUsageCacheTest, GetSizeWithoutCacheFileTest) {
- FilePath usage_file_path = GetUsageFilePath();
- EXPECT_EQ(-1, FileSystemUsageCache::GetUsage(usage_file_path));
-}
-
-TEST_F(FileSystemUsageCacheTest, IncrementDirtyWithoutCacheFileTest) {
- FilePath usage_file_path = GetUsageFilePath();
- EXPECT_EQ(false, FileSystemUsageCache::IncrementDirty(usage_file_path));
-}
-
-TEST_F(FileSystemUsageCacheTest, DecrementDirtyWithoutCacheFileTest) {
- FilePath usage_file_path = GetUsageFilePath();
- EXPECT_EQ(false, FileSystemUsageCache::IncrementDirty(usage_file_path));
-}
diff --git a/webkit/fileapi/file_system_usage_tracker.cc b/webkit/fileapi/file_system_usage_tracker.cc
index 9456f2a..f58e4aa 100644
--- a/webkit/fileapi/file_system_usage_tracker.cc
+++ b/webkit/fileapi/file_system_usage_tracker.cc
@@ -14,7 +14,6 @@
#include "base/task.h"
#include "googleurl/src/gurl.h"
#include "webkit/fileapi/file_system_path_manager.h"
-#include "webkit/fileapi/file_system_usage_cache.h"
namespace fileapi {
@@ -53,24 +52,7 @@ class FileSystemUsageTracker::GetUsageTask
void RunOnFileThread() {
DCHECK(file_message_loop_->BelongsToCurrentThread());
- if (!file_util::DirectoryExists(origin_base_path_))
- fs_usage_ = 0;
- else {
- FilePath usage_file_path = origin_base_path_.AppendASCII(
- FileSystemUsageCache::kUsageFileName);
- fs_usage_ = FileSystemUsageCache::GetUsage(usage_file_path);
-
- if (fs_usage_ < 0) {
- FilePath content_file_path = origin_base_path_;
- if (FileSystemUsageCache::Exists(usage_file_path))
- FileSystemUsageCache::Delete(usage_file_path);
- fs_usage_ = file_util::ComputeDirectorySize(content_file_path);
- // fs_usage_ will include the size of .usage.
- // The result of ComputeDirectorySize does not include it.
- fs_usage_ += FileSystemUsageCache::kUsageFileSize;
- FileSystemUsageCache::UpdateUsage(usage_file_path, fs_usage_);
- }
- }
+ // TODO(dmikurube): add the code that retrieves the origin usage here.
original_message_loop_->PostTask(
FROM_HERE, NewRunnableMethod(this, &GetUsageTask::Completed));
diff --git a/webkit/fileapi/file_system_usage_tracker_unittest.cc b/webkit/fileapi/file_system_usage_tracker_unittest.cc
index 6bb541f..0d8a33c 100644
--- a/webkit/fileapi/file_system_usage_tracker_unittest.cc
+++ b/webkit/fileapi/file_system_usage_tracker_unittest.cc
@@ -8,31 +8,15 @@
#include "base/file_util.h"
#include "base/message_loop.h"
#include "base/message_loop_proxy.h"
-#include "base/platform_file.h"
#include "base/scoped_callback_factory.h"
#include "googleurl/src/gurl.h"
#include "base/scoped_temp_dir.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "webkit/fileapi/file_system_path_manager.h"
#include "webkit/fileapi/file_system_types.h"
-#include "webkit/fileapi/file_system_usage_cache.h"
using namespace fileapi;
-namespace {
-
-static const GURL kDummyURL1("http://www.dummy.org");
-static const GURL kDummyURL2("http://www.example.com");
-
-// Declared to shorten the variable names.
-static const fileapi::FileSystemType kTemporary =
- fileapi::kFileSystemTypeTemporary;
-static const fileapi::FileSystemType kPersistent =
- fileapi::kFileSystemTypePersistent;
-static const int kUsageFileSize = FileSystemUsageCache::kUsageFileSize;
-
-}
-
class FileSystemUsageTrackerTest : public testing::Test {
public:
FileSystemUsageTrackerTest()
@@ -43,14 +27,6 @@ class FileSystemUsageTrackerTest : public testing::Test {
ASSERT_TRUE(data_dir_.CreateUniqueTempDir());
}
- struct TestFile {
- bool isDirectory;
- const char* name;
- int64 size;
- GURL origin_url;
- fileapi::FileSystemType type;
- };
-
protected:
FileSystemUsageTracker* NewUsageTracker(bool is_incognito) {
return new FileSystemUsageTracker(
@@ -68,67 +44,6 @@ class FileSystemUsageTrackerTest : public testing::Test {
return usage_;
}
- FilePath GetOriginBasePath(const GURL& origin_url,
- fileapi::FileSystemType type) {
- return
- FileSystemPathManager::GetFileSystemBaseDirectoryForOriginAndType(
- data_dir_.path().Append(
- FileSystemPathManager::kFileSystemDirectory),
- FileSystemPathManager::GetOriginIdentifierFromURL(origin_url),
- type);
- }
-
- bool CreateFileSystemDirectory(const char* dir_name,
- const GURL& origin_url,
- fileapi::FileSystemType type) {
- FilePath origin_base_path = GetOriginBasePath(origin_url, type);
- FilePath dir_path;
- if (dir_name != NULL)
- dir_path = origin_base_path.AppendASCII(dir_name);
- else
- dir_path = origin_base_path;
- if (dir_path.empty())
- return false;
-
- return file_util::CreateDirectory(dir_path);
- }
-
- bool CreateFileSystemFile(const char* file_name,
- int64 file_size,
- const GURL& origin_url,
- fileapi::FileSystemType type) {
- FilePath origin_base_path = GetOriginBasePath(origin_url, type);
- FilePath file_path = origin_base_path.AppendASCII(file_name);
-
- if (file_path.empty())
- return false;
-
- int file_flags = base::PLATFORM_FILE_CREATE_ALWAYS |
- base::PLATFORM_FILE_WRITE;
- base::PlatformFileError error_code;
- base::PlatformFile file =
- base::CreatePlatformFile(file_path, file_flags, NULL, &error_code);
- if (error_code != base::PLATFORM_FILE_OK)
- return false;
-
- bool succeeded;
- succeeded = base::TruncatePlatformFile(file, file_size);
- succeeded = succeeded && base::ClosePlatformFile(file);
- return succeeded;
- }
-
- void CreateFiles(const TestFile* files, int num_files) {
- for (int i = 0; i < num_files; i++) {
- if (files[i].isDirectory) {
- ASSERT_EQ(true, CreateFileSystemDirectory(
- files[i].name, files[i].origin_url, files[i].type));
- } else {
- ASSERT_EQ(true, CreateFileSystemFile(
- files[i].name, files[i].size, files[i].origin_url, files[i].type));
- }
- }
- }
-
private:
void OnGetUsage(int64 usage) {
usage_ = usage;
@@ -141,139 +56,11 @@ class FileSystemUsageTrackerTest : public testing::Test {
DISALLOW_COPY_AND_ASSIGN(FileSystemUsageTrackerTest);
};
-TEST_F(FileSystemUsageTrackerTest, NoFileSystemTest) {
- scoped_ptr<FileSystemUsageTracker> tracker(NewUsageTracker(false));
-
- EXPECT_EQ(0,
- GetOriginUsage(tracker.get(), kDummyURL1, kTemporary));
-}
-
-TEST_F(FileSystemUsageTrackerTest, NoFileTest) {
- scoped_ptr<FileSystemUsageTracker> tracker(NewUsageTracker(false));
- TestFile files[] = {
- {true, NULL, 0, kDummyURL1, kTemporary},
- };
- CreateFiles(files, ARRAYSIZE_UNSAFE(files));
-
- for (int i = 0; i < 2; i++) {
- EXPECT_EQ(kUsageFileSize,
- GetOriginUsage(tracker.get(), kDummyURL1, kTemporary));
- }
-}
-
-TEST_F(FileSystemUsageTrackerTest, OneFileTest) {
+// TODO(dmikurube): change this test to a meaningful one once we add
+// the real code in the FileSystemUsageTracker.
+TEST_F(FileSystemUsageTrackerTest, DummyTest) {
scoped_ptr<FileSystemUsageTracker> tracker(NewUsageTracker(false));
- TestFile files[] = {
- {true, NULL, 0, kDummyURL1, kTemporary},
- {false, "foo", 4921, kDummyURL1, kTemporary},
- };
- CreateFiles(files, ARRAYSIZE_UNSAFE(files));
-
- for (int i = 0; i < 2; i++) {
- EXPECT_EQ(4921 + kUsageFileSize,
- GetOriginUsage(tracker.get(), kDummyURL1, kTemporary));
- }
-}
-
-TEST_F(FileSystemUsageTrackerTest, TwoFilesTest) {
- scoped_ptr<FileSystemUsageTracker> tracker(NewUsageTracker(false));
- TestFile files[] = {
- {true, NULL, 0, kDummyURL1, kTemporary},
- {false, "foo", 10310, kDummyURL1, kTemporary},
- {false, "bar", 41, kDummyURL1, kTemporary},
- };
- CreateFiles(files, ARRAYSIZE_UNSAFE(files));
-
- for (int i = 0; i < 2; i++) {
- EXPECT_EQ(10310 + 41 + kUsageFileSize,
- GetOriginUsage(tracker.get(), kDummyURL1, kTemporary));
- }
-}
-
-TEST_F(FileSystemUsageTrackerTest, EmptyFilesTest) {
- scoped_ptr<FileSystemUsageTracker> tracker(NewUsageTracker(false));
- TestFile files[] = {
- {true, NULL, 0, kDummyURL1, kTemporary},
- {false, "foo", 0, kDummyURL1, kTemporary},
- {false, "bar", 0, kDummyURL1, kTemporary},
- {false, "baz", 0, kDummyURL1, kTemporary},
- };
- CreateFiles(files, ARRAYSIZE_UNSAFE(files));
-
- for (int i = 0; i < 2; i++) {
- EXPECT_EQ(kUsageFileSize,
- GetOriginUsage(tracker.get(), kDummyURL1, kTemporary));
- }
-}
-
-TEST_F(FileSystemUsageTrackerTest, SubDirectoryTest) {
- scoped_ptr<FileSystemUsageTracker> tracker(NewUsageTracker(false));
- TestFile files[] = {
- {true, NULL, 0, kDummyURL1, kTemporary},
- {true, "dirtest", 0, kDummyURL1, kTemporary},
- {false, "dirtest/foo", 11921, kDummyURL1, kTemporary},
- {false, "bar", 4814, kDummyURL1, kTemporary},
- };
- CreateFiles(files, ARRAYSIZE_UNSAFE(files));
-
- for (int i = 0; i < 2; i++) {
- EXPECT_EQ(11921 + 4814 + kUsageFileSize,
- GetOriginUsage(tracker.get(), kDummyURL1, kTemporary));
- }
-}
-
-TEST_F(FileSystemUsageTrackerTest, MultiTypeTest) {
- scoped_ptr<FileSystemUsageTracker> tracker(NewUsageTracker(false));
- TestFile files[] = {
- {true, NULL, 0, kDummyURL1, kTemporary},
- {true, "dirtest", 0, kDummyURL1, kTemporary},
- {false, "dirtest/foo", 133, kDummyURL1, kTemporary},
- {false, "bar", 14, kDummyURL1, kTemporary},
- {true, NULL, 0, kDummyURL1, kPersistent},
- {true, "dirtest", 0, kDummyURL1, kPersistent},
- {false, "dirtest/foo", 193, kDummyURL1, kPersistent},
- {false, "bar", 9, kDummyURL1, kPersistent},
- };
- CreateFiles(files, ARRAYSIZE_UNSAFE(files));
-
- for (int i = 0; i < 2; i++) {
- EXPECT_EQ(133 + 14 + kUsageFileSize,
- GetOriginUsage(tracker.get(), kDummyURL1, kTemporary));
- EXPECT_EQ(193 + 9 + kUsageFileSize,
- GetOriginUsage(tracker.get(), kDummyURL1, kPersistent));
- }
-}
-
-TEST_F(FileSystemUsageTrackerTest, MultiDomainTest) {
- scoped_ptr<FileSystemUsageTracker> tracker(NewUsageTracker(false));
- TestFile files[] = {
- {true, NULL, 0, kDummyURL1, kTemporary},
- {true, "dir1", 0, kDummyURL1, kTemporary},
- {false, "dir1/foo", 1331, kDummyURL1, kTemporary},
- {false, "bar", 134, kDummyURL1, kTemporary},
- {true, NULL, 0, kDummyURL1, kPersistent},
- {true, "dir2", 0, kDummyURL1, kPersistent},
- {false, "dir2/foo", 1903, kDummyURL1, kPersistent},
- {false, "bar", 19, kDummyURL1, kPersistent},
- {true, NULL, 0, kDummyURL2, kTemporary},
- {true, "dom", 0, kDummyURL2, kTemporary},
- {false, "dom/fan", 1319, kDummyURL2, kTemporary},
- {false, "bar", 113, kDummyURL2, kTemporary},
- {true, NULL, 0, kDummyURL2, kPersistent},
- {true, "dom", 0, kDummyURL2, kPersistent},
- {false, "dom/fan", 2013, kDummyURL2, kPersistent},
- {false, "baz", 18, kDummyURL2, kPersistent},
- };
- CreateFiles(files, ARRAYSIZE_UNSAFE(files));
-
- for (int i = 0; i < 2; i++) {
- EXPECT_EQ(1331 + 134 + kUsageFileSize,
- GetOriginUsage(tracker.get(), kDummyURL1, kTemporary));
- EXPECT_EQ(1903 + 19 + kUsageFileSize,
- GetOriginUsage(tracker.get(), kDummyURL1, kPersistent));
- EXPECT_EQ(1319 + 113 + kUsageFileSize,
- GetOriginUsage(tracker.get(), kDummyURL2, kTemporary));
- EXPECT_EQ(2013 + 18 + kUsageFileSize,
- GetOriginUsage(tracker.get(), kDummyURL2, kPersistent));
- }
+ ASSERT_EQ(0, GetOriginUsage(tracker.get(),
+ GURL("http://www.dummy.org/"),
+ fileapi::kFileSystemTypeTemporary));
}
diff --git a/webkit/fileapi/webkit_fileapi.gypi b/webkit/fileapi/webkit_fileapi.gypi
index 53a7510..c082f2c 100644
--- a/webkit/fileapi/webkit_fileapi.gypi
+++ b/webkit/fileapi/webkit_fileapi.gypi
@@ -32,8 +32,6 @@
'file_system_usage_tracker.h',
'file_system_util.cc',
'file_system_util.h',
- 'file_system_usage_cache.h',
- 'file_system_usage_cache.cc',
'file_writer_delegate.cc',
'file_writer_delegate.h',
'webfilewriter_base.cc',
@@ -49,3 +47,4 @@
},
],
}
+