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

Unified Diff: webkit/fileapi/file_writer_delegate.cc

Issue 7433006: Pepper quota support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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_writer_delegate.cc
diff --git a/webkit/fileapi/file_writer_delegate.cc b/webkit/fileapi/file_writer_delegate.cc
index 4bb1f9ba8a41f97f1c9bd1cc3bd04bd4a7087f95..1ddd6c9ac0e5bcbdfafe51b8949d03e95f5ceae3 100644
--- a/webkit/fileapi/file_writer_delegate.cc
+++ b/webkit/fileapi/file_writer_delegate.cc
@@ -19,68 +19,6 @@ namespace fileapi {
static const int kReadBufSize = 32768;
-namespace {
-
-typedef Callback2<base::PlatformFileError /* error code */,
- const base::PlatformFileInfo& /* file_info */
- >::Type InitializeTaskCallback;
-
-class InitializeTask : public base::RefCountedThreadSafe<InitializeTask> {
- public:
- InitializeTask(
- base::PlatformFile file,
- FileSystemOperationContext* context,
- InitializeTaskCallback* callback)
- : origin_message_loop_proxy_(
- base::MessageLoopProxy::CreateForCurrentThread()),
- error_code_(base::PLATFORM_FILE_OK),
- file_(file),
- context_(*context),
- callback_(callback) {
- DCHECK(callback);
- }
-
- bool Start(scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
- const tracked_objects::Location& from_here) {
- return message_loop_proxy->PostTask(from_here, NewRunnableMethod(this,
- &InitializeTask::ProcessOnTargetThread));
- }
-
- private:
- friend class base::RefCountedThreadSafe<InitializeTask>;
-
- void RunCallback() {
- callback_->Run(error_code_, file_info_);
- delete callback_;
- }
-
- void ProcessOnTargetThread() {
- DCHECK(context_.file_system_context());
- FileSystemQuotaUtil* quota_util = context_.file_system_context()->
- GetQuotaUtil(context_.src_type());
- if (quota_util) {
- DCHECK(quota_util->proxy());
- quota_util->proxy()->StartUpdateOrigin(
- context_.src_origin_url(), context_.src_type());
- }
- if (!base::GetPlatformFileInfo(file_, &file_info_))
- error_code_ = base::PLATFORM_FILE_ERROR_FAILED;
- origin_message_loop_proxy_->PostTask(FROM_HERE, NewRunnableMethod(this,
- &InitializeTask::RunCallback));
- }
-
- scoped_refptr<base::MessageLoopProxy> origin_message_loop_proxy_;
- base::PlatformFileError error_code_;
-
- base::PlatformFile file_;
- FileSystemOperationContext context_;
- InitializeTaskCallback* callback_;
-
- base::PlatformFileInfo file_info_;
-};
-
-} // namespace (anonymous)
-
FileWriterDelegate::FileWriterDelegate(
FileSystemOperation* file_system_operation, int64 offset,
scoped_refptr<base::MessageLoopProxy> proxy)
@@ -103,13 +41,24 @@ FileWriterDelegate::FileWriterDelegate(
FileWriterDelegate::~FileWriterDelegate() {
}
-void FileWriterDelegate::OnGetFileInfoAndCallStartUpdate(
- base::PlatformFileError error,
- const base::PlatformFileInfo& file_info) {
- if (error) {
- OnError(error);
- return;
+void FileWriterDelegate::Start(base::PlatformFile file,
+ int64 file_size,
+ net::URLRequest* request) {
+ file_ = file;
+ size_ = file_size;
+ request_ = request;
+
+ DCHECK(file_system_operation_);
+ FileSystemQuotaUtil* quota_util =
+ file_system_operation_->file_system_context()->GetQuotaUtil(
+ file_system_operation_context()->src_type());
+ if (quota_util) {
+ DCHECK(quota_util->proxy());
+ quota_util->proxy()->StartUpdateOrigin(
+ file_system_operation_context()->src_origin_url(),
+ file_system_operation_context()->src_type());
}
+
int64 allowed_bytes_growth =
file_system_operation_context()->allowed_bytes_growth();
if (allowed_bytes_growth == QuotaFileUtil::kNoLimit ||
@@ -123,27 +72,14 @@ void FileWriterDelegate::OnGetFileInfoAndCallStartUpdate(
} else {
if (allowed_bytes_growth < 0)
allowed_bytes_growth = 0;
- allowed_bytes_to_write_ = file_info.size - offset_ + allowed_bytes_growth;
+ allowed_bytes_to_write_ = file_size - offset_ + allowed_bytes_growth;
}
- size_ = file_info.size;
file_stream_.reset(new net::FileStream(file_,
base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_WRITE |
base::PLATFORM_FILE_ASYNC));
request_->Start();
}
-void FileWriterDelegate::Start(base::PlatformFile file,
- net::URLRequest* request) {
- file_ = file;
- request_ = request;
-
- scoped_refptr<InitializeTask> relay = new InitializeTask(
- file_, file_system_operation_context(),
- callback_factory_.NewCallback(
- &FileWriterDelegate::OnGetFileInfoAndCallStartUpdate));
- relay->Start(proxy_, FROM_HERE);
-}
-
void FileWriterDelegate::OnReceivedRedirect(
net::URLRequest* request, const GURL& new_url, bool* defer_redirect) {
NOTREACHED();

Powered by Google App Engine
This is Rietveld 408576698