| Index: storage/browser/fileapi/isolated_context.cc
|
| diff --git a/webkit/browser/fileapi/isolated_context.cc b/storage/browser/fileapi/isolated_context.cc
|
| similarity index 86%
|
| rename from webkit/browser/fileapi/isolated_context.cc
|
| rename to storage/browser/fileapi/isolated_context.cc
|
| index a187a05e0cd9895c5ee15145a38c36248788f51b..7bf55cda37438a6fbec4b2985eb3fa560122e07d 100644
|
| --- a/webkit/browser/fileapi/isolated_context.cc
|
| +++ b/storage/browser/fileapi/isolated_context.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/isolated_context.h"
|
| +#include "storage/browser/fileapi/isolated_context.h"
|
|
|
| #include "base/basictypes.h"
|
| #include "base/files/file_path.h"
|
| @@ -12,9 +12,9 @@
|
| #include "base/strings/string_number_conversions.h"
|
| #include "base/strings/string_util.h"
|
| #include "base/strings/stringprintf.h"
|
| -#include "webkit/browser/fileapi/file_system_url.h"
|
| +#include "storage/browser/fileapi/file_system_url.h"
|
|
|
| -namespace fileapi {
|
| +namespace storage {
|
|
|
| namespace {
|
|
|
| @@ -52,11 +52,13 @@ static base::LazyInstance<IsolatedContext>::Leaky g_isolated_context =
|
|
|
| } // namespace
|
|
|
| -IsolatedContext::FileInfoSet::FileInfoSet() {}
|
| -IsolatedContext::FileInfoSet::~FileInfoSet() {}
|
| +IsolatedContext::FileInfoSet::FileInfoSet() {
|
| +}
|
| +IsolatedContext::FileInfoSet::~FileInfoSet() {
|
| +}
|
|
|
| -bool IsolatedContext::FileInfoSet::AddPath(
|
| - const base::FilePath& path, std::string* registered_name) {
|
| +bool IsolatedContext::FileInfoSet::AddPath(const base::FilePath& path,
|
| + std::string* registered_name) {
|
| // The given path should not contain any '..' and should be absolute.
|
| if (path.ReferencesParent() || !path.IsAbsolute())
|
| return false;
|
| @@ -84,23 +86,20 @@ bool IsolatedContext::FileInfoSet::AddPath(
|
| return true;
|
| }
|
|
|
| -bool IsolatedContext::FileInfoSet::AddPathWithName(
|
| - const base::FilePath& path, const std::string& name) {
|
| +bool IsolatedContext::FileInfoSet::AddPathWithName(const base::FilePath& path,
|
| + const std::string& name) {
|
| // The given path should not contain any '..' and should be absolute.
|
| if (path.ReferencesParent() || !path.IsAbsolute())
|
| return false;
|
| - return fileset_.insert(
|
| - MountPointInfo(name, path.NormalizePathSeparators())).second;
|
| + return fileset_.insert(MountPointInfo(name, path.NormalizePathSeparators()))
|
| + .second;
|
| }
|
|
|
| //--------------------------------------------------------------------------
|
|
|
| class IsolatedContext::Instance {
|
| public:
|
| - enum PathType {
|
| - PLATFORM_PATH,
|
| - VIRTUAL_PATH
|
| - };
|
| + enum PathType { PLATFORM_PATH, VIRTUAL_PATH };
|
|
|
| // For a single-path isolated file system, which could be registered by
|
| // IsolatedContext::RegisterFileSystemForPath() or
|
| @@ -164,14 +163,12 @@ IsolatedContext::Instance::Instance(FileSystemType type,
|
|
|
| IsolatedContext::Instance::Instance(FileSystemType type,
|
| const std::set<MountPointInfo>& files)
|
| - : type_(type),
|
| - path_type_(PLATFORM_PATH),
|
| - files_(files),
|
| - ref_counts_(0) {
|
| + : type_(type), path_type_(PLATFORM_PATH), files_(files), ref_counts_(0) {
|
| DCHECK(!IsSinglePathIsolatedFileSystem(type_));
|
| }
|
|
|
| -IsolatedContext::Instance::~Instance() {}
|
| +IsolatedContext::Instance::~Instance() {
|
| +}
|
|
|
| bool IsolatedContext::Instance::ResolvePathForName(const std::string& name,
|
| base::FilePath* path) const {
|
| @@ -189,8 +186,8 @@ bool IsolatedContext::Instance::ResolvePathForName(const std::string& name,
|
|
|
| return file_info_.name == name;
|
| }
|
| - std::set<MountPointInfo>::const_iterator found = files_.find(
|
| - MountPointInfo(name, base::FilePath()));
|
| + std::set<MountPointInfo>::const_iterator found =
|
| + files_.find(MountPointInfo(name, base::FilePath()));
|
| if (found == files_.end())
|
| return false;
|
| *path = found->path;
|
| @@ -217,8 +214,8 @@ std::string IsolatedContext::RegisterDraggedFileSystem(
|
| const FileInfoSet& files) {
|
| base::AutoLock locker(lock_);
|
| std::string filesystem_id = GetNewFileSystemId();
|
| - instance_map_[filesystem_id] = new Instance(
|
| - kFileSystemTypeDragged, files.fileset());
|
| + instance_map_[filesystem_id] =
|
| + new Instance(kFileSystemTypeDragged, files.fileset());
|
| return filesystem_id;
|
| }
|
|
|
| @@ -241,9 +238,8 @@ std::string IsolatedContext::RegisterFileSystemForPath(
|
|
|
| base::AutoLock locker(lock_);
|
| std::string new_id = GetNewFileSystemId();
|
| - instance_map_[new_id] = new Instance(type, filesystem_id,
|
| - MountPointInfo(name, path),
|
| - Instance::PLATFORM_PATH);
|
| + instance_map_[new_id] = new Instance(
|
| + type, filesystem_id, MountPointInfo(name, path), Instance::PLATFORM_PATH);
|
| path_to_id_map_[path].insert(new_id);
|
| return new_id;
|
| }
|
| @@ -257,11 +253,11 @@ std::string IsolatedContext::RegisterFileSystemForVirtualPath(
|
| if (path.ReferencesParent())
|
| return std::string();
|
| std::string filesystem_id = GetNewFileSystemId();
|
| - instance_map_[filesystem_id] = new Instance(
|
| - type,
|
| - std::string(), // filesystem_id
|
| - MountPointInfo(register_name, cracked_path_prefix),
|
| - Instance::VIRTUAL_PATH);
|
| + instance_map_[filesystem_id] =
|
| + new Instance(type,
|
| + std::string(), // filesystem_id
|
| + MountPointInfo(register_name, cracked_path_prefix),
|
| + Instance::VIRTUAL_PATH);
|
| path_to_id_map_[path].insert(filesystem_id);
|
| return filesystem_id;
|
| }
|
| @@ -275,8 +271,8 @@ bool IsolatedContext::RevokeFileSystem(const std::string& filesystem_id) {
|
| return UnregisterFileSystem(filesystem_id);
|
| }
|
|
|
| -bool IsolatedContext::GetRegisteredPath(
|
| - const std::string& filesystem_id, base::FilePath* path) const {
|
| +bool IsolatedContext::GetRegisteredPath(const std::string& filesystem_id,
|
| + base::FilePath* path) const {
|
| DCHECK(path);
|
| base::AutoLock locker(lock_);
|
| IDToInstance::const_iterator found = instance_map_.find(filesystem_id);
|
| @@ -366,8 +362,8 @@ void IsolatedContext::RevokeFileSystemByPath(const base::FilePath& path_in) {
|
| if (ids_iter == path_to_id_map_.end())
|
| return;
|
| std::set<std::string>& ids = ids_iter->second;
|
| - for (std::set<std::string>::iterator iter = ids.begin();
|
| - iter != ids.end(); ++iter) {
|
| + for (std::set<std::string>::iterator iter = ids.begin(); iter != ids.end();
|
| + ++iter) {
|
| IDToInstance::iterator found = instance_map_.find(*iter);
|
| if (found != instance_map_.end()) {
|
| delete found->second;
|
| @@ -408,8 +404,7 @@ bool IsolatedContext::GetDraggedFileInfo(
|
| if (found == instance_map_.end() ||
|
| found->second->type() != kFileSystemTypeDragged)
|
| return false;
|
| - files->assign(found->second->files().begin(),
|
| - found->second->files().end());
|
| + files->assign(found->second->files().begin(), found->second->files().end());
|
| return true;
|
| }
|
|
|
| @@ -436,16 +431,22 @@ FileSystemURL IsolatedContext::CrackFileSystemURL(
|
| FileSystemType cracked_type;
|
| base::FilePath cracked_path;
|
| FileSystemMountOption cracked_mount_option;
|
| - if (!CrackVirtualPath(url.path(), &mount_name, &cracked_type,
|
| - &cracked_mount_name, &cracked_path,
|
| + if (!CrackVirtualPath(url.path(),
|
| + &mount_name,
|
| + &cracked_type,
|
| + &cracked_mount_name,
|
| + &cracked_path,
|
| &cracked_mount_option)) {
|
| return FileSystemURL();
|
| }
|
|
|
| return FileSystemURL(
|
| - url.origin(), url.mount_type(), url.virtual_path(),
|
| + url.origin(),
|
| + url.mount_type(),
|
| + url.virtual_path(),
|
| !url.filesystem_id().empty() ? url.filesystem_id() : mount_name,
|
| - cracked_type, cracked_path,
|
| + cracked_type,
|
| + cracked_path,
|
| cracked_mount_name.empty() ? mount_name : cracked_mount_name,
|
| cracked_mount_option);
|
| }
|
| @@ -457,8 +458,8 @@ bool IsolatedContext::UnregisterFileSystem(const std::string& filesystem_id) {
|
| return false;
|
| Instance* instance = found->second;
|
| if (instance->IsSinglePathInstance()) {
|
| - PathToID::iterator ids_iter = path_to_id_map_.find(
|
| - instance->file_info().path);
|
| + PathToID::iterator ids_iter =
|
| + path_to_id_map_.find(instance->file_info().path);
|
| DCHECK(ids_iter != path_to_id_map_.end());
|
| ids_iter->second.erase(filesystem_id);
|
| if (ids_iter->second.empty())
|
| @@ -481,4 +482,4 @@ std::string IsolatedContext::GetNewFileSystemId() const {
|
| return id;
|
| }
|
|
|
| -} // namespace fileapi
|
| +} // namespace storage
|
|
|