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

Unified Diff: webkit/browser/fileapi/obfuscated_file_util.cc

Issue 16150002: Implement special origin database handling for Isolated Apps (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
Index: webkit/browser/fileapi/obfuscated_file_util.cc
diff --git a/webkit/browser/fileapi/obfuscated_file_util.cc b/webkit/browser/fileapi/obfuscated_file_util.cc
index 2971fe2e90c0f2d44392668000dfd19f0039ab58..2050783499fc0d8105f49683cd1b739fbc5e474c 100644
--- a/webkit/browser/fileapi/obfuscated_file_util.cc
+++ b/webkit/browser/fileapi/obfuscated_file_util.cc
@@ -24,7 +24,9 @@
#include "webkit/browser/fileapi/file_system_operation_context.h"
#include "webkit/browser/fileapi/file_system_url.h"
#include "webkit/browser/fileapi/native_file_util.h"
+#include "webkit/browser/fileapi/sandbox_isolated_origin_database.h"
#include "webkit/browser/fileapi/sandbox_mount_point_provider.h"
+#include "webkit/browser/fileapi/sandbox_origin_database.h"
#include "webkit/browser/fileapi/syncable/syncable_file_system_util.h"
#include "webkit/common/fileapi/file_system_util.h"
#include "webkit/quota/quota_manager.h"
@@ -210,7 +212,7 @@ class ObfuscatedOriginEnumerator
public:
typedef SandboxOriginDatabase::OriginRecord OriginRecord;
ObfuscatedOriginEnumerator(
- SandboxOriginDatabase* origin_database,
+ SandboxOriginDatabaseInterface* origin_database,
const base::FilePath& base_file_path)
: base_file_path_(base_file_path) {
if (origin_database)
@@ -240,7 +242,8 @@ class ObfuscatedOriginEnumerator
NOTREACHED();
return false;
}
- base::FilePath path = base_file_path_.Append(current_.path).Append(type_string);
+ base::FilePath path =
+ base_file_path_.Append(current_.path).Append(type_string);
return file_util::DirectoryExists(path);
}
@@ -251,8 +254,10 @@ class ObfuscatedOriginEnumerator
};
ObfuscatedFileUtil::ObfuscatedFileUtil(
+ quota::SpecialStoragePolicy* special_storage_policy,
const base::FilePath& file_system_directory)
- : file_system_directory_(file_system_directory) {
+ : special_storage_policy_(special_storage_policy),
+ file_system_directory_(file_system_directory) {
}
ObfuscatedFileUtil::~ObfuscatedFileUtil() {
@@ -881,8 +886,8 @@ base::FilePath ObfuscatedFileUtil::GetDirectoryForOriginAndType(
bool ObfuscatedFileUtil::DeleteDirectoryForOriginAndType(
const GURL& origin, FileSystemType type) {
base::PlatformFileError error = base::PLATFORM_FILE_OK;
- base::FilePath origin_type_path = GetDirectoryForOriginAndType(origin, type, false,
- &error);
+ base::FilePath origin_type_path = GetDirectoryForOriginAndType(
+ origin, type, false, &error);
if (origin_type_path.empty())
return true;
@@ -975,7 +980,8 @@ bool ObfuscatedFileUtil::DestroyDirectoryDatabase(
}
PlatformFileError error = base::PLATFORM_FILE_OK;
- base::FilePath path = GetDirectoryForOriginAndType(origin, type, false, &error);
+ base::FilePath path = GetDirectoryForOriginAndType(
+ origin, type, false, &error);
if (path.empty() || error == base::PLATFORM_FILE_ERROR_NOT_FOUND)
return true;
return SandboxDirectoryDatabase::DestroyDatabase(path);
@@ -1048,8 +1054,8 @@ PlatformFileError ObfuscatedFileUtil::CreateFile(
dest_origin, dest_type, true);
PlatformFileError error = base::PLATFORM_FILE_OK;
- base::FilePath root = GetDirectoryForOriginAndType(dest_origin, dest_type, false,
- &error);
+ base::FilePath root = GetDirectoryForOriginAndType(
+ dest_origin, dest_type, false, &error);
if (error != base::PLATFORM_FILE_OK)
return error;
@@ -1120,7 +1126,8 @@ PlatformFileError ObfuscatedFileUtil::CreateFile(
base::FilePath ObfuscatedFileUtil::DataPathToLocalPath(
const GURL& origin, FileSystemType type, const base::FilePath& data_path) {
PlatformFileError error = base::PLATFORM_FILE_OK;
- base::FilePath root = GetDirectoryForOriginAndType(origin, type, false, &error);
+ base::FilePath root = GetDirectoryForOriginAndType(
+ origin, type, false, &error);
if (error != base::PLATFORM_FILE_OK)
return base::FilePath();
return root.Append(data_path);
@@ -1147,7 +1154,8 @@ SandboxDirectoryDatabase* ObfuscatedFileUtil::GetDirectoryDatabase(
}
PlatformFileError error = base::PLATFORM_FILE_OK;
- base::FilePath path = GetDirectoryForOriginAndType(origin, type, create, &error);
+ base::FilePath path = GetDirectoryForOriginAndType(
+ origin, type, create, &error);
if (error != base::PLATFORM_FILE_OK) {
LOG(WARNING) << "Failed to get origin+type directory: " << path.value();
return NULL;
@@ -1160,6 +1168,14 @@ SandboxDirectoryDatabase* ObfuscatedFileUtil::GetDirectoryDatabase(
base::FilePath ObfuscatedFileUtil::GetDirectoryForOrigin(
const GURL& origin, bool create, base::PlatformFileError* error_code) {
+ if (special_storage_policy_ &&
+ special_storage_policy_->HasIsolatedStorage(origin)) {
+ CHECK(isolated_origin_.is_empty() || isolated_origin_ == origin)
+ << "multiple origins for an isolated site: "
+ << isolated_origin_.spec() << " vs " << origin.spec();
+ isolated_origin_ = origin;
+ }
+
if (!InitOriginDatabase(create)) {
if (error_code) {
*error_code = create ?
@@ -1234,17 +1250,29 @@ void ObfuscatedFileUtil::DropDatabases() {
}
bool ObfuscatedFileUtil::InitOriginDatabase(bool create) {
- if (!origin_database_) {
- if (!create && !file_util::DirectoryExists(file_system_directory_))
- return false;
- if (!file_util::CreateDirectory(file_system_directory_)) {
- LOG(WARNING) << "Failed to create FileSystem directory: " <<
- file_system_directory_.value();
- return false;
- }
+ if (origin_database_)
+ return true;
+
+ if (!create && !file_util::DirectoryExists(file_system_directory_))
+ return false;
+ if (!file_util::CreateDirectory(file_system_directory_)) {
+ LOG(WARNING) << "Failed to create FileSystem directory: " <<
+ file_system_directory_.value();
+ return false;
+ }
+
+ if (!isolated_origin_.is_empty()) {
+ DCHECK(special_storage_policy_->HasIsolatedStorage(isolated_origin_));
origin_database_.reset(
- new SandboxOriginDatabase(file_system_directory_));
+ new SandboxIsolatedOriginDatabase(
+ UTF16ToUTF8(webkit_base::GetOriginIdentifierFromURL(
+ isolated_origin_)),
+ file_system_directory_));
+ return true;
}
+
+ origin_database_.reset(
+ new SandboxOriginDatabase(file_system_directory_));
return true;
}
@@ -1260,8 +1288,8 @@ PlatformFileError ObfuscatedFileUtil::GenerateNewLocalPath(
return base::PLATFORM_FILE_ERROR_FAILED;
PlatformFileError error = base::PLATFORM_FILE_OK;
- base::FilePath new_local_path = GetDirectoryForOriginAndType(origin, type,
- false, &error);
+ base::FilePath new_local_path = GetDirectoryForOriginAndType(
+ origin, type, false, &error);
if (error != base::PLATFORM_FILE_OK)
return base::PLATFORM_FILE_ERROR_FAILED;
« no previous file with comments | « webkit/browser/fileapi/obfuscated_file_util.h ('k') | webkit/browser/fileapi/sandbox_isolated_origin_database.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698