summaryrefslogtreecommitdiffstats
path: root/webkit/fileapi
diff options
context:
space:
mode:
authorericu@chromium.org <ericu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-10 23:31:01 +0000
committerericu@chromium.org <ericu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-10 23:31:01 +0000
commit9eaa331b9d4e9644eae6d2e1eafc5e990b51abaf (patch)
tree0b056cf494376309e23e5bfbde7e24be3ca7e85e /webkit/fileapi
parent4a5119069ccdb698b5d8f6fcd0988a6b1a0c66dd (diff)
downloadchromium_src-9eaa331b9d4e9644eae6d2e1eafc5e990b51abaf.zip
chromium_src-9eaa331b9d4e9644eae6d2e1eafc5e990b51abaf.tar.gz
chromium_src-9eaa331b9d4e9644eae6d2e1eafc5e990b51abaf.tar.bz2
Remove the old-sandbox-to-new-sandbox migration code. The only users of the old sandbox are those who used the filesystem in apps 1.5 years ago, and haven't loaded those apps since.
Review URL: https://chromiumcodereview.appspot.com/11419193 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@172182 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/fileapi')
-rw-r--r--webkit/fileapi/file_system_mount_point_provider_unittest.cc2
-rw-r--r--webkit/fileapi/obfuscated_file_util.cc74
-rw-r--r--webkit/fileapi/obfuscated_file_util.h13
-rw-r--r--webkit/fileapi/obfuscated_file_util_unittest.cc47
-rw-r--r--webkit/fileapi/sandbox_mount_point_provider.cc243
-rw-r--r--webkit/fileapi/sandbox_mount_point_provider.h14
-rw-r--r--webkit/fileapi/sandbox_mount_point_provider_unittest.cc259
7 files changed, 6 insertions, 646 deletions
diff --git a/webkit/fileapi/file_system_mount_point_provider_unittest.cc b/webkit/fileapi/file_system_mount_point_provider_unittest.cc
index a09f090..81c48eb 100644
--- a/webkit/fileapi/file_system_mount_point_provider_unittest.cc
+++ b/webkit/fileapi/file_system_mount_point_provider_unittest.cc
@@ -246,7 +246,7 @@ class FileSystemMountPointProviderTest : public testing::Test {
FilePath data_path() const { return data_dir_.path(); }
FilePath file_system_path() const {
return data_dir_.path().Append(
- SandboxMountPointProvider::kNewFileSystemDirectory);
+ SandboxMountPointProvider::kFileSystemDirectory);
}
FileSystemContext* file_system_context() const {
return file_system_context_.get();
diff --git a/webkit/fileapi/obfuscated_file_util.cc b/webkit/fileapi/obfuscated_file_util.cc
index 943c9c7..3144636 100644
--- a/webkit/fileapi/obfuscated_file_util.cc
+++ b/webkit/fileapi/obfuscated_file_util.cc
@@ -92,8 +92,6 @@ void TouchDirectory(FileSystemDirectoryDatabase* db, FileId dir_id) {
NOTREACHED();
}
-const FilePath::CharType kLegacyDataDirectory[] = FILE_PATH_LITERAL("Legacy");
-
const FilePath::CharType kTemporaryDirectoryName[] = FILE_PATH_LITERAL("t");
const FilePath::CharType kPersistentDirectoryName[] = FILE_PATH_LITERAL("p");
const FilePath::CharType kSyncableDirectoryName[] = FILE_PATH_LITERAL("s");
@@ -990,78 +988,6 @@ bool ObfuscatedFileUtil::DeleteDirectoryForOriginAndType(
return true;
}
-bool ObfuscatedFileUtil::MigrateFromOldSandbox(
- const GURL& origin_url, FileSystemType type, const FilePath& src_root) {
- if (!DestroyDirectoryDatabase(origin_url, type))
- return false;
- base::PlatformFileError error = base::PLATFORM_FILE_OK;
- FilePath dest_root = GetDirectoryForOriginAndType(origin_url, type, true,
- &error);
- if (error != base::PLATFORM_FILE_OK)
- return false;
- FileSystemDirectoryDatabase* db = GetDirectoryDatabase(
- origin_url, type, true);
- if (!db)
- return false;
-
- file_util::FileEnumerator file_enum(src_root, true,
- file_util::FileEnumerator::FILES |
- file_util::FileEnumerator::DIRECTORIES);
- FilePath src_full_path;
- size_t root_path_length = src_root.value().length() + 1; // +1 for the slash
- while (!(src_full_path = file_enum.Next()).empty()) {
- file_util::FileEnumerator::FindInfo info;
- file_enum.GetFindInfo(&info);
- FilePath relative_virtual_path =
- FilePath(src_full_path.value().substr(root_path_length));
- if (relative_virtual_path.empty()) {
- LOG(WARNING) << "Failed to convert path to relative: " <<
- src_full_path.value();
- return false;
- }
- FileId file_id;
- if (db->GetFileWithPath(relative_virtual_path, &file_id)) {
- NOTREACHED(); // File already exists.
- return false;
- }
- if (!db->GetFileWithPath(relative_virtual_path.DirName(), &file_id)) {
- NOTREACHED(); // Parent doesn't exist.
- return false;
- }
-
- FileInfo file_info;
- file_info.name = VirtualPath::BaseName(src_full_path).value();
- if (file_util::FileEnumerator::IsDirectory(info)) {
-#if defined(OS_WIN)
- file_info.modification_time =
- base::Time::FromFileTime(info.ftLastWriteTime);
-#elif defined(OS_POSIX)
- file_info.modification_time = base::Time::FromTimeT(info.stat.st_mtime);
-#endif
- } else {
- file_info.data_path =
- FilePath(kLegacyDataDirectory).Append(relative_virtual_path);
- }
- file_info.parent_id = file_id;
- if (!db->AddFileInfo(file_info, &file_id)) {
- NOTREACHED();
- return false;
- }
- }
- // TODO(ericu): Should we adjust the mtime of the root directory to match as
- // well?
- FilePath legacy_dest_dir = dest_root.Append(kLegacyDataDirectory);
-
- if (!file_util::Move(src_root, legacy_dest_dir)) {
- LOG(WARNING) <<
- "The final step of a migration failed; I'll try to clean up.";
- db = NULL;
- DestroyDirectoryDatabase(origin_url, type);
- return false;
- }
- return true;
-}
-
// static
FilePath::StringType ObfuscatedFileUtil::GetDirectoryNameForType(
FileSystemType type) {
diff --git a/webkit/fileapi/obfuscated_file_util.h b/webkit/fileapi/obfuscated_file_util.h
index e739076..80a1234 100644
--- a/webkit/fileapi/obfuscated_file_util.h
+++ b/webkit/fileapi/obfuscated_file_util.h
@@ -143,19 +143,6 @@ class WEBKIT_STORAGE_EXPORT_PRIVATE ObfuscatedFileUtil
// delete its directory database.
bool DeleteDirectoryForOriginAndType(const GURL& origin, FileSystemType type);
- // This will migrate a filesystem from the old passthrough sandbox into the
- // new obfuscated one. It won't obfuscate the old filenames [it will maintain
- // the old structure, but move it to a new root], but any new files created
- // will go into the new standard locations. This will be completely
- // transparent to the user. This migration is atomic in that it won't alter
- // the source data until it's done, and that will be with a single directory
- // move [the directory with the unguessable name will move into the new
- // filesystem storage directory]. However, if this fails partway through, it
- // might leave a seemingly-valid database for this origin. When it starts up,
- // it will clear any such database, just in case.
- bool MigrateFromOldSandbox(
- const GURL& origin, FileSystemType type, const FilePath& root);
-
// TODO(ericu): This doesn't really feel like it belongs in this class.
// The previous version lives in FileSystemPathManager, but perhaps
// SandboxMountPointProvider would be better?
diff --git a/webkit/fileapi/obfuscated_file_util_unittest.cc b/webkit/fileapi/obfuscated_file_util_unittest.cc
index afb5efd..0e5d1b7 100644
--- a/webkit/fileapi/obfuscated_file_util_unittest.cc
+++ b/webkit/fileapi/obfuscated_file_util_unittest.cc
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <algorithm>
#include <set>
#include <string>
@@ -13,7 +12,6 @@
#include "base/memory/scoped_ptr.h"
#include "base/message_loop.h"
#include "base/platform_file.h"
-#include "base/sys_string_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "webkit/fileapi/file_system_context.h"
#include "webkit/fileapi/file_system_operation_context.h"
@@ -1411,49 +1409,6 @@ TEST_F(ObfuscatedFileUtilTest, TestEnumerator) {
EXPECT_FALSE(DirectoryExists(dest_url));
}
-TEST_F(ObfuscatedFileUtilTest, TestMigration) {
- base::ScopedTempDir source_dir;
- ASSERT_TRUE(source_dir.CreateUniqueTempDir());
- FilePath root_path = source_dir.path().AppendASCII("chrome-pLmnMWXE7NzTFRsn");
- ASSERT_TRUE(file_util::CreateDirectory(root_path));
-
- test::SetUpRegularTestCases(root_path);
-
- EXPECT_TRUE(ofu()->MigrateFromOldSandbox(origin(), type(), root_path));
-
- FilePath new_root =
- test_directory().AppendASCII("File System").AppendASCII("000").Append(
- ofu()->GetDirectoryNameForType(type())).AppendASCII("Legacy");
- for (size_t i = 0; i < test::kRegularTestCaseSize; ++i) {
- SCOPED_TRACE(testing::Message() << "Validating kMigrationTestPath " << i);
- const test::TestCaseRecord& test_case = test::kRegularTestCases[i];
- FilePath local_data_path = new_root.Append(test_case.path);
- local_data_path = local_data_path.NormalizePathSeparators();
- scoped_ptr<FileSystemOperationContext> context(NewContext(NULL));
- base::PlatformFileInfo ofu_file_info;
- FilePath data_path;
- SCOPED_TRACE(testing::Message() << "Path is " << test_case.path);
- EXPECT_EQ(base::PLATFORM_FILE_OK,
- ofu()->GetFileInfo(context.get(), CreateURL(FilePath(test_case.path)),
- &ofu_file_info, &data_path));
- if (test_case.is_directory) {
- EXPECT_TRUE(ofu_file_info.is_directory);
- } else {
- base::PlatformFileInfo platform_file_info;
- SCOPED_TRACE(testing::Message() << "local_data_path is " <<
- local_data_path.value());
- SCOPED_TRACE(testing::Message() << "data_path is " << data_path.value());
- ASSERT_TRUE(file_util::GetFileInfo(local_data_path, &platform_file_info));
- EXPECT_EQ(test_case.data_file_size, platform_file_info.size);
- EXPECT_FALSE(platform_file_info.is_directory);
- scoped_ptr<FileSystemOperationContext> context(NewContext(NULL));
- EXPECT_EQ(local_data_path, data_path);
- EXPECT_EQ(platform_file_info.size, ofu_file_info.size);
- EXPECT_FALSE(ofu_file_info.is_directory);
- }
- }
-}
-
TEST_F(ObfuscatedFileUtilTest, TestOriginEnumerator) {
scoped_ptr<ObfuscatedFileUtil::AbstractOriginEnumerator>
enumerator(ofu()->CreateOriginEnumerator());
@@ -1546,7 +1501,7 @@ TEST_F(ObfuscatedFileUtilTest, TestRevokeUsageCache) {
int64 expected_quota = 0;
for (size_t i = 0; i < test::kRegularTestCaseSize; ++i) {
- SCOPED_TRACE(testing::Message() << "Creating kMigrationTestPath " << i);
+ SCOPED_TRACE(testing::Message() << "Creating kRegularTestCase " << i);
const test::TestCaseRecord& test_case = test::kRegularTestCases[i];
FilePath file_path(test_case.path);
expected_quota += ObfuscatedFileUtil::ComputeFilePathCost(file_path);
diff --git a/webkit/fileapi/sandbox_mount_point_provider.cc b/webkit/fileapi/sandbox_mount_point_provider.cc
index eb5b752..5d38081 100644
--- a/webkit/fileapi/sandbox_mount_point_provider.cc
+++ b/webkit/fileapi/sandbox_mount_point_provider.cc
@@ -9,10 +9,6 @@
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/metrics/histogram.h"
-#include "base/rand_util.h"
-#include "base/single_thread_task_runner.h"
-#include "base/string_util.h"
-#include "base/stringprintf.h"
#include "base/task_runner_util.h"
#include "googleurl/src/gurl.h"
#include "net/base/net_util.h"
@@ -25,12 +21,10 @@
#include "webkit/fileapi/file_system_usage_cache.h"
#include "webkit/fileapi/file_system_util.h"
#include "webkit/fileapi/local_file_system_operation.h"
-#include "webkit/fileapi/native_file_util.h"
#include "webkit/fileapi/obfuscated_file_util.h"
#include "webkit/fileapi/sandbox_file_stream_writer.h"
#include "webkit/fileapi/sandbox_quota_observer.h"
#include "webkit/fileapi/syncable/syncable_file_system_operation.h"
-#include "webkit/glue/webkit_glue.h"
#include "webkit/quota/quota_manager.h"
using quota::QuotaManagerProxy;
@@ -42,12 +36,6 @@ namespace {
const char kChromeScheme[] = "chrome";
const char kExtensionScheme[] = "chrome-extension";
-const FilePath::CharType kOldFileSystemUniqueNamePrefix[] =
- FILE_PATH_LITERAL("chrome-");
-const size_t kOldFileSystemUniqueLength = 16;
-const size_t kOldFileSystemUniqueDirectoryNameLength =
- kOldFileSystemUniqueLength + arraysize(kOldFileSystemUniqueNamePrefix) - 1;
-
const char kOpenFileSystemLabel[] = "FileSystem.OpenFileSystem";
const char kOpenFileSystemDetailLabel[] = "FileSystem.OpenFileSystemDetail";
const char kOpenFileSystemDetailNonThrottledLabel[] =
@@ -83,42 +71,6 @@ const FilePath::CharType kRestrictedChars[] = {
FILE_PATH_LITERAL('/'), FILE_PATH_LITERAL('\\'),
};
-FilePath::StringType OldCreateUniqueDirectoryName(const GURL& origin_url) {
- // This can be anything but need to be unpredictable.
- static const FilePath::CharType letters[] = FILE_PATH_LITERAL(
- "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
- FilePath::StringType unique(kOldFileSystemUniqueNamePrefix);
- for (size_t i = 0; i < kOldFileSystemUniqueLength; ++i)
- unique += letters[base::RandInt(0, arraysize(letters) - 2)];
- return unique;
-}
-
-base::PlatformFileError OldReadOriginDirectory(const FilePath& base_path,
- FilePath* unique) {
- file_util::FileEnumerator file_enum(
- base_path, false /* recursive */,
- file_util::FileEnumerator::DIRECTORIES,
- FilePath::StringType(kOldFileSystemUniqueNamePrefix) +
- FILE_PATH_LITERAL("*"));
- FilePath current;
- bool found = false;
- while (!(current = file_enum.Next()).empty()) {
- if (current.BaseName().value().length() !=
- kOldFileSystemUniqueDirectoryNameLength)
- continue;
- if (found) {
- LOG(WARNING) << "Unexpectedly found more than one FileSystem "
- << "directory";
- return base::PLATFORM_FILE_ERROR_FAILED;
- }
- found = true;
- *unique = current;
- }
- if (unique->empty())
- return base::PLATFORM_FILE_ERROR_NOT_FOUND;
- return base::PLATFORM_FILE_OK;
-}
-
class ObfuscatedOriginEnumerator
: public SandboxMountPointProvider::OriginEnumerator {
public:
@@ -139,145 +91,6 @@ class ObfuscatedOriginEnumerator
scoped_ptr<ObfuscatedFileUtil::AbstractOriginEnumerator> enum_;
};
-class OldSandboxOriginEnumerator
- : public SandboxMountPointProvider::OriginEnumerator {
- public:
- explicit OldSandboxOriginEnumerator(const FilePath& base_path)
- : enumerator_(base_path, false /* recursive */,
- file_util::FileEnumerator::DIRECTORIES) {}
- virtual ~OldSandboxOriginEnumerator() {}
-
- virtual GURL Next() OVERRIDE {
- current_ = enumerator_.Next();
- if (current_.empty())
- return GURL();
- return GetOriginURLFromIdentifier(current_.BaseName().MaybeAsASCII());
- }
-
- virtual bool HasFileSystemType(fileapi::FileSystemType type) const OVERRIDE {
- if (current_.empty())
- return false;
- std::string directory = GetFileSystemTypeString(type);
- DCHECK(!directory.empty());
- return file_util::DirectoryExists(current_.AppendASCII(directory));
- }
-
- private:
- file_util::FileEnumerator enumerator_;
- FilePath current_;
-};
-
-FilePath OldGetBaseDirectoryForOrigin(
- const FilePath& old_base_path,
- const GURL& origin_url) {
- std::string id = GetOriginIdentifierFromURL(origin_url);
- if (!id.empty())
- return old_base_path.AppendASCII(id);
- return FilePath();
-}
-
-FilePath OldGetBaseDirectoryForOriginAndType(
- const FilePath& old_base_path,
- const GURL& origin_url, fileapi::FileSystemType type) {
- std::string type_string = GetFileSystemTypeString(type);
- if (type_string.empty()) {
- NOTREACHED();
- return FilePath();
- }
- FilePath base_path = OldGetBaseDirectoryForOrigin(
- old_base_path, origin_url);
- if (base_path.empty()) {
- NOTREACHED();
- return FilePath();
- }
- return base_path.AppendASCII(type_string);
-}
-
-bool MigrateOneOldFileSystem(
- ObfuscatedFileUtil* file_util,
- const FilePath& old_base_path, const GURL& origin,
- fileapi::FileSystemType type) {
- FilePath base_path = OldGetBaseDirectoryForOriginAndType(
- old_base_path, origin, type);
- if (base_path.empty())
- return false;
-
- FilePath root;
- base::PlatformFileError result = OldReadOriginDirectory(base_path, &root);
- if (base::PLATFORM_FILE_ERROR_NOT_FOUND == result)
- return true; // There was nothing to migrate; call that a success.
-
- // If we found more than one filesystem [a problem we don't know how to
- // solve], the data is already not accessible through Chrome, so it won't do
- // any harm not to migrate it. Just flag it as an error, so that we don't
- // delete it.
- if (base::PLATFORM_FILE_OK != result)
- return false;
-
- if (!file_util->MigrateFromOldSandbox(origin, type, root)) {
- LOG(WARNING) << "Failed to migrate filesystem for origin " << origin <<
- " and type " << type;
- return false;
- }
- return true;
-}
-
-void MigrateAllOldFileSystems(
- ObfuscatedFileUtil* file_util,
- const FilePath& old_base_path) {
- scoped_ptr<OldSandboxOriginEnumerator> old_origins(
- new OldSandboxOriginEnumerator(old_base_path));
- GURL origin;
- int failures = 0;
- while (!(origin = old_origins->Next()).is_empty()) {
- int failures_this_origin = 0;
- if (old_origins->HasFileSystemType(kFileSystemTypeTemporary) &&
- !MigrateOneOldFileSystem(
- file_util, old_base_path, origin,
- kFileSystemTypeTemporary))
- ++failures_this_origin;
- if (old_origins->HasFileSystemType(kFileSystemTypePersistent) &&
- !MigrateOneOldFileSystem(
- file_util, old_base_path, origin,
- kFileSystemTypePersistent))
- ++failures_this_origin;
- if (!failures_this_origin) {
- FilePath origin_base_path =
- OldGetBaseDirectoryForOrigin(old_base_path, origin);
- // Yes, that's an rm -rf. Make sure that path looks valid, just in case.
- if (!origin_base_path.empty())
- file_util::Delete(origin_base_path, true);
- }
- failures += failures_this_origin;
- }
- if (!failures)
- file_util::Delete(old_base_path, true);
- if (file_util::DirectoryExists(old_base_path)) {
- // Move it out of the way so that we won't keep trying to migrate it. You
- // get only one chance at this; the bits we couldn't do this time, we're
- // unlikely to be able to do in the future. This way you can now use the
- // new filesystem, but have a way to recover your old files if absolutely
- // necessary.
- FilePath new_path =
- old_base_path.DirName().Append(
- SandboxMountPointProvider::kRenamedOldFileSystemDirectory);
- file_util::ReplaceFile(old_base_path, new_path);
- }
-}
-
-// A migration, whether successful or not, will try to move this directory out
-// of the way so that we never try to migrate it again. We need to do this
-// check on all public entry points in this file, so that it's guaranteed to be
-// done before anyone looks up a filesystem. Most entry points start by trying
-// to look up the filesystem's root, so we can take care of most of them by
-// putting a check there.
-void MigrateIfNeeded(
- ObfuscatedFileUtil* file_util,
- const FilePath& old_base_path) {
- if (file_util::DirectoryExists(old_base_path))
- MigrateAllOldFileSystems(file_util, old_base_path);
-}
-
void DidValidateFileSystemRoot(
base::WeakPtr<SandboxMountPointProvider> mount_point_provider,
const FileSystemMountPointProvider::ValidateFileSystemCallback& callback,
@@ -291,11 +104,9 @@ void ValidateRootOnFileThread(
ObfuscatedFileUtil* file_util,
const GURL& origin_url,
FileSystemType type,
- const FilePath& old_base_path,
bool create,
base::PlatformFileError* error_ptr) {
DCHECK(error_ptr);
- MigrateIfNeeded(file_util, old_base_path);
FilePath root_path =
file_util->GetDirectoryForOriginAndType(
@@ -314,16 +125,9 @@ void ValidateRootOnFileThread(
} // anonymous namespace
-const FilePath::CharType SandboxMountPointProvider::kOldFileSystemDirectory[] =
- FILE_PATH_LITERAL("FileSystem");
-
-const FilePath::CharType SandboxMountPointProvider::kNewFileSystemDirectory[] =
+const FilePath::CharType SandboxMountPointProvider::kFileSystemDirectory[] =
FILE_PATH_LITERAL("File System");
-const FilePath::CharType
- SandboxMountPointProvider::kRenamedOldFileSystemDirectory[] =
- FILE_PATH_LITERAL("FS.old");
-
// static
bool SandboxMountPointProvider::CanHandleType(FileSystemType type) {
return type == kFileSystemTypeTemporary ||
@@ -340,7 +144,7 @@ SandboxMountPointProvider::SandboxMountPointProvider(
profile_path_(profile_path),
file_system_options_(file_system_options),
sandbox_file_util_(new ObfuscatedFileUtil(
- profile_path.Append(kNewFileSystemDirectory))),
+ profile_path.Append(kFileSystemDirectory))),
quota_observer_(new SandboxQuotaObserver(
quota_manager_proxy,
file_task_runner,
@@ -397,7 +201,7 @@ void SandboxMountPointProvider::ValidateFileSystemRoot(
FROM_HERE,
base::Bind(&ValidateRootOnFileThread,
sandbox_file_util_.get(),
- origin_url, type, old_base_path(), create,
+ origin_url, type, create,
base::Unretained(error_ptr)),
base::Bind(&DidValidateFileSystemRoot,
weak_factory_.GetWeakPtr(),
@@ -521,29 +325,14 @@ void SandboxMountPointProvider::DeleteFileSystem(
callback);
}
-FilePath SandboxMountPointProvider::old_base_path() const {
- return profile_path_.Append(kOldFileSystemDirectory);
-}
-
-FilePath SandboxMountPointProvider::new_base_path() const {
- return profile_path_.Append(kNewFileSystemDirectory);
-}
-
-FilePath SandboxMountPointProvider::renamed_old_base_path() const {
- return profile_path_.Append(kRenamedOldFileSystemDirectory);
-}
-
SandboxMountPointProvider::OriginEnumerator*
SandboxMountPointProvider::CreateOriginEnumerator() const {
- MigrateIfNeeded(sandbox_file_util_.get(), old_base_path());
return new ObfuscatedOriginEnumerator(sandbox_file_util_.get());
}
FilePath SandboxMountPointProvider::GetBaseDirectoryForOriginAndType(
const GURL& origin_url, fileapi::FileSystemType type, bool create) const {
- MigrateIfNeeded(sandbox_file_util_.get(), old_base_path());
-
base::PlatformFileError error = base::PLATFORM_FILE_OK;
FilePath path = sandbox_file_util_->GetDirectoryForOriginAndType(
origin_url, type, create, &error);
@@ -558,7 +347,6 @@ SandboxMountPointProvider::DeleteOriginDataOnFileThread(
QuotaManagerProxy* proxy,
const GURL& origin_url,
fileapi::FileSystemType type) {
- MigrateIfNeeded(sandbox_file_util_.get(), old_base_path());
int64 usage = GetOriginUsageOnFileThread(file_system_context,
origin_url, type);
@@ -768,31 +556,6 @@ FilePath SandboxMountPointProvider::GetUsageCachePathForOriginAndType(
return base_path.Append(FileSystemUsageCache::kUsageFileName);
}
-FilePath SandboxMountPointProvider::OldCreateFileSystemRootPath(
- const GURL& origin_url, fileapi::FileSystemType type) {
- FilePath origin_base_path =
- OldGetBaseDirectoryForOriginAndType(old_base_path(), origin_url, type);
- DCHECK(!origin_base_path.empty());
-
- FilePath root;
- base::PlatformFileError result =
- OldReadOriginDirectory(origin_base_path, &root);
- if (base::PLATFORM_FILE_OK == result)
- return root;
-
- // We found more than on filesystem there already--we don't know how to
- // recover from this.
- if (base::PLATFORM_FILE_ERROR_NOT_FOUND != result)
- return FilePath();
-
- // Creates the root directory.
- root = origin_base_path.Append(OldCreateUniqueDirectoryName(origin_url));
- if (!file_util::CreateDirectory(root))
- return FilePath();
-
- return root;
-}
-
bool SandboxMountPointProvider::IsAllowedScheme(const GURL& url) const {
// Basically we only accept http or https. We allow file:// URLs
// only if --allow-file-access-from-files flag is given.
diff --git a/webkit/fileapi/sandbox_mount_point_provider.h b/webkit/fileapi/sandbox_mount_point_provider.h
index 5d4b637..7b0eb51 100644
--- a/webkit/fileapi/sandbox_mount_point_provider.h
+++ b/webkit/fileapi/sandbox_mount_point_provider.h
@@ -60,13 +60,8 @@ class WEBKIT_STORAGE_EXPORT SandboxMountPointProvider
virtual bool HasFileSystemType(FileSystemType type) const = 0;
};
- // The legacy [pre-obfuscation] FileSystem directory name, kept around for
- // migration and migration testing.
- static const FilePath::CharType kOldFileSystemDirectory[];
// The FileSystem directory name.
- static const FilePath::CharType kNewFileSystemDirectory[];
- // Where we move the old filesystem directory if migration fails.
- static const FilePath::CharType kRenamedOldFileSystemDirectory[];
+ static const FilePath::CharType kFileSystemDirectory[];
static bool CanHandleType(FileSystemType type);
@@ -115,10 +110,6 @@ class WEBKIT_STORAGE_EXPORT SandboxMountPointProvider
FileSystemContext* context,
const DeleteFileSystemCallback& callback) OVERRIDE;
- FilePath old_base_path() const;
- FilePath new_base_path() const;
- FilePath renamed_old_base_path() const;
-
// Returns an origin enumerator of this provider.
// This method can only be called on the file thread.
OriginEnumerator* CreateOriginEnumerator() const;
@@ -196,9 +187,6 @@ class WEBKIT_STORAGE_EXPORT SandboxMountPointProvider
FileSystemType type,
base::PlatformFileError* error_out);
- FilePath OldCreateFileSystemRootPath(
- const GURL& origin_url, FileSystemType type);
-
// Returns true if the given |url|'s scheme is allowed to access
// filesystem.
bool IsAllowedScheme(const GURL& url) const;
diff --git a/webkit/fileapi/sandbox_mount_point_provider_unittest.cc b/webkit/fileapi/sandbox_mount_point_provider_unittest.cc
index 2e4f209..875ab76 100644
--- a/webkit/fileapi/sandbox_mount_point_provider_unittest.cc
+++ b/webkit/fileapi/sandbox_mount_point_provider_unittest.cc
@@ -5,32 +5,18 @@
#include "webkit/fileapi/sandbox_mount_point_provider.h"
#include <set>
-#include <string>
#include "base/basictypes.h"
-#include "base/bind.h"
#include "base/file_util.h"
#include "base/files/scoped_temp_dir.h"
-#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
-#include "base/memory/weak_ptr.h"
#include "base/message_loop.h"
#include "base/message_loop_proxy.h"
-#include "base/platform_file.h"
#include "googleurl/src/gurl.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/fileapi/file_system_context.h"
#include "webkit/fileapi/file_system_mount_point_provider.h"
-#include "webkit/fileapi/file_system_operation_context.h"
-#include "webkit/fileapi/file_system_task_runners.h"
-#include "webkit/fileapi/file_system_url.h"
#include "webkit/fileapi/file_system_util.h"
-#include "webkit/fileapi/file_util_helper.h"
#include "webkit/fileapi/mock_file_system_options.h"
-#include "webkit/quota/mock_special_storage_policy.h"
-
-using base::PlatformFile;
-using base::PlatformFileError;
namespace fileapi {
@@ -118,249 +104,4 @@ TEST_F(SandboxMountPointProviderOriginEnumeratorTest, EnumerateOrigins) {
EXPECT_EQ(persistent_size, persistent_actual_size);
}
-namespace {
-
-struct MigrationTestCaseRecord {
- GURL origin;
- bool has_temporary;
- bool has_persistent;
-};
-
-const MigrationTestCaseRecord kMigrationTestRecords[] = {
- { GURL("http://www.example.com"), true, false },
- { GURL("http://example.com"), false, true },
- { GURL("http://www.google.com"), false, true },
- { GURL("http://www.another.origin.com"), true, true },
- { GURL("http://www.yet.another.origin.com"), true, true },
- { GURL("file:///"), false, true },
-};
-
-} // anonymous namespace
-
-class SandboxMountPointProviderMigrationTest : public testing::Test {
- public:
- SandboxMountPointProviderMigrationTest() :
- ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
- }
-
- void SetUp() {
- ASSERT_TRUE(data_dir_.CreateUniqueTempDir());
- scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy =
- new quota::MockSpecialStoragePolicy;
- special_storage_policy->SetAllUnlimited(true);
- file_system_context_ = new FileSystemContext(
- FileSystemTaskRunners::CreateMockTaskRunners(),
- special_storage_policy,
- NULL,
- data_dir_.path(),
- CreateAllowFileAccessOptions());
- }
-
- SandboxMountPointProvider* sandbox_provider() {
- return file_system_context_->sandbox_provider();
- }
-
- FileSystemFileUtil* file_util() {
- return sandbox_provider()->GetFileUtil(kFileSystemTypeTemporary);
- }
-
- void OnValidate(PlatformFileError result) {
- EXPECT_NE(base::PLATFORM_FILE_OK, result); // We told it not to create.
- }
-
- FileSystemMountPointProvider::ValidateFileSystemCallback
- GetValidateCallback() {
- return base::Bind(&SandboxMountPointProviderMigrationTest::OnValidate,
- weak_factory_.GetWeakPtr());
- }
-
- void EnsureFileExists(const FilePath& path) {
- bool created = false;
- PlatformFileError error_code = base::PLATFORM_FILE_OK;
- PlatformFile handle = base::CreatePlatformFile(
- path,
- base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_READ,
- &created, &error_code);
- ASSERT_EQ(base::PLATFORM_FILE_OK, error_code);
- ASSERT_TRUE(created);
- ASSERT_NE(base::kInvalidPlatformFileValue, handle);
- base::ClosePlatformFile(handle);
- }
-
- void CreateDataInDir(const FilePath& root, const std::string& seed) {
- ASSERT_TRUE(file_util::CreateDirectory(
- root.AppendASCII(seed)));
- ASSERT_TRUE(file_util::CreateDirectory(
- root.AppendASCII(seed).AppendASCII(seed)));
- ASSERT_TRUE(file_util::CreateDirectory(
- root.AppendASCII(seed).AppendASCII("d 0")));
- ASSERT_TRUE(file_util::CreateDirectory(
- root.AppendASCII(seed).AppendASCII("d 1")));
- EnsureFileExists(root.AppendASCII("file 0"));
- EnsureFileExists(
- root.AppendASCII(seed).AppendASCII("d 0").AppendASCII("file 1"));
- EnsureFileExists(
- root.AppendASCII(seed).AppendASCII("d 0").AppendASCII("file 2"));
- }
-
- FileSystemOperationContext* NewContext() {
- return new FileSystemOperationContext(file_system_context_);
- }
-
- bool PathExists(const FileSystemURL& url) {
- scoped_ptr<FileSystemOperationContext> context(NewContext());
- return FileUtilHelper::PathExists(context.get(), file_util(), url);
- }
-
- bool DirectoryExists(const FileSystemURL& url) {
- scoped_ptr<FileSystemOperationContext> context(NewContext());
- return FileUtilHelper::DirectoryExists(context.get(), file_util(), url);
- }
-
- std::string URLAndTypeToSeedString(const GURL& origin_url,
- fileapi::FileSystemType type) {
- return GetOriginIdentifierFromURL(origin_url) +
- GetFileSystemTypeString(type);
- }
-
- void ValidateDataInNewFileSystem(
- const GURL& origin_url, fileapi::FileSystemType type) {
- scoped_ptr<FileSystemOperationContext> context;
- FilePath seed_file_path = FilePath().AppendASCII(
- URLAndTypeToSeedString(origin_url, type));
-
- FileSystemURL root(origin_url, type, FilePath());
- FileSystemURL seed = root.WithPath(root.path().Append(seed_file_path));
-
- EXPECT_TRUE(DirectoryExists(seed));
- EXPECT_TRUE(DirectoryExists(
- seed.WithPath(seed.path().Append(seed_file_path))));
- EXPECT_TRUE(DirectoryExists(
- seed.WithPath(seed.path().AppendASCII("d 0"))));
- EXPECT_TRUE(DirectoryExists(
- seed.WithPath(seed.path().AppendASCII("d 1"))));
- EXPECT_TRUE(PathExists(
- root.WithPath(root.path().AppendASCII("file 0"))));
- EXPECT_FALSE(DirectoryExists(
- seed.WithPath(seed.path().AppendASCII("file 0"))));
- EXPECT_TRUE(PathExists(
- seed.WithPath(seed.path().AppendASCII("d 0").AppendASCII("file 1"))));
- EXPECT_FALSE(DirectoryExists(
- seed.WithPath(seed.path().AppendASCII("d 0").AppendASCII("file 1"))));
- EXPECT_TRUE(PathExists(
- seed.WithPath(seed.path().AppendASCII("d 0").AppendASCII("file 2"))));
- EXPECT_FALSE(DirectoryExists(
- seed.WithPath(seed.path().AppendASCII("d 0").AppendASCII("file 2"))));
- }
-
- void RunMigrationTest(int method) {
- for (size_t i = 0; i < arraysize(kMigrationTestRecords); ++i) {
- const MigrationTestCaseRecord& test_case = kMigrationTestRecords[i];
- const GURL& origin_url = test_case.origin;
- ASSERT_TRUE(test_case.has_temporary || test_case.has_persistent);
- if (test_case.has_temporary) {
- FilePath root = sandbox_provider()->OldCreateFileSystemRootPath(
- origin_url, kFileSystemTypeTemporary);
- ASSERT_FALSE(root.empty());
- CreateDataInDir(root, URLAndTypeToSeedString(origin_url,
- kFileSystemTypeTemporary));
- }
- if (test_case.has_persistent) {
- FilePath root = sandbox_provider()->OldCreateFileSystemRootPath(
- origin_url, kFileSystemTypePersistent);
- ASSERT_FALSE(root.empty());
- CreateDataInDir(root, URLAndTypeToSeedString(origin_url,
- kFileSystemTypePersistent));
- }
- }
-
- const GURL origin_url("http://not.in.the.test.cases");
- fileapi::FileSystemType type = kFileSystemTypeTemporary;
- bool create = false;
- std::set<GURL> origins;
- std::string host = "the host with the most";
-
- // We want to make sure that all the public methods of
- // SandboxMountPointProvider which might access the filesystem will cause a
- // migration if one is needed.
- switch (method) {
- case 0:
- sandbox_provider()->ValidateFileSystemRoot(
- origin_url, type, create, GetValidateCallback());
- MessageLoop::current()->RunAllPending();
- break;
- case 1:
- sandbox_provider()->GetFileSystemRootPathOnFileThread(
- origin_url, type, FilePath(), create);
- break;
- case 2:
- sandbox_provider()->GetBaseDirectoryForOriginAndType(
- origin_url, type, create);
- break;
- case 3:
- sandbox_provider()->DeleteOriginDataOnFileThread(
- file_system_context_, NULL, origin_url, type);
- break;
- case 4:
- sandbox_provider()->GetOriginsForTypeOnFileThread(
- type, &origins);
- break;
- case 5:
- sandbox_provider()->GetOriginsForHostOnFileThread(
- type, host, &origins);
- break;
- case 6:
- sandbox_provider()->GetOriginUsageOnFileThread(
- file_system_context_, origin_url, type);
- break;
- default:
- FAIL();
- break;
- }
- for (size_t i = 0; i < arraysize(kMigrationTestRecords); ++i) {
- const MigrationTestCaseRecord& test_case = kMigrationTestRecords[i];
- const GURL& origin_url = test_case.origin;
- ASSERT_TRUE(test_case.has_temporary || test_case.has_persistent);
- if (test_case.has_temporary)
- ValidateDataInNewFileSystem(origin_url, kFileSystemTypeTemporary);
- if (test_case.has_persistent)
- ValidateDataInNewFileSystem(origin_url, kFileSystemTypePersistent);
- }
- }
-
- protected:
- base::ScopedTempDir data_dir_;
- MessageLoop message_loop_;
- scoped_refptr<FileSystemContext> file_system_context_;
- base::WeakPtrFactory<SandboxMountPointProviderMigrationTest> weak_factory_;
-};
-
-TEST_F(SandboxMountPointProviderMigrationTest, TestMigrateViaMethod0) {
- RunMigrationTest(0);
-}
-
-TEST_F(SandboxMountPointProviderMigrationTest, TestMigrateViaMethod1) {
- RunMigrationTest(1);
-}
-
-TEST_F(SandboxMountPointProviderMigrationTest, TestMigrateViaMethod2) {
- RunMigrationTest(2);
-}
-
-TEST_F(SandboxMountPointProviderMigrationTest, TestMigrateViaMethod3) {
- RunMigrationTest(3);
-}
-
-TEST_F(SandboxMountPointProviderMigrationTest, TestMigrateViaMethod4) {
- RunMigrationTest(4);
-}
-
-TEST_F(SandboxMountPointProviderMigrationTest, TestMigrateViaMethod5) {
- RunMigrationTest(5);
-}
-
-TEST_F(SandboxMountPointProviderMigrationTest, TestMigrateViaMethod6) {
- RunMigrationTest(6);
-}
-
} // namespace fileapi