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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/fileapi/file_system_file_util_proxy.h" 5 #include "webkit/fileapi/file_system_file_util_proxy.h"
6 6
7 #include "base/message_loop_proxy.h" 7 #include "base/message_loop_proxy.h"
8 #include "webkit/fileapi/file_system_context.h" 8 #include "webkit/fileapi/file_system_context.h"
9 #include "webkit/fileapi/file_system_file_util.h" 9 #include "webkit/fileapi/file_system_file_util.h"
10 #include "webkit/fileapi/file_system_operation_context.h" 10 #include "webkit/fileapi/file_system_operation_context.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 FROM_HERE, 65 FROM_HERE,
66 NewRunnableMethod(this, &MessageLoopRelay::RunCallback)); 66 NewRunnableMethod(this, &MessageLoopRelay::RunCallback));
67 } 67 }
68 68
69 scoped_refptr<base::MessageLoopProxy> origin_message_loop_proxy_; 69 scoped_refptr<base::MessageLoopProxy> origin_message_loop_proxy_;
70 base::PlatformFileError error_code_; 70 base::PlatformFileError error_code_;
71 fileapi::FileSystemOperationContext context_; 71 fileapi::FileSystemOperationContext context_;
72 fileapi::FileSystemFileUtil* file_system_file_util_; 72 fileapi::FileSystemFileUtil* file_system_file_util_;
73 }; 73 };
74 74
75 class RelayCreateOrOpen : public MessageLoopRelay { 75 class RelayCreateOrOpenAndQuerySize : public MessageLoopRelay {
76 public: 76 public:
77 RelayCreateOrOpen( 77 RelayCreateOrOpenAndQuerySize(
78 const fileapi::FileSystemOperationContext& context, 78 const fileapi::FileSystemOperationContext& context,
79 scoped_refptr<base::MessageLoopProxy> message_loop_proxy, 79 scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
80 const FilePath& file_path, 80 const FilePath& file_path,
81 int file_flags, 81 int file_flags,
82 fileapi::FileSystemFileUtilProxy::CreateOrOpenCallback* callback) 82 fileapi::FileSystemFileUtilProxy::CreateOrOpenCallback* callback)
83 : MessageLoopRelay(context), 83 : MessageLoopRelay(context),
84 message_loop_proxy_(message_loop_proxy), 84 message_loop_proxy_(message_loop_proxy),
85 file_path_(file_path), 85 file_path_(file_path),
86 file_flags_(file_flags), 86 file_flags_(file_flags),
87 file_size_(-1),
87 callback_(callback), 88 callback_(callback),
88 file_handle_(base::kInvalidPlatformFileValue), 89 file_handle_(base::kInvalidPlatformFileValue),
89 created_(false) { 90 created_(false) {
90 DCHECK(callback); 91 DCHECK(callback);
91 } 92 }
92 93
93 protected: 94 protected:
94 virtual ~RelayCreateOrOpen() { 95 virtual ~RelayCreateOrOpenAndQuerySize() {
95 if (file_handle_ != base::kInvalidPlatformFileValue) 96 if (file_handle_ != base::kInvalidPlatformFileValue)
96 fileapi::FileSystemFileUtilProxy::Close(*context(), 97 fileapi::FileSystemFileUtilProxy::Close(*context(),
97 message_loop_proxy_, file_handle_, NULL); 98 message_loop_proxy_, file_handle_, NULL);
98 } 99 }
99 100
100 virtual void RunWork() { 101 virtual void RunWork() {
101 set_error_code( 102 file_size_ = -1;
102 file_system_file_util()->CreateOrOpen( 103 base::PlatformFileError error;
103 context(), file_path_, file_flags_, &file_handle_, &created_)); 104 error = file_system_file_util()->CreateOrOpen(
105 context(), file_path_, file_flags_, &file_handle_, &created_);
106 if (error == base::PLATFORM_FILE_OK) {
107 if (created_) {
108 file_size_ = 0;
109 } else {
110 base::PlatformFileInfo file_info;
111 FilePath platform_path;
112 error = file_system_file_util()->GetFileInfo(
113 context(), file_path_, &file_info, &platform_path);
114 file_size_ = file_info.size;
115 }
116 }
117 set_error_code(error);
104 } 118 }
105 119
106 virtual void RunCallback() { 120 virtual void RunCallback() {
107 callback_->Run(error_code(), base::PassPlatformFile(&file_handle_), 121 callback_->Run(error_code(), base::PassPlatformFile(&file_handle_),
108 created_); 122 created_, file_size_);
109 delete callback_; 123 delete callback_;
110 } 124 }
111 125
112 private: 126 private:
113 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; 127 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
114 FilePath file_path_; 128 FilePath file_path_;
115 int file_flags_; 129 int file_flags_;
130 int file_size_;
116 fileapi::FileSystemFileUtilProxy::CreateOrOpenCallback* callback_; 131 fileapi::FileSystemFileUtilProxy::CreateOrOpenCallback* callback_;
117 base::PlatformFile file_handle_; 132 base::PlatformFile file_handle_;
118 bool created_; 133 bool created_;
119 }; 134 };
120 135
121 class RelayWithStatusCallback : public MessageLoopRelay { 136 class RelayWithStatusCallback : public MessageLoopRelay {
122 public: 137 public:
123 RelayWithStatusCallback( 138 RelayWithStatusCallback(
124 const fileapi::FileSystemOperationContext& context, 139 const fileapi::FileSystemOperationContext& context,
125 fileapi::FileSystemFileUtilProxy::StatusCallback* callback) 140 fileapi::FileSystemFileUtilProxy::StatusCallback* callback)
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 scoped_refptr<base::MessageLoopProxy> message_loop_proxy, 449 scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
435 scoped_refptr<MessageLoopRelay> relay) { 450 scoped_refptr<MessageLoopRelay> relay) {
436 return relay->Start(message_loop_proxy, from_here); 451 return relay->Start(message_loop_proxy, from_here);
437 } 452 }
438 453
439 } // namespace 454 } // namespace
440 455
441 namespace fileapi { 456 namespace fileapi {
442 457
443 // static 458 // static
444 bool FileSystemFileUtilProxy::CreateOrOpen( 459 bool FileSystemFileUtilProxy::CreateOrOpenAndQuerySize(
445 const FileSystemOperationContext& context, 460 const FileSystemOperationContext& context,
446 scoped_refptr<MessageLoopProxy> message_loop_proxy, 461 scoped_refptr<MessageLoopProxy> message_loop_proxy,
447 const FilePath& file_path, int file_flags, 462 const FilePath& file_path, int file_flags,
448 CreateOrOpenCallback* callback) { 463 CreateOrOpenCallback* callback) {
449 return Start(FROM_HERE, message_loop_proxy, new RelayCreateOrOpen(context, 464 return Start(FROM_HERE, message_loop_proxy,
450 message_loop_proxy, file_path, file_flags, callback)); 465 new RelayCreateOrOpenAndQuerySize(context,
466 message_loop_proxy, file_path, file_flags, callback));
451 } 467 }
452 468
453 // static 469 // static
454 bool FileSystemFileUtilProxy::Close( 470 bool FileSystemFileUtilProxy::Close(
455 const FileSystemOperationContext& context, 471 const FileSystemOperationContext& context,
456 scoped_refptr<MessageLoopProxy> message_loop_proxy, 472 scoped_refptr<MessageLoopProxy> message_loop_proxy,
457 base::PlatformFile file_handle, 473 base::PlatformFile file_handle,
458 StatusCallback* callback) { 474 StatusCallback* callback) {
459 return Start(FROM_HERE, message_loop_proxy, 475 return Start(FROM_HERE, message_loop_proxy,
460 new RelayClose(context, file_handle, callback)); 476 new RelayClose(context, file_handle, callback));
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 const FileSystemOperationContext& context, 581 const FileSystemOperationContext& context,
566 scoped_refptr<MessageLoopProxy> message_loop_proxy, 582 scoped_refptr<MessageLoopProxy> message_loop_proxy,
567 const FilePath& path, 583 const FilePath& path,
568 int64 length, 584 int64 length,
569 StatusCallback* callback) { 585 StatusCallback* callback) {
570 return Start(FROM_HERE, message_loop_proxy, 586 return Start(FROM_HERE, message_loop_proxy,
571 new RelayTruncate(context, path, length, callback)); 587 new RelayTruncate(context, path, length, callback));
572 } 588 }
573 589
574 } // namespace fileapi 590 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698