summaryrefslogtreecommitdiffstats
path: root/storage
diff options
context:
space:
mode:
authorshess <shess@chromium.org>2015-04-06 11:52:16 -0700
committerCommit bot <commit-bot@chromium.org>2015-04-06 18:52:57 +0000
commit10ce3cc97b63b6e2a294f8279490e91ed22f06f4 (patch)
tree8e0f9c13b28681ecf1be9257af6c56fcf01eab41 /storage
parentc02ea23b81f95b4161a395d6b229cd680de63375 (diff)
downloadchromium_src-10ce3cc97b63b6e2a294f8279490e91ed22f06f4.zip
chromium_src-10ce3cc97b63b6e2a294f8279490e91ed22f06f4.tar.gz
chromium_src-10ce3cc97b63b6e2a294f8279490e91ed22f06f4.tar.bz2
Add SetFileSize() IPC for WebSQL.
The sandbox on OSX and Linux restricts ftruncate(), which SQLite uses. Provide a browser hook for chromium_vfs. BUG=457905 Review URL: https://codereview.chromium.org/1006423008 Cr-Commit-Position: refs/heads/master@{#323925}
Diffstat (limited to 'storage')
-rw-r--r--storage/browser/database/vfs_backend.cc12
-rw-r--r--storage/browser/database/vfs_backend.h2
2 files changed, 14 insertions, 0 deletions
diff --git a/storage/browser/database/vfs_backend.cc b/storage/browser/database/vfs_backend.cc
index 1f8c97b..2cd0246 100644
--- a/storage/browser/database/vfs_backend.cc
+++ b/storage/browser/database/vfs_backend.cc
@@ -155,4 +155,16 @@ int64 VfsBackend::GetFileSize(const base::FilePath& file_path) {
return (base::GetFileSize(file_path, &size) ? size : 0);
}
+// static
+bool VfsBackend::SetFileSize(const base::FilePath& file_path, int64 size) {
+ int flags = 0;
+ flags |= base::File::FLAG_READ;
+ flags |= base::File::FLAG_WRITE;
+ flags |= base::File::FLAG_OPEN;
+ base::File file = base::File(file_path, flags);
+ if (!file.IsValid())
+ return false;
+ return file.SetLength(size);
+}
+
} // namespace storage
diff --git a/storage/browser/database/vfs_backend.h b/storage/browser/database/vfs_backend.h
index 0ee1dd3..2b625d1 100644
--- a/storage/browser/database/vfs_backend.h
+++ b/storage/browser/database/vfs_backend.h
@@ -30,6 +30,8 @@ class STORAGE_EXPORT VfsBackend {
static int64 GetFileSize(const base::FilePath& file_path);
+ static bool SetFileSize(const base::FilePath& file_path, int64 size);
+
// Used to make decisions in the DatabaseDispatcherHost.
static bool OpenTypeIsReadWrite(int desired_flags);