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

Unified Diff: webkit/fileapi/file_system_file_util_proxy.cc

Issue 7433006: Pepper quota support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updated Created 9 years, 5 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/fileapi/file_system_file_util_proxy.cc
diff --git a/webkit/fileapi/file_system_file_util_proxy.cc b/webkit/fileapi/file_system_file_util_proxy.cc
index dd8659585e01d2f28588b037d9fc8b522001845e..64ef8fdf2199a6470de17e011f53c0d77b5aea2b 100644
--- a/webkit/fileapi/file_system_file_util_proxy.cc
+++ b/webkit/fileapi/file_system_file_util_proxy.cc
@@ -72,9 +72,9 @@ class MessageLoopRelay
fileapi::FileSystemFileUtil* file_system_file_util_;
};
-class RelayCreateOrOpen : public MessageLoopRelay {
+class RelayCreateOrOpenAndQuerySize : public MessageLoopRelay {
public:
- RelayCreateOrOpen(
+ RelayCreateOrOpenAndQuerySize(
const fileapi::FileSystemOperationContext& context,
scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
const FilePath& file_path,
@@ -84,6 +84,7 @@ class RelayCreateOrOpen : public MessageLoopRelay {
message_loop_proxy_(message_loop_proxy),
file_path_(file_path),
file_flags_(file_flags),
+ file_size_(-1),
callback_(callback),
file_handle_(base::kInvalidPlatformFileValue),
created_(false) {
@@ -91,21 +92,34 @@ class RelayCreateOrOpen : public MessageLoopRelay {
}
protected:
- virtual ~RelayCreateOrOpen() {
+ virtual ~RelayCreateOrOpenAndQuerySize() {
if (file_handle_ != base::kInvalidPlatformFileValue)
fileapi::FileSystemFileUtilProxy::Close(*context(),
message_loop_proxy_, file_handle_, NULL);
}
virtual void RunWork() {
- set_error_code(
- file_system_file_util()->CreateOrOpen(
- context(), file_path_, file_flags_, &file_handle_, &created_));
+ file_size_ = -1;
+ base::PlatformFileError error;
+ error = file_system_file_util()->CreateOrOpen(
+ context(), file_path_, file_flags_, &file_handle_, &created_);
+ if (error == base::PLATFORM_FILE_OK) {
+ if (created_) {
+ file_size_ = 0;
+ } else {
+ base::PlatformFileInfo file_info;
+ FilePath platform_path;
+ error = file_system_file_util()->GetFileInfo(
+ context(), file_path_, &file_info, &platform_path);
+ file_size_ = file_info.size;
+ }
+ }
+ set_error_code(error);
}
virtual void RunCallback() {
callback_->Run(error_code(), base::PassPlatformFile(&file_handle_),
- created_);
+ created_, file_size_);
delete callback_;
}
@@ -113,6 +127,7 @@ class RelayCreateOrOpen : public MessageLoopRelay {
scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
FilePath file_path_;
int file_flags_;
+ int file_size_;
fileapi::FileSystemFileUtilProxy::CreateOrOpenCallback* callback_;
base::PlatformFile file_handle_;
bool created_;
@@ -441,13 +456,14 @@ bool Start(const tracked_objects::Location& from_here,
namespace fileapi {
// static
-bool FileSystemFileUtilProxy::CreateOrOpen(
+bool FileSystemFileUtilProxy::CreateOrOpenAndQuerySize(
const FileSystemOperationContext& context,
scoped_refptr<MessageLoopProxy> message_loop_proxy,
const FilePath& file_path, int file_flags,
CreateOrOpenCallback* callback) {
- return Start(FROM_HERE, message_loop_proxy, new RelayCreateOrOpen(context,
- message_loop_proxy, file_path, file_flags, callback));
+ return Start(FROM_HERE, message_loop_proxy,
+ new RelayCreateOrOpenAndQuerySize(context,
+ message_loop_proxy, file_path, file_flags, callback));
}
// static

Powered by Google App Engine
This is Rietveld 408576698