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

Unified Diff: storage/common/fileapi/file_system_util.cc

Issue 442383002: Move storage-related files from webkit/ to new top-level directory storage/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 4 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 | « storage/common/fileapi/file_system_util.h ('k') | storage/common/quota/quota_status_code.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: storage/common/fileapi/file_system_util.cc
diff --git a/webkit/common/fileapi/file_system_util.cc b/storage/common/fileapi/file_system_util.cc
similarity index 88%
rename from webkit/common/fileapi/file_system_util.cc
rename to storage/common/fileapi/file_system_util.cc
index ded3457ccf3efb2626c51f6491701a7adefefca5..165991afef27ef41e9a566b70e5ea832d47a82e2 100644
--- a/webkit/common/fileapi/file_system_util.cc
+++ b/storage/common/fileapi/file_system_util.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/common/fileapi/file_system_util.h"
+#include "storage/common/fileapi/file_system_util.h"
#include <algorithm>
@@ -14,9 +14,9 @@
#include "net/base/escape.h"
#include "net/base/net_errors.h"
#include "url/gurl.h"
-#include "webkit/common/database/database_identifier.h"
+#include "storage/common/database/database_identifier.h"
-namespace fileapi {
+namespace storage {
const char kPersistentDir[] = "/persistent";
const char kTemporaryDir[] = "/temporary";
@@ -49,7 +49,7 @@ base::FilePath VirtualPath::BaseName(const base::FilePath& virtual_path) {
base::FilePath VirtualPath::DirName(const base::FilePath& virtual_path) {
typedef base::FilePath::StringType StringType;
- StringType path = virtual_path.value();
+ StringType path = virtual_path.value();
// The logic below is taken from that of base::FilePath::DirName, except
// that this version never cares about '//' or drive-letters even on win32.
@@ -124,15 +124,18 @@ void VirtualPath::GetComponentsUTF8Unsafe(
base::FilePath::StringType VirtualPath::GetNormalizedFilePath(
const base::FilePath& path) {
base::FilePath::StringType normalized_path = path.value();
- const size_t num_separators = base::FilePath::StringType(
- base::FilePath::kSeparators).length();
+ const size_t num_separators =
+ base::FilePath::StringType(base::FilePath::kSeparators).length();
for (size_t i = 0; i < num_separators; ++i) {
- std::replace(normalized_path.begin(), normalized_path.end(),
- base::FilePath::kSeparators[i], kSeparator);
+ std::replace(normalized_path.begin(),
+ normalized_path.end(),
+ base::FilePath::kSeparators[i],
+ kSeparator);
}
- return (IsAbsolute(normalized_path)) ?
- normalized_path : base::FilePath::StringType(kRoot) + normalized_path;
+ return (IsAbsolute(normalized_path))
+ ? normalized_path
+ : base::FilePath::StringType(kRoot) + normalized_path;
}
bool VirtualPath::IsAbsolute(const base::FilePath::StringType& path) {
@@ -143,8 +146,7 @@ bool VirtualPath::IsRootPath(const base::FilePath& path) {
std::vector<base::FilePath::StringType> components;
VirtualPath::GetComponents(path, &components);
return (path.empty() || components.empty() ||
- (components.size() == 1 &&
- components[0] == VirtualPath::kRoot));
+ (components.size() == 1 && components[0] == VirtualPath::kRoot));
}
bool ParseFileSystemSchemeURL(const GURL& url,
@@ -161,12 +163,12 @@ bool ParseFileSystemSchemeURL(const GURL& url,
FileSystemType type;
const char* dir;
} kValidTypes[] = {
- { kFileSystemTypePersistent, kPersistentDir },
- { kFileSystemTypeTemporary, kTemporaryDir },
- { kFileSystemTypeIsolated, kIsolatedDir },
- { kFileSystemTypeExternal, kExternalDir },
- { kFileSystemTypeTest, kTestDir },
- };
+ {kFileSystemTypePersistent, kPersistentDir},
+ {kFileSystemTypeTemporary, kTemporaryDir},
+ {kFileSystemTypeIsolated, kIsolatedDir},
+ {kFileSystemTypeExternal, kExternalDir},
+ {kFileSystemTypeTest, kTestDir},
+ };
// A path of the inner_url contains only mount type part (e.g. "/temporary").
DCHECK(url.inner_url());
@@ -181,9 +183,10 @@ bool ParseFileSystemSchemeURL(const GURL& url,
if (file_system_type == kFileSystemTypeUnknown)
return false;
- std::string path = net::UnescapeURLComponent(url.path(),
+ std::string path = net::UnescapeURLComponent(
+ url.path(),
net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS |
- net::UnescapeRule::CONTROL_CHARS);
+ net::UnescapeRule::CONTROL_CHARS);
// Ensure the path is relative.
while (!path.empty() && path[0] == '/')
@@ -200,8 +203,8 @@ bool ParseFileSystemSchemeURL(const GURL& url,
if (type)
*type = file_system_type;
if (virtual_path)
- *virtual_path = converted_path.NormalizePathSeparators().
- StripTrailingSeparators();
+ *virtual_path =
+ converted_path.NormalizePathSeparators().StripTrailingSeparators();
return true;
}
@@ -228,7 +231,7 @@ GURL GetFileSystemRootURI(const GURL& origin_url, FileSystemType type) {
case kFileSystemTypeTest:
url += (kTestDir + 1); // We don't want the leading slash.
return GURL(url + "/");
- // Internal types are always pointed via isolated or external URLs.
+ // Internal types are always pointed via isolated or external URLs.
default:
NOTREACHED();
}
@@ -324,7 +327,7 @@ std::string GetFileSystemTypeString(FileSystemType type) {
case kFileSystemInternalTypeEnumStart:
case kFileSystemInternalTypeEnumEnd:
NOTREACHED();
- // Fall through.
+ // Fall through.
case kFileSystemTypeUnknown:
return "Unknown";
}
@@ -348,8 +351,7 @@ base::FilePath StringToFilePath(const std::string& file_path_string) {
#endif
}
-blink::WebFileError FileErrorToWebFileError(
- base::File::Error error_code) {
+blink::WebFileError FileErrorToWebFileError(base::File::Error error_code) {
switch (error_code) {
case base::File::FILE_ERROR_NOT_FOUND:
return blink::WebFileErrorNotFound;
@@ -377,9 +379,8 @@ blink::WebFileError FileErrorToWebFileError(
}
}
-bool GetFileSystemPublicType(
- const std::string type_string,
- blink::WebFileSystemType* type) {
+bool GetFileSystemPublicType(const std::string type_string,
+ blink::WebFileSystemType* type) {
DCHECK(type);
if (type_string == "Temporary") {
*type = blink::WebFileSystemTypeTemporary;
@@ -403,8 +404,8 @@ bool GetFileSystemPublicType(
std::string GetIsolatedFileSystemName(const GURL& origin_url,
const std::string& filesystem_id) {
- std::string name(fileapi::GetFileSystemName(
- origin_url, fileapi::kFileSystemTypeIsolated));
+ std::string name(
+ storage::GetFileSystemName(origin_url, storage::kFileSystemTypeIsolated));
name.append("_");
name.append(filesystem_id);
return name;
@@ -416,8 +417,9 @@ bool CrackIsolatedFileSystemName(const std::string& filesystem_name,
// |filesystem_name| is of the form {origin}:isolated_{filesystem_id}.
std::string start_token(":");
- start_token = start_token.append(
- GetFileSystemTypeString(kFileSystemTypeIsolated)).append("_");
+ start_token =
+ start_token.append(GetFileSystemTypeString(kFileSystemTypeIsolated))
+ .append("_");
// WebKit uses different case in its constant for isolated file system
// names, so we do a case insensitive compare by converting both strings
// to uppercase.
@@ -430,8 +432,8 @@ bool CrackIsolatedFileSystemName(const std::string& filesystem_name,
if (pos == 0)
return false;
- *filesystem_id = filesystem_name.substr(pos + start_token.length(),
- std::string::npos);
+ *filesystem_id =
+ filesystem_name.substr(pos + start_token.length(), std::string::npos);
if (filesystem_id->empty())
return false;
@@ -450,8 +452,8 @@ std::string GetIsolatedFileSystemRootURIString(
const GURL& origin_url,
const std::string& filesystem_id,
const std::string& optional_root_name) {
- std::string root = GetFileSystemRootURI(origin_url,
- kFileSystemTypeIsolated).spec();
+ std::string root =
+ GetFileSystemRootURI(origin_url, kFileSystemTypeIsolated).spec();
if (base::FilePath::FromUTF8Unsafe(filesystem_id).ReferencesParent())
return std::string();
root.append(net::EscapePath(filesystem_id));
@@ -465,11 +467,10 @@ std::string GetIsolatedFileSystemRootURIString(
return root;
}
-std::string GetExternalFileSystemRootURIString(
- const GURL& origin_url,
- const std::string& mount_name) {
- std::string root = GetFileSystemRootURI(origin_url,
- kFileSystemTypeExternal).spec();
+std::string GetExternalFileSystemRootURIString(const GURL& origin_url,
+ const std::string& mount_name) {
+ std::string root =
+ GetFileSystemRootURI(origin_url, kFileSystemTypeExternal).spec();
if (base::FilePath::FromUTF8Unsafe(mount_name).ReferencesParent())
return std::string();
root.append(net::EscapePath(mount_name));
@@ -509,4 +510,4 @@ base::File::Error NetErrorToFileError(int error) {
}
}
-} // namespace fileapi
+} // namespace storage
« no previous file with comments | « storage/common/fileapi/file_system_util.h ('k') | storage/common/quota/quota_status_code.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698