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

Unified Diff: webkit/fileapi/sandbox_database_test_helper.cc

Issue 15442002: Move FileAPI sandboxed filesystem related code from webkit/fileapi to webkit/browser/fileapi (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 7 years, 7 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
« no previous file with comments | « webkit/fileapi/sandbox_database_test_helper.h ('k') | webkit/fileapi/sandbox_directory_database.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/fileapi/sandbox_database_test_helper.cc
diff --git a/webkit/fileapi/sandbox_database_test_helper.cc b/webkit/fileapi/sandbox_database_test_helper.cc
deleted file mode 100644
index 2bf1c7c4e94577c225195bfbe192821a7c0254e8..0000000000000000000000000000000000000000
--- a/webkit/fileapi/sandbox_database_test_helper.cc
+++ /dev/null
@@ -1,101 +0,0 @@
-// Copyright (c) 2012 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/sandbox_database_test_helper.h"
-
-#include <algorithm>
-#include <functional>
-#include <vector>
-
-#include "base/file_util.h"
-#include "base/stl_util.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/fileapi/file_system_util.h"
-
-namespace fileapi {
-
-void CorruptDatabase(const base::FilePath& db_path,
- leveldb::FileType type,
- ptrdiff_t offset,
- size_t size) {
- file_util::FileEnumerator file_enum(db_path, false /* not recursive */,
- file_util::FileEnumerator::DIRECTORIES |
- file_util::FileEnumerator::FILES);
- base::FilePath file_path;
- base::FilePath picked_file_path;
- uint64 picked_file_number = kuint64max;
-
- while (!(file_path = file_enum.Next()).empty()) {
- uint64 number = kuint64max;
- leveldb::FileType file_type;
- EXPECT_TRUE(leveldb::ParseFileName(FilePathToString(file_path.BaseName()),
- &number, &file_type));
- if (file_type == type &&
- (picked_file_number == kuint64max || picked_file_number < number)) {
- picked_file_path = file_path;
- picked_file_number = number;
- }
- }
-
- EXPECT_FALSE(picked_file_path.empty());
- EXPECT_NE(kuint64max, picked_file_number);
-
- bool created = true;
- base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED;
- base::PlatformFile file =
- CreatePlatformFile(picked_file_path,
- base::PLATFORM_FILE_OPEN |
- base::PLATFORM_FILE_READ |
- base::PLATFORM_FILE_WRITE,
- &created, &error);
- EXPECT_EQ(base::PLATFORM_FILE_OK, error);
- EXPECT_FALSE(created);
-
- base::PlatformFileInfo file_info;
- EXPECT_TRUE(base::GetPlatformFileInfo(file, &file_info));
- if (offset < 0)
- offset += file_info.size;
- EXPECT_GE(offset, 0);
- EXPECT_LE(offset, file_info.size);
-
- size = std::min(size, static_cast<size_t>(file_info.size - offset));
-
- std::vector<char> buf(size);
- int read_size = base::ReadPlatformFile(file, offset,
- vector_as_array(&buf), buf.size());
- EXPECT_LT(0, read_size);
- EXPECT_GE(buf.size(), static_cast<size_t>(read_size));
- buf.resize(read_size);
-
- std::transform(buf.begin(), buf.end(), buf.begin(),
- std::logical_not<char>());
-
- int written_size = base::WritePlatformFile(file, offset,
- vector_as_array(&buf), buf.size());
- EXPECT_GT(written_size, 0);
- EXPECT_EQ(buf.size(), static_cast<size_t>(written_size));
-
- base::ClosePlatformFile(file);
-}
-
-void DeleteDatabaseFile(const base::FilePath& db_path,
- leveldb::FileType type) {
- file_util::FileEnumerator file_enum(db_path, false /* not recursive */,
- file_util::FileEnumerator::DIRECTORIES |
- file_util::FileEnumerator::FILES);
- base::FilePath file_path;
- while (!(file_path = file_enum.Next()).empty()) {
- uint64 number = kuint64max;
- leveldb::FileType file_type;
- EXPECT_TRUE(leveldb::ParseFileName(FilePathToString(file_path.BaseName()),
- &number, &file_type));
- if (file_type == type) {
- file_util::Delete(file_path, false);
- // We may have multiple files for the same type, so don't break here.
- }
- }
-
-}
-
-} // namespace fileapi
« no previous file with comments | « webkit/fileapi/sandbox_database_test_helper.h ('k') | webkit/fileapi/sandbox_directory_database.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698