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

Unified Diff: storage/browser/database/vfs_backend.cc

Issue 1006423008: Add SetFileSize() IPC for WebSQL. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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: storage/browser/database/vfs_backend.cc
diff --git a/storage/browser/database/vfs_backend.cc b/storage/browser/database/vfs_backend.cc
index 1f8c97bfc0022efd379adec80a8234f577394042..214eada628b8f470b1115f09d3d8d5b861596d03 100644
--- a/storage/browser/database/vfs_backend.cc
+++ b/storage/browser/database/vfs_backend.cc
@@ -155,4 +155,19 @@ 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) {
+ // TODO(shess): Is there a base::File sitting around to do this? Otherwise it
michaeln 2015/03/19 00:36:33 There is not, IPC::TakeFileHandleForProcess(file.P
michaeln 2015/04/01 21:04:48 Except for incognito profiles.
Scott Hess - ex-Googler 2015/04/01 22:42:20 Seems like I should change the comment either way
+ // might make sense to expose truncate() somewhere rather than having to open
+ // a file.
+ 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);
michaeln 2015/03/19 00:36:33 Depending on when/how xTruncate is used, seems lik
Scott Hess - ex-Googler 2015/03/25 20:24:23 On POSIX, locks are advisory only, so the file des
+ if (!file.IsValid())
+ return false;
+ return file.SetLength(size);
+}
+
} // namespace storage
« content/renderer/renderer_blink_platform_impl.h ('K') | « storage/browser/database/vfs_backend.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698