| Index: storage/browser/fileapi/sandbox_origin_database.cc
|
| diff --git a/webkit/browser/fileapi/sandbox_origin_database.cc b/storage/browser/fileapi/sandbox_origin_database.cc
|
| similarity index 85%
|
| rename from webkit/browser/fileapi/sandbox_origin_database.cc
|
| rename to storage/browser/fileapi/sandbox_origin_database.cc
|
| index 3bbee520e630dc74ae9f9d835e904e4ba7c49ffe..2c23d840c6f4c5ac286c691c48ecedad7de63ddf 100644
|
| --- a/webkit/browser/fileapi/sandbox_origin_database.cc
|
| +++ b/storage/browser/fileapi/sandbox_origin_database.cc
|
| @@ -2,7 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "webkit/browser/fileapi/sandbox_origin_database.h"
|
| +#include "storage/browser/fileapi/sandbox_origin_database.h"
|
|
|
| #include <set>
|
| #include <utility>
|
| @@ -18,7 +18,7 @@
|
| #include "base/strings/stringprintf.h"
|
| #include "third_party/leveldatabase/src/include/leveldb/db.h"
|
| #include "third_party/leveldatabase/src/include/leveldb/write_batch.h"
|
| -#include "webkit/common/fileapi/file_system_util.h"
|
| +#include "storage/common/fileapi/file_system_util.h"
|
|
|
| namespace {
|
|
|
| @@ -38,11 +38,7 @@ enum InitStatus {
|
| INIT_STATUS_MAX
|
| };
|
|
|
| -enum RepairResult {
|
| - DB_REPAIR_SUCCEEDED = 0,
|
| - DB_REPAIR_FAILED,
|
| - DB_REPAIR_MAX
|
| -};
|
| +enum RepairResult { DB_REPAIR_SUCCEEDED = 0, DB_REPAIR_FAILED, DB_REPAIR_MAX };
|
|
|
| std::string OriginToOriginKey(const std::string& origin) {
|
| std::string key(kOriginKeyPrefix);
|
| @@ -55,7 +51,7 @@ const char* LastPathKey() {
|
|
|
| } // namespace
|
|
|
| -namespace fileapi {
|
| +namespace storage {
|
|
|
| SandboxOriginDatabase::SandboxOriginDatabase(
|
| const base::FilePath& file_system_directory,
|
| @@ -104,14 +100,14 @@ bool SandboxOriginDatabase::Init(InitOption init_option,
|
| LOG(WARNING) << "Attempting to repair SandboxOriginDatabase.";
|
|
|
| if (RepairDatabase(path)) {
|
| - UMA_HISTOGRAM_ENUMERATION(kDatabaseRepairHistogramLabel,
|
| - DB_REPAIR_SUCCEEDED, DB_REPAIR_MAX);
|
| + UMA_HISTOGRAM_ENUMERATION(
|
| + kDatabaseRepairHistogramLabel, DB_REPAIR_SUCCEEDED, DB_REPAIR_MAX);
|
| LOG(WARNING) << "Repairing SandboxOriginDatabase completed.";
|
| return true;
|
| }
|
| - UMA_HISTOGRAM_ENUMERATION(kDatabaseRepairHistogramLabel,
|
| - DB_REPAIR_FAILED, DB_REPAIR_MAX);
|
| - // fall through
|
| + UMA_HISTOGRAM_ENUMERATION(
|
| + kDatabaseRepairHistogramLabel, DB_REPAIR_FAILED, DB_REPAIR_MAX);
|
| + // fall through
|
| case DELETE_ON_CORRUPTION:
|
| if (!base::DeleteFile(file_system_directory_, true))
|
| return false;
|
| @@ -177,7 +173,7 @@ bool SandboxOriginDatabase::RepairDatabase(const std::string& db_path) {
|
| dir_itr != directories.end();
|
| ++dir_itr) {
|
| if (!base::DeleteFile(file_system_directory_.Append(*dir_itr),
|
| - true /* recursive */)) {
|
| + true /* recursive */)) {
|
| DropDatabase();
|
| return false;
|
| }
|
| @@ -190,8 +186,8 @@ void SandboxOriginDatabase::HandleError(
|
| const tracked_objects::Location& from_here,
|
| const leveldb::Status& status) {
|
| db_.reset();
|
| - LOG(ERROR) << "SandboxOriginDatabase failed at: "
|
| - << from_here.ToString() << " with error: " << status.ToString();
|
| + LOG(ERROR) << "SandboxOriginDatabase failed at: " << from_here.ToString()
|
| + << " with error: " << status.ToString();
|
| }
|
|
|
| void SandboxOriginDatabase::ReportInitStatus(const leveldb::Status& status) {
|
| @@ -203,17 +199,17 @@ void SandboxOriginDatabase::ReportInitStatus(const leveldb::Status& status) {
|
| last_reported_time_ = now;
|
|
|
| if (status.ok()) {
|
| - UMA_HISTOGRAM_ENUMERATION(kInitStatusHistogramLabel,
|
| - INIT_STATUS_OK, INIT_STATUS_MAX);
|
| + UMA_HISTOGRAM_ENUMERATION(
|
| + kInitStatusHistogramLabel, INIT_STATUS_OK, INIT_STATUS_MAX);
|
| } else if (status.IsCorruption()) {
|
| - UMA_HISTOGRAM_ENUMERATION(kInitStatusHistogramLabel,
|
| - INIT_STATUS_CORRUPTION, INIT_STATUS_MAX);
|
| + UMA_HISTOGRAM_ENUMERATION(
|
| + kInitStatusHistogramLabel, INIT_STATUS_CORRUPTION, INIT_STATUS_MAX);
|
| } else if (status.IsIOError()) {
|
| - UMA_HISTOGRAM_ENUMERATION(kInitStatusHistogramLabel,
|
| - INIT_STATUS_IO_ERROR, INIT_STATUS_MAX);
|
| + UMA_HISTOGRAM_ENUMERATION(
|
| + kInitStatusHistogramLabel, INIT_STATUS_IO_ERROR, INIT_STATUS_MAX);
|
| } else {
|
| - UMA_HISTOGRAM_ENUMERATION(kInitStatusHistogramLabel,
|
| - INIT_STATUS_UNKNOWN_ERROR, INIT_STATUS_MAX);
|
| + UMA_HISTOGRAM_ENUMERATION(
|
| + kInitStatusHistogramLabel, INIT_STATUS_UNKNOWN_ERROR, INIT_STATUS_MAX);
|
| }
|
| }
|
|
|
| @@ -233,8 +229,8 @@ bool SandboxOriginDatabase::HasOriginPath(const std::string& origin) {
|
| return false;
|
| }
|
|
|
| -bool SandboxOriginDatabase::GetPathForOrigin(
|
| - const std::string& origin, base::FilePath* directory) {
|
| +bool SandboxOriginDatabase::GetPathForOrigin(const std::string& origin,
|
| + base::FilePath* directory) {
|
| if (!Init(CREATE_IF_NONEXISTENT, REPAIR_ON_CORRUPTION))
|
| return false;
|
| DCHECK(directory);
|
| @@ -278,8 +274,7 @@ bool SandboxOriginDatabase::RemovePathForOrigin(const std::string& origin) {
|
| return false;
|
| }
|
|
|
| -bool SandboxOriginDatabase::ListAllOrigins(
|
| - std::vector<OriginRecord>* origins) {
|
| +bool SandboxOriginDatabase::ListAllOrigins(std::vector<OriginRecord>* origins) {
|
| DCHECK(origins);
|
| if (!Init(CREATE_IF_NONEXISTENT, REPAIR_ON_CORRUPTION)) {
|
| origins->clear();
|
| @@ -290,9 +285,9 @@ bool SandboxOriginDatabase::ListAllOrigins(
|
| iter->Seek(origin_key_prefix);
|
| origins->clear();
|
| while (iter->Valid() &&
|
| - StartsWithASCII(iter->key().ToString(), origin_key_prefix, true)) {
|
| + StartsWithASCII(iter->key().ToString(), origin_key_prefix, true)) {
|
| std::string origin =
|
| - iter->key().ToString().substr(origin_key_prefix.length());
|
| + iter->key().ToString().substr(origin_key_prefix.length());
|
| base::FilePath path = StringToFilePath(iter->value().ToString());
|
| origins->push_back(OriginRecord(origin, path));
|
| iter->Next();
|
| @@ -334,8 +329,7 @@ bool SandboxOriginDatabase::GetLastPathNumber(int* number) {
|
| }
|
| // This is always the first write into the database. If we ever add a
|
| // version number, they should go in in a single transaction.
|
| - status =
|
| - db_->Put(leveldb::WriteOptions(), LastPathKey(), std::string("-1"));
|
| + status = db_->Put(leveldb::WriteOptions(), LastPathKey(), std::string("-1"));
|
| if (!status.ok()) {
|
| HandleError(FROM_HERE, status);
|
| return false;
|
| @@ -344,4 +338,4 @@ bool SandboxOriginDatabase::GetLastPathNumber(int* number) {
|
| return true;
|
| }
|
|
|
| -} // namespace fileapi
|
| +} // namespace storage
|
|
|