summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-30 08:36:55 +0000
committerkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-30 08:36:55 +0000
commitd65c8215eae22236f282a98df358a27a8f7babb2 (patch)
treefcd939beb3c43c4b92412ab19da93f27c22dbdef /webkit
parentc793bcce64a56fd55c3ba2a69a716aca3c6abef8 (diff)
downloadchromium_src-d65c8215eae22236f282a98df358a27a8f7babb2.zip
chromium_src-d65c8215eae22236f282a98df358a27a8f7babb2.tar.gz
chromium_src-d65c8215eae22236f282a98df358a27a8f7babb2.tar.bz2
Remove ugly writable flags from IsolatedContext
For regular chrome centralize the read/write permission to ChildProcessSecurityPolicy and do nothing in fileapi layer. For DRT/content_shell disable writes at SimpleFileSystem layer as well as we do in FileAPIMessageFilter for chrome. BUG=none TEST=existing tests TEST=layout tests https://bugs.webkit.org/show_bug.cgi?id=89981 Review URL: https://chromiumcodereview.appspot.com/10692005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@145063 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/fileapi/isolated_context.cc18
-rw-r--r--webkit/fileapi/isolated_context.h14
-rw-r--r--webkit/fileapi/isolated_context_unittest.cc24
-rw-r--r--webkit/fileapi/isolated_file_util.cc16
-rw-r--r--webkit/fileapi/isolated_file_util.h6
-rw-r--r--webkit/fileapi/isolated_file_util_unittest.cc20
-rw-r--r--webkit/fileapi/isolated_mount_point_provider.cc8
-rw-r--r--webkit/tools/test_shell/simple_file_system.cc111
-rw-r--r--webkit/tools/test_shell/simple_file_system.h11
-rw-r--r--webkit/tools/test_shell/simple_file_writer.cc41
10 files changed, 130 insertions, 139 deletions
diff --git a/webkit/fileapi/isolated_context.cc b/webkit/fileapi/isolated_context.cc
index 16f7a89..20ca9a7 100644
--- a/webkit/fileapi/isolated_context.cc
+++ b/webkit/fileapi/isolated_context.cc
@@ -137,23 +137,6 @@ bool IsolatedContext::GetTopLevelPaths(const std::string& filesystem_id,
return true;
}
-bool IsolatedContext::SetWritable(const std::string& filesystem_id,
- bool writable) {
- base::AutoLock locker(lock_);
- if (toplevel_map_.find(filesystem_id) == toplevel_map_.end())
- return false;
- if (writable)
- writable_ids_.insert(filesystem_id);
- else
- writable_ids_.erase(filesystem_id);
- return true;
-}
-
-bool IsolatedContext::IsWritable(const std::string& filesystem_id) const {
- base::AutoLock locker(lock_);
- return (writable_ids_.find(filesystem_id) != writable_ids_.end());
-}
-
FilePath IsolatedContext::CreateVirtualPath(
const std::string& filesystem_id, const FilePath& relative_path) const {
FilePath full_path;
@@ -172,7 +155,6 @@ IsolatedContext::~IsolatedContext() {
void IsolatedContext::RevokeWithoutLocking(
const std::string& filesystem_id) {
toplevel_map_.erase(filesystem_id);
- writable_ids_.erase(filesystem_id);
ref_counts_.erase(filesystem_id);
}
diff --git a/webkit/fileapi/isolated_context.h b/webkit/fileapi/isolated_context.h
index 31ed9fc..b4eaadd 100644
--- a/webkit/fileapi/isolated_context.h
+++ b/webkit/fileapi/isolated_context.h
@@ -96,13 +96,6 @@ class FILEAPI_EXPORT IsolatedContext {
FilePath CreateVirtualPath(const std::string& filesystem_id,
const FilePath& relative_path) const;
- // Set the filesystem writable if |writable| is true, non-writable
- // if it is false. Returns false if the |filesystem_id| is not valid.
- bool SetWritable(const std::string& filesystem_id, bool writable);
-
- // Returns true if the |filesystem_id| is writable.
- bool IsWritable(const std::string& filesystem_id) const;
-
private:
friend struct base::DefaultLazyInstanceTraits<IsolatedContext>;
@@ -127,13 +120,6 @@ class FILEAPI_EXPORT IsolatedContext {
// Maps the toplevel entries to the filesystem id.
IDToPathMap toplevel_map_;
- // Holds a set of writable ids.
- // Isolated file systems are created read-only by default, and this set
- // holds a list of exceptions.
- // Detailed filesystem permission may be provided by an external
- // security policy manager, e.g. ChildProcessSecurityPolicy.
- std::set<std::string> writable_ids_;
-
// Reference counts. Note that an isolated filesystem is created with ref==0.
// and will get deleted when the ref count reaches <=0.
std::map<std::string, int> ref_counts_;
diff --git a/webkit/fileapi/isolated_context_unittest.cc b/webkit/fileapi/isolated_context_unittest.cc
index a1b138b..5a828f5 100644
--- a/webkit/fileapi/isolated_context_unittest.cc
+++ b/webkit/fileapi/isolated_context_unittest.cc
@@ -165,28 +165,4 @@ TEST_F(IsolatedContextTest, TestWithVirtualRoot) {
virtual_path, &cracked_id, &root_path, &cracked_path));
}
-TEST_F(IsolatedContextTest, Writable) {
- // By default the file system must be read-only.
- ASSERT_FALSE(isolated_context()->IsWritable(id_));
-
- // Set writable.
- ASSERT_TRUE(isolated_context()->SetWritable(id_, true));
- ASSERT_TRUE(isolated_context()->IsWritable(id_));
-
- // Set non-writable.
- ASSERT_TRUE(isolated_context()->SetWritable(id_, false));
- ASSERT_FALSE(isolated_context()->IsWritable(id_));
-
- // Set writable again, and revoke the filesystem.
- ASSERT_TRUE(isolated_context()->SetWritable(id_, true));
- isolated_context()->RevokeIsolatedFileSystem(id_);
-
- // IsWritable should return false for non-registered file system.
- ASSERT_FALSE(isolated_context()->IsWritable(id_));
- // SetWritable should also return false for non-registered file system
- // (no matter what value we give).
- ASSERT_FALSE(isolated_context()->SetWritable(id_, true));
- ASSERT_FALSE(isolated_context()->SetWritable(id_, false));
-}
-
} // namespace fileapi
diff --git a/webkit/fileapi/isolated_file_util.cc b/webkit/fileapi/isolated_file_util.cc
index bb145b6..6c0bf6a 100644
--- a/webkit/fileapi/isolated_file_util.cc
+++ b/webkit/fileapi/isolated_file_util.cc
@@ -280,7 +280,7 @@ PlatformFileError IsolatedFileUtil::Touch(
const base::Time& last_access_time,
const base::Time& last_modified_time) {
FilePath platform_path;
- if (!GetPlatformPathForWrite(url, &platform_path) || platform_path.empty())
+ if (!GetPlatformPath(url, &platform_path) || platform_path.empty())
return base::PLATFORM_FILE_ERROR_SECURITY;
return NativeFileUtil::Touch(
platform_path, last_access_time, last_modified_time);
@@ -291,7 +291,7 @@ PlatformFileError IsolatedFileUtil::Truncate(
const FileSystemURL& url,
int64 length) {
FilePath platform_path;
- if (!GetPlatformPathForWrite(url, &platform_path) || platform_path.empty())
+ if (!GetPlatformPath(url, &platform_path) || platform_path.empty())
return base::PLATFORM_FILE_ERROR_SECURITY;
return NativeFileUtil::Truncate(platform_path, length);
}
@@ -380,16 +380,4 @@ bool IsolatedFileUtil::GetPlatformPath(const FileSystemURL& url,
return true;
}
-bool IsolatedFileUtil::GetPlatformPathForWrite(
- const FileSystemURL& url,
- FilePath* platform_path) const {
- DCHECK(platform_path);
- std::string filesystem_id;
- FilePath root_path;
- if (!IsolatedContext::GetInstance()->CrackIsolatedPath(
- url.path(), &filesystem_id, &root_path, platform_path))
- return false;
- return IsolatedContext::GetInstance()->IsWritable(filesystem_id);
-}
-
} // namespace
diff --git a/webkit/fileapi/isolated_file_util.h b/webkit/fileapi/isolated_file_util.h
index b95146b..1d708a6 100644
--- a/webkit/fileapi/isolated_file_util.h
+++ b/webkit/fileapi/isolated_file_util.h
@@ -94,12 +94,6 @@ class FILEAPI_EXPORT_PRIVATE IsolatedFileUtil : public FileSystemFileUtil {
// Returns false if the given |url| is not a valid path.
bool GetPlatformPath(const FileSystemURL& url,
FilePath* platform_path) const;
-
- // Returns false if the given |url| is not a valid path, or
- // the file system is not writable.
- bool GetPlatformPathForWrite(const FileSystemURL& url,
- FilePath* platform_path) const;
-
DISALLOW_COPY_AND_ASSIGN(IsolatedFileUtil);
};
diff --git a/webkit/fileapi/isolated_file_util_unittest.cc b/webkit/fileapi/isolated_file_util_unittest.cc
index fb54edd..dff0baf 100644
--- a/webkit/fileapi/isolated_file_util_unittest.cc
+++ b/webkit/fileapi/isolated_file_util_unittest.cc
@@ -466,15 +466,6 @@ TEST_F(IsolatedFileUtilTest, TouchTest) {
base::Time last_access_time = base::Time::FromTimeT(1000);
base::Time last_modified_time = base::Time::FromTimeT(2000);
- // Set the filesystem non-writable and try calling Touch.
- ASSERT_TRUE(isolated_context()->SetWritable(filesystem_id(), false));
- EXPECT_EQ(base::PLATFORM_FILE_ERROR_SECURITY,
- file_util()->Touch(GetOperationContext().get(), url,
- last_access_time,
- last_modified_time));
-
- // Set the filesystem writable and try calling Touch.
- ASSERT_TRUE(isolated_context()->SetWritable(filesystem_id(), true));
EXPECT_EQ(base::PLATFORM_FILE_OK,
file_util()->Touch(GetOperationContext().get(), url,
last_access_time,
@@ -500,18 +491,9 @@ TEST_F(IsolatedFileUtilTest, TruncateTest) {
SCOPED_TRACE(testing::Message() << test_case.path);
FileSystemURL url = GetFileSystemURL(FilePath(test_case.path));
- // Set the filesystem non-writable and try calling Truncate.
- ASSERT_TRUE(isolated_context()->SetWritable(filesystem_id(), false));
- EXPECT_EQ(base::PLATFORM_FILE_ERROR_SECURITY,
- file_util()->Truncate(GetOperationContext().get(), url, 0));
-
+ // Truncate to 0.
base::PlatformFileInfo info;
FilePath platform_path;
-
- // Set the filesystem writable.
- ASSERT_TRUE(isolated_context()->SetWritable(filesystem_id(), true));
-
- // Truncate to 0.
EXPECT_EQ(base::PLATFORM_FILE_OK,
file_util()->Truncate(GetOperationContext().get(), url, 0));
ASSERT_EQ(base::PLATFORM_FILE_OK,
diff --git a/webkit/fileapi/isolated_mount_point_provider.cc b/webkit/fileapi/isolated_mount_point_provider.cc
index 537885e..d2055d8 100644
--- a/webkit/fileapi/isolated_mount_point_provider.cc
+++ b/webkit/fileapi/isolated_mount_point_provider.cc
@@ -31,15 +31,13 @@ IsolatedContext* isolated_context() {
return IsolatedContext::GetInstance();
}
-FilePath GetPathFromURL(const FileSystemURL& url, bool for_writing) {
+FilePath GetPathFromURL(const FileSystemURL& url) {
if (!url.is_valid() || url.type() != kFileSystemTypeIsolated)
return FilePath();
std::string fsid;
FilePath path;
if (!isolated_context()->CrackIsolatedPath(url.path(), &fsid, NULL, &path))
return FilePath();
- if (for_writing && !isolated_context()->IsWritable(fsid))
- return FilePath();
return path;
}
@@ -118,7 +116,7 @@ IsolatedMountPointProvider::CreateFileStreamReader(
const FileSystemURL& url,
int64 offset,
FileSystemContext* context) const {
- FilePath path = GetPathFromURL(url, false);
+ FilePath path = GetPathFromURL(url);
return path.empty() ? NULL : new webkit_blob::LocalFileStreamReader(
context->file_task_runner(), path, offset, base::Time());
}
@@ -127,7 +125,7 @@ FileStreamWriter* IsolatedMountPointProvider::CreateFileStreamWriter(
const FileSystemURL& url,
int64 offset,
FileSystemContext* context) const {
- FilePath path = GetPathFromURL(url, true);
+ FilePath path = GetPathFromURL(url);
return path.empty() ? NULL : new LocalFileStreamWriter(path, offset);
}
diff --git a/webkit/tools/test_shell/simple_file_system.cc b/webkit/tools/test_shell/simple_file_system.cc
index f9a656d..1400ebd 100644
--- a/webkit/tools/test_shell/simple_file_system.cc
+++ b/webkit/tools/test_shell/simple_file_system.cc
@@ -120,65 +120,112 @@ void SimpleFileSystem::OpenFileSystem(
void SimpleFileSystem::move(
const WebURL& src_path,
const WebURL& dest_path, WebFileSystemCallbacks* callbacks) {
- GetNewOperation(src_path)->Move(FileSystemURL(src_path),
- FileSystemURL(dest_path),
- FinishHandler(callbacks));
+ FileSystemURL src_url(src_path);
+ FileSystemURL dest_url(dest_path);
+ if (!HasFilePermission(src_url, FILE_PERMISSION_WRITE) ||
+ !HasFilePermission(dest_url, FILE_PERMISSION_CREATE)) {
+ callbacks->didFail(WebKit::WebFileErrorSecurity);
+ return;
+ }
+ GetNewOperation(src_url)->Move(src_url, dest_url,
+ FinishHandler(callbacks));
}
void SimpleFileSystem::copy(
const WebURL& src_path, const WebURL& dest_path,
WebFileSystemCallbacks* callbacks) {
- GetNewOperation(src_path)->Copy(FileSystemURL(src_path),
- FileSystemURL(dest_path),
- FinishHandler(callbacks));
+ FileSystemURL src_url(src_path);
+ FileSystemURL dest_url(dest_path);
+ if (!HasFilePermission(src_url, FILE_PERMISSION_READ) ||
+ !HasFilePermission(dest_url, FILE_PERMISSION_CREATE)) {
+ callbacks->didFail(WebKit::WebFileErrorSecurity);
+ return;
+ }
+ GetNewOperation(src_url)->Copy(src_url, dest_url,
+ FinishHandler(callbacks));
}
void SimpleFileSystem::remove(
const WebURL& path, WebFileSystemCallbacks* callbacks) {
- GetNewOperation(path)->Remove(FileSystemURL(path), false /* recursive */,
- FinishHandler(callbacks));
+ FileSystemURL url(path);
+ if (!HasFilePermission(url, FILE_PERMISSION_WRITE)) {
+ callbacks->didFail(WebKit::WebFileErrorSecurity);
+ return;
+ }
+ GetNewOperation(url)->Remove(url, false /* recursive */,
+ FinishHandler(callbacks));
}
void SimpleFileSystem::removeRecursively(
const WebURL& path, WebFileSystemCallbacks* callbacks) {
- GetNewOperation(path)->Remove(FileSystemURL(path), true /* recursive */,
- FinishHandler(callbacks));
+ FileSystemURL url(path);
+ if (!HasFilePermission(url, FILE_PERMISSION_WRITE)) {
+ callbacks->didFail(WebKit::WebFileErrorSecurity);
+ return;
+ }
+ GetNewOperation(url)->Remove(url, true /* recursive */,
+ FinishHandler(callbacks));
}
void SimpleFileSystem::readMetadata(
const WebURL& path, WebFileSystemCallbacks* callbacks) {
- GetNewOperation(path)->GetMetadata(FileSystemURL(path),
- GetMetadataHandler(callbacks));
+ FileSystemURL url(path);
+ if (!HasFilePermission(url, FILE_PERMISSION_READ)) {
+ callbacks->didFail(WebKit::WebFileErrorSecurity);
+ return;
+ }
+ GetNewOperation(url)->GetMetadata(url, GetMetadataHandler(callbacks));
}
void SimpleFileSystem::createFile(
const WebURL& path, bool exclusive, WebFileSystemCallbacks* callbacks) {
- GetNewOperation(path)->CreateFile(FileSystemURL(path), exclusive,
- FinishHandler(callbacks));
+ FileSystemURL url(path);
+ if (!HasFilePermission(url, FILE_PERMISSION_CREATE)) {
+ callbacks->didFail(WebKit::WebFileErrorSecurity);
+ return;
+ }
+ GetNewOperation(url)->CreateFile(url, exclusive, FinishHandler(callbacks));
}
void SimpleFileSystem::createDirectory(
const WebURL& path, bool exclusive, WebFileSystemCallbacks* callbacks) {
- GetNewOperation(path)->CreateDirectory(FileSystemURL(path), exclusive, false,
- FinishHandler(callbacks));
+ FileSystemURL url(path);
+ if (!HasFilePermission(url, FILE_PERMISSION_CREATE)) {
+ callbacks->didFail(WebKit::WebFileErrorSecurity);
+ return;
+ }
+ GetNewOperation(url)->CreateDirectory(url, exclusive, false,
+ FinishHandler(callbacks));
}
void SimpleFileSystem::fileExists(
const WebURL& path, WebFileSystemCallbacks* callbacks) {
- GetNewOperation(path)->FileExists(FileSystemURL(path),
- FinishHandler(callbacks));
+ FileSystemURL url(path);
+ if (!HasFilePermission(url, FILE_PERMISSION_READ)) {
+ callbacks->didFail(WebKit::WebFileErrorSecurity);
+ return;
+ }
+ GetNewOperation(url)->FileExists(url, FinishHandler(callbacks));
}
void SimpleFileSystem::directoryExists(
const WebURL& path, WebFileSystemCallbacks* callbacks) {
- GetNewOperation(path)->DirectoryExists(FileSystemURL(path),
- FinishHandler(callbacks));
+ FileSystemURL url(path);
+ if (!HasFilePermission(url, FILE_PERMISSION_READ)) {
+ callbacks->didFail(WebKit::WebFileErrorSecurity);
+ return;
+ }
+ GetNewOperation(url)->DirectoryExists(url, FinishHandler(callbacks));
}
void SimpleFileSystem::readDirectory(
const WebURL& path, WebFileSystemCallbacks* callbacks) {
- GetNewOperation(path)->ReadDirectory(FileSystemURL(path),
- ReadDirectoryHandler(callbacks));
+ FileSystemURL url(path);
+ if (!HasFilePermission(url, FILE_PERMISSION_READ)) {
+ callbacks->didFail(WebKit::WebFileErrorSecurity);
+ return;
+ }
+ GetNewOperation(url)->ReadDirectory(url, ReadDirectoryHandler(callbacks));
}
WebFileWriter* SimpleFileSystem::createFileWriter(
@@ -190,8 +237,13 @@ void SimpleFileSystem::createSnapshotFileAndReadMetadata(
const WebURL& blobURL,
const WebURL& path,
WebFileSystemCallbacks* callbacks) {
- GetNewOperation(path)->CreateSnapshotFile(
- FileSystemURL(path), SnapshotFileHandler(blobURL, callbacks));
+ FileSystemURL url(path);
+ if (!HasFilePermission(url, FILE_PERMISSION_READ)) {
+ callbacks->didFail(WebKit::WebFileErrorSecurity);
+ return;
+ }
+ GetNewOperation(url)->CreateSnapshotFile(
+ url, SnapshotFileHandler(blobURL, callbacks));
}
// static
@@ -207,9 +259,16 @@ void SimpleFileSystem::CleanupOnIOThread() {
g_blob_storage_controller = NULL;
}
+bool SimpleFileSystem::HasFilePermission(
+ const fileapi::FileSystemURL& url, FilePermission permission) {
+ // Disallow writing on isolated file system, otherwise return ok.
+ return (url.type() != fileapi::kFileSystemTypeIsolated ||
+ permission == FILE_PERMISSION_READ);
+}
+
FileSystemOperationInterface* SimpleFileSystem::GetNewOperation(
- const WebURL& url) {
- return file_system_context_->CreateFileSystemOperation(FileSystemURL(url));
+ const fileapi::FileSystemURL& url) {
+ return file_system_context_->CreateFileSystemOperation(url);
}
FileSystemOperationInterface::StatusCallback
diff --git a/webkit/tools/test_shell/simple_file_system.h b/webkit/tools/test_shell/simple_file_system.h
index c9d1fc1..a4d1e12 100644
--- a/webkit/tools/test_shell/simple_file_system.h
+++ b/webkit/tools/test_shell/simple_file_system.h
@@ -23,6 +23,7 @@ class WebURL;
namespace fileapi {
class FileSystemContext;
+class FileSystemURL;
}
namespace webkit_blob {
@@ -93,9 +94,17 @@ class SimpleFileSystem
static void CleanupOnIOThread();
private:
+ enum FilePermission {
+ FILE_PERMISSION_READ,
+ FILE_PERMISSION_WRITE,
+ FILE_PERMISSION_CREATE,
+ };
+
// Helpers.
+ bool HasFilePermission(const fileapi::FileSystemURL& url,
+ FilePermission permission);
fileapi::FileSystemOperationInterface* GetNewOperation(
- const WebKit::WebURL& path);
+ const fileapi::FileSystemURL& url);
// Callback Handlers
fileapi::FileSystemOperationInterface::StatusCallback FinishHandler(
diff --git a/webkit/tools/test_shell/simple_file_writer.cc b/webkit/tools/test_shell/simple_file_writer.cc
index 2d6b022..bf48185 100644
--- a/webkit/tools/test_shell/simple_file_writer.cc
+++ b/webkit/tools/test_shell/simple_file_writer.cc
@@ -11,6 +11,7 @@
#include "net/url_request/url_request_context.h"
#include "webkit/fileapi/file_system_context.h"
#include "webkit/fileapi/file_system_operation_interface.h"
+#include "webkit/fileapi/file_system_types.h"
#include "webkit/fileapi/file_system_url.h"
#include "webkit/glue/webkit_glue.h"
#include "webkit/tools/test_shell/simple_resource_loader_bridge.h"
@@ -42,30 +43,34 @@ class SimpleFileWriter::IOThreadProxy
main_thread_ = base::MessageLoopProxy::current();
}
- void Truncate(const GURL& path, int64 offset) {
+ void Truncate(const FileSystemURL& url, int64 offset) {
if (!io_thread_->BelongsToCurrentThread()) {
io_thread_->PostTask(
FROM_HERE,
- base::Bind(&IOThreadProxy::Truncate, this, path, offset));
+ base::Bind(&IOThreadProxy::Truncate, this, url, offset));
return;
}
+ if (FailIfNotWritable(url))
+ return;
DCHECK(!operation_);
- operation_ = GetNewOperation(path);
- operation_->Truncate(FileSystemURL(path), offset,
+ operation_ = GetNewOperation(url);
+ operation_->Truncate(url, offset,
base::Bind(&IOThreadProxy::DidFinish, this));
}
- void Write(const GURL& path, const GURL& blob_url, int64 offset) {
+ void Write(const FileSystemURL& url, const GURL& blob_url, int64 offset) {
if (!io_thread_->BelongsToCurrentThread()) {
io_thread_->PostTask(
FROM_HERE,
- base::Bind(&IOThreadProxy::Write, this, path, blob_url, offset));
+ base::Bind(&IOThreadProxy::Write, this, url, blob_url, offset));
return;
}
+ if (FailIfNotWritable(url))
+ return;
DCHECK(request_context_);
DCHECK(!operation_);
- operation_ = GetNewOperation(path);
- operation_->Write(request_context_, FileSystemURL(path), blob_url, offset,
+ operation_ = GetNewOperation(url);
+ operation_->Write(request_context_, url, blob_url, offset,
base::Bind(&IOThreadProxy::DidWrite, this));
}
@@ -87,8 +92,18 @@ class SimpleFileWriter::IOThreadProxy
friend class base::RefCountedThreadSafe<IOThreadProxy>;
virtual ~IOThreadProxy() {}
- FileSystemOperationInterface* GetNewOperation(const GURL& path) {
- return file_system_context_->CreateFileSystemOperation(FileSystemURL(path));
+ FileSystemOperationInterface* GetNewOperation( const FileSystemURL& url) {
+ return file_system_context_->CreateFileSystemOperation(url);
+ }
+
+ // Returns true if it is not writable.
+ bool FailIfNotWritable(const FileSystemURL& url) {
+ if (url.type() == fileapi::kFileSystemTypeIsolated) {
+ // Write is not allowed in isolate file system in SimpleFileWriter.
+ DidFailOnMainThread(base::PLATFORM_FILE_ERROR_SECURITY);
+ return true;
+ }
+ return false;
}
void DidSucceedOnMainThread() {
@@ -174,12 +189,14 @@ SimpleFileWriter::~SimpleFileWriter() {
}
void SimpleFileWriter::DoTruncate(const GURL& path, int64 offset) {
- io_thread_proxy_->Truncate(path, offset);
+ FileSystemURL url(path);
+ io_thread_proxy_->Truncate(url, offset);
}
void SimpleFileWriter::DoWrite(
const GURL& path, const GURL& blob_url, int64 offset) {
- io_thread_proxy_->Write(path, blob_url, offset);
+ FileSystemURL url(path);
+ io_thread_proxy_->Write(url, blob_url, offset);
}
void SimpleFileWriter::DoCancel() {