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

Side by Side Diff: webkit/fileapi/file_system_file_util_proxy.cc

Issue 6471019: Stackable file_util for FileAPIs. Sample code for discussion. Incomplete. Cannot be compiled. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fixed the Patch Set 3 before reflecting the comments. -UtilBase can be built and works. Created 9 years, 10 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
« no previous file with comments | « webkit/fileapi/file_system_file_util_proxy.h ('k') | webkit/fileapi/file_system_operation.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "webkit/fileapi/file_system_file_util_proxy.h"
6
7 #include "base/message_loop_proxy.h"
8 #include "webkit/fileapi/file_system_file_util_base.h"
9 #include "webkit/fileapi/file_system_operation_context.h"
10
11 namespace fileapi {
12
13 class MessageLoopRelay
14 : public base::RefCountedThreadSafe<MessageLoopRelay> {
15 public:
16 MessageLoopRelay(FileSystemOperationContext* fs_context)
17 : file_util_(FileSystemFileUtilBase::GetInstance()),
18 fs_context_(fs_context),
19 origin_message_loop_proxy_(
20 base::MessageLoopProxy::CreateForCurrentThread()),
21 error_code_(base::PLATFORM_FILE_OK) {
22 }
23
24 bool Start(scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
25 const tracked_objects::Location& from_here) {
26 return message_loop_proxy->PostTask(
27 from_here,
28 NewRunnableMethod(this, &MessageLoopRelay::ProcessOnTargetThread));
29 }
30
31 protected:
32 friend class base::RefCountedThreadSafe<MessageLoopRelay>;
33 virtual ~MessageLoopRelay() {}
34
35 // Called to perform work on the FILE thread.
36 virtual void RunWork() = 0;
37
38 // Called to notify the callback on the origin thread.
39 virtual void RunCallback() = 0;
40
41 void set_error_code(base::PlatformFileError error_code) {
42 error_code_ = error_code;
43 }
44
45 base::PlatformFileError error_code() const {
46 return error_code_;
47 }
48
49 FileSystemFileUtilBase* file_util_;
50 FileSystemOperationContext* fs_context_;
51
52 private:
53 void ProcessOnTargetThread() {
54 RunWork();
55 origin_message_loop_proxy_->PostTask(
56 FROM_HERE,
57 NewRunnableMethod(this, &MessageLoopRelay::RunCallback));
58 }
59
60 scoped_refptr<base::MessageLoopProxy> origin_message_loop_proxy_;
61 base::PlatformFileError error_code_;
62 };
63
64 class RelayCreateOrOpen : public MessageLoopRelay {
65 public:
66 RelayCreateOrOpen(
67 FileSystemOperationContext* fs_context,
68 scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
69 const FilePath& file_path,
70 int file_flags,
71 FileSystemFileUtilProxy::CreateOrOpenCallback* callback)
72 : MessageLoopRelay(fs_context),
73 message_loop_proxy_(message_loop_proxy),
74 file_path_(file_path),
75 file_flags_(file_flags),
76 callback_(callback),
77 file_handle_(base::kInvalidPlatformFileValue),
78 created_(false) {
79 DCHECK(callback);
80 }
81
82 protected:
83 virtual ~RelayCreateOrOpen() {
84 if (file_handle_ != base::kInvalidPlatformFileValue)
85 fileapi::FileSystemFileUtilProxy::Close(
86 fs_context_, message_loop_proxy_, file_handle_, NULL);
87 }
88
89 virtual void RunWork() {
90 base::PlatformFileError error_code;
91 error_code =
92 file_util_->CreateOrOpen(fs_context_, file_path_, file_flags_,
93 file_handle_, created_);
94 if (error_code != base::PLATFORM_FILE_OK)
95 set_error_code(error_code);
96 }
97
98 virtual void RunCallback() {
99 callback_->Run(error_code(), base::PassPlatformFile(&file_handle_),
100 created_);
101 delete callback_;
102 }
103
104 private:
105 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
106 FilePath file_path_;
107 int file_flags_;
108 FileSystemFileUtilProxy::CreateOrOpenCallback* callback_;
109 base::PlatformFile file_handle_;
110 bool created_;
111 };
112
113 class RelayCreateTemporary : public MessageLoopRelay {
114 public:
115 RelayCreateTemporary(
116 FileSystemOperationContext* fs_context,
117 scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
118 FileSystemFileUtilProxy::CreateTemporaryCallback* callback)
119 : MessageLoopRelay(fs_context),
120 message_loop_proxy_(message_loop_proxy),
121 callback_(callback),
122 file_handle_(base::kInvalidPlatformFileValue) {
123 DCHECK(callback);
124 }
125
126 protected:
127 virtual ~RelayCreateTemporary() {
128 if (file_handle_ != base::kInvalidPlatformFileValue)
129 fileapi::FileSystemFileUtilProxy::Close(
130 fs_context_, message_loop_proxy_, file_handle_, NULL);
131 }
132
133 virtual void RunWork() {
134 base::PlatformFileError error_code;
135 error_code =
136 file_util_->CreateTemporary(fs_context_, file_path_, file_handle_);
137 if (error_code != base::PLATFORM_FILE_OK)
138 set_error_code(error_code);
139 }
140
141 virtual void RunCallback() {
142 callback_->Run(error_code(), base::PassPlatformFile(&file_handle_),
143 file_path_);
144 delete callback_;
145 }
146
147 private:
148 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
149 FileSystemFileUtilProxy::CreateTemporaryCallback* callback_;
150 base::PlatformFile file_handle_;
151 FilePath file_path_;
152 };
153
154 class RelayWithStatusCallback : public MessageLoopRelay {
155 public:
156 explicit RelayWithStatusCallback(
157 FileSystemOperationContext* fs_context,
158 FileSystemFileUtilProxy::StatusCallback* callback)
159 : MessageLoopRelay(fs_context),
160 callback_(callback) {
161 // It is OK for callback to be NULL.
162 }
163
164 protected:
165 virtual void RunCallback() {
166 // The caller may not have been interested in the result.
167 if (callback_) {
168 callback_->Run(error_code());
169 delete callback_;
170 }
171 }
172
173 private:
174 FileSystemFileUtilProxy::StatusCallback* callback_;
175 };
176
177 class RelayClose : public RelayWithStatusCallback {
178 public:
179 RelayClose(FileSystemOperationContext* fs_context,
180 base::PlatformFile file_handle,
181 FileSystemFileUtilProxy::StatusCallback* callback)
182 : RelayWithStatusCallback(fs_context, callback),
183 file_handle_(file_handle) {
184 }
185
186 protected:
187 virtual void RunWork() {
188 base::PlatformFileError error_code;
189 error_code =
190 file_util_->Close(fs_context_, file_handle_);
191 if (error_code != base::PLATFORM_FILE_OK)
192 set_error_code(error_code);
193 }
194
195 private:
196 base::PlatformFile file_handle_;
197 };
198
199 class RelayEnsureFileExists : public MessageLoopRelay {
200 public:
201 RelayEnsureFileExists(
202 FileSystemOperationContext* fs_context,
203 scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
204 const FilePath& file_path,
205 FileSystemFileUtilProxy::EnsureFileExistsCallback* callback)
206 : MessageLoopRelay(fs_context),
207 message_loop_proxy_(message_loop_proxy),
208 file_path_(file_path),
209 callback_(callback),
210 created_(false) {
211 DCHECK(callback);
212 }
213
214 protected:
215 virtual void RunWork() {
216 base::PlatformFileError error_code;
217 error_code = file_util_->EnsureFileExists(fs_context_,
218 file_path_, &created_);
219 if (error_code != base::PLATFORM_FILE_OK)
220 set_error_code(error_code);
221 }
222
223 virtual void RunCallback() {
224 callback_->Run(error_code(), created_);
225 delete callback_;
226 }
227
228 private:
229 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
230 FilePath file_path_;
231 FileSystemFileUtilProxy::EnsureFileExistsCallback* callback_;
232 bool created_;
233 };
234
235 class RelayDelete : public RelayWithStatusCallback {
236 public:
237 RelayDelete(FileSystemOperationContext* fs_context,
238 const FilePath& file_path,
239 bool recursive,
240 FileSystemFileUtilProxy::StatusCallback* callback)
241 : RelayWithStatusCallback(fs_context, callback),
242 file_path_(file_path),
243 recursive_(recursive) {
244 }
245
246 protected:
247 virtual void RunWork() {
248 base::PlatformFileError error_code;
249 error_code =
250 file_util_->Delete(fs_context_, file_path_, recursive_);
251 if (error_code != base::PLATFORM_FILE_OK)
252 set_error_code(error_code);
253 }
254
255 private:
256 FilePath file_path_;
257 bool recursive_;
258 };
259
260 class RelayCopy : public RelayWithStatusCallback {
261 public:
262 RelayCopy(FileSystemOperationContext* fs_context,
263 const FilePath& src_file_path,
264 const FilePath& dest_file_path,
265 FileSystemFileUtilProxy::StatusCallback* callback)
266 : RelayWithStatusCallback(fs_context, callback),
267 src_file_path_(src_file_path),
268 dest_file_path_(dest_file_path) {
269 }
270
271 protected:
272 virtual void RunWork() {
273 base::PlatformFileError error_code;
274 error_code =
275 file_util_->Copy(fs_context_, src_file_path_, dest_file_path_);
276 if (error_code != base::PLATFORM_FILE_OK)
277 set_error_code(error_code);
278 }
279
280 private:
281 FilePath src_file_path_;
282 FilePath dest_file_path_;
283 };
284
285 class RelayMove : public RelayWithStatusCallback {
286 public:
287 RelayMove(FileSystemOperationContext* fs_context,
288 const FilePath& src_file_path,
289 const FilePath& dest_file_path,
290 FileSystemFileUtilProxy::StatusCallback* callback)
291 : RelayWithStatusCallback(fs_context, callback),
292 src_file_path_(src_file_path),
293 dest_file_path_(dest_file_path) {
294 }
295
296 protected:
297 virtual void RunWork() {
298 base::PlatformFileError error_code;
299 error_code =
300 file_util_->Move(fs_context_, src_file_path_, dest_file_path_);
301 if (error_code != base::PLATFORM_FILE_OK)
302 set_error_code(error_code);
303 }
304
305 private:
306 FilePath src_file_path_;
307 FilePath dest_file_path_;
308 };
309
310 class RelayCreateDirectory : public RelayWithStatusCallback {
311 public:
312 RelayCreateDirectory(
313 FileSystemOperationContext* fs_context,
314 const FilePath& file_path,
315 bool exclusive,
316 bool recursive,
317 FileSystemFileUtilProxy::StatusCallback* callback)
318 : RelayWithStatusCallback(fs_context, callback),
319 file_path_(file_path),
320 exclusive_(exclusive),
321 recursive_(recursive) {
322 }
323
324 protected:
325 virtual void RunWork() {
326 base::PlatformFileError error_code;
327 error_code = file_util_->CreateDirectory(fs_context_,
328 file_path_, exclusive_, recursive_);
329 if (error_code != base::PLATFORM_FILE_OK)
330 set_error_code(error_code);
331 }
332
333 private:
334 FilePath file_path_;
335 bool exclusive_;
336 bool recursive_;
337 };
338
339 class RelayReadDirectory : public MessageLoopRelay {
340 public:
341 RelayReadDirectory(
342 FileSystemOperationContext* fs_context,
343 const FilePath& file_path,
344 FileSystemFileUtilProxy::ReadDirectoryCallback* callback)
345 : MessageLoopRelay(fs_context),
346 callback_(callback),
347 file_path_(file_path) {
348 DCHECK(callback);
349 }
350
351 protected:
352 virtual void RunWork() {
353 base::PlatformFileError error_code;
354 error_code = file_util_->ReadDirectory(fs_context_,
355 file_path_, entries_);
356 if (error_code != base::PLATFORM_FILE_OK)
357 set_error_code(error_code);
358 }
359
360 virtual void RunCallback() {
361 callback_->Run(error_code(), entries_);
362 delete callback_;
363 }
364
365 private:
366 FileSystemFileUtilProxy::ReadDirectoryCallback* callback_;
367 FilePath file_path_;
368 std::vector<base::FileUtilProxy::Entry> entries_;
369 };
370
371 class RelayGetFileInfo : public MessageLoopRelay {
372 public:
373 RelayGetFileInfo(
374 FileSystemOperationContext* fs_context,
375 const FilePath& file_path,
376 FileSystemFileUtilProxy::GetFileInfoCallback* callback)
377 : MessageLoopRelay(fs_context),
378 callback_(callback),
379 file_path_(file_path) {
380 DCHECK(callback);
381 }
382
383 protected:
384 virtual void RunWork() {
385 base::PlatformFileError error_code;
386 error_code = file_util_->GetFileInfo(fs_context_,
387 file_path_, file_info_);
388 if (error_code != base::PLATFORM_FILE_OK)
389 set_error_code(error_code);
390 }
391
392 virtual void RunCallback() {
393 callback_->Run(error_code(), file_info_);
394 delete callback_;
395 }
396
397 private:
398 FileSystemFileUtilProxy::GetFileInfoCallback* callback_;
399 FilePath file_path_;
400 base::PlatformFileInfo file_info_;
401 };
402
403 class RelayGetFileInfoFromPlatformFile : public MessageLoopRelay {
404 public:
405 RelayGetFileInfoFromPlatformFile(
406 FileSystemOperationContext* fs_context,
407 base::PlatformFile file,
408 FileSystemFileUtilProxy::GetFileInfoCallback* callback)
409 : MessageLoopRelay(fs_context),
410 callback_(callback),
411 file_(file) {
412 DCHECK(callback);
413 }
414
415 protected:
416 virtual void RunWork() {
417 base::PlatformFileError error_code;
418 error_code = file_util_->GetFileInfoFromPlatformFile(fs_context_,
419 file_, file_info_);
420 if (error_code != base::PLATFORM_FILE_OK)
421 set_error_code(error_code);
422 }
423
424 virtual void RunCallback() {
425 callback_->Run(error_code(), file_info_);
426 delete callback_;
427 }
428
429 private:
430 FileSystemFileUtilProxy::GetFileInfoCallback* callback_;
431 base::PlatformFile file_;
432 base::PlatformFileInfo file_info_;
433 };
434
435 class RelayRead : public MessageLoopRelay {
436 public:
437 RelayRead(
438 FileSystemOperationContext* fs_context,
439 base::PlatformFile file,
440 int64 offset,
441 int bytes_to_read,
442 FileSystemFileUtilProxy::ReadCallback* callback)
443 : MessageLoopRelay(fs_context),
444 file_(file),
445 offset_(offset),
446 buffer_(new char[bytes_to_read]),
447 bytes_to_read_(bytes_to_read),
448 callback_(callback),
449 bytes_read_(0) {
450 }
451
452 protected:
453 virtual void RunWork() {
454 base::PlatformFileError error_code;
455 error_code = file_util_->Read(fs_context_,
456 file_, offset_, bytes_to_read_,
457 bytes_read_, buffer_.get());
458 if (error_code != base::PLATFORM_FILE_OK)
459 set_error_code(error_code);
460 }
461
462 virtual void RunCallback() {
463 if (callback_) {
464 callback_->Run(error_code(), buffer_.get(), bytes_read_);
465 delete callback_;
466 }
467 }
468
469 private:
470 base::PlatformFile file_;
471 int64 offset_;
472 scoped_array<char> buffer_;
473 int bytes_to_read_;
474 FileSystemFileUtilProxy::ReadCallback* callback_;
475 int bytes_read_;
476 };
477
478 class RelayWrite : public MessageLoopRelay {
479 public:
480 RelayWrite(
481 FileSystemOperationContext* fs_context,
482 base::PlatformFile file,
483 int64 offset,
484 const char* buffer,
485 int bytes_to_write,
486 FileSystemFileUtilProxy::WriteCallback* callback)
487 : MessageLoopRelay(fs_context),
488 file_(file),
489 offset_(offset),
490 buffer_(new char[bytes_to_write]),
491 bytes_to_write_(bytes_to_write),
492 callback_(callback) {
493 memcpy(buffer_.get(), buffer, bytes_to_write);
494 }
495
496 protected:
497 virtual void RunWork() {
498 base::PlatformFileError error_code;
499 error_code = file_util_->Write(fs_context_,
500 file_, offset_, bytes_to_write_,
501 bytes_written_, buffer_.get());
502 if (error_code != base::PLATFORM_FILE_OK)
503 set_error_code(error_code);
504 }
505
506 virtual void RunCallback() {
507 if (callback_) {
508 callback_->Run(error_code(), bytes_written_);
509 delete callback_;
510 }
511 }
512
513 private:
514 base::PlatformFile file_;
515 int64 offset_;
516 scoped_array<char> buffer_;
517 int bytes_to_write_;
518 FileSystemFileUtilProxy::WriteCallback* callback_;
519 int bytes_written_;
520 };
521
522 class RelayTouch : public RelayWithStatusCallback {
523 public:
524 RelayTouch(
525 FileSystemOperationContext* fs_context,
526 base::PlatformFile file,
527 const base::Time& last_access_time,
528 const base::Time& last_modified_time,
529 FileSystemFileUtilProxy::StatusCallback* callback)
530 : RelayWithStatusCallback(fs_context, callback),
531 file_(file),
532 last_access_time_(last_access_time),
533 last_modified_time_(last_modified_time) {
534 }
535
536 protected:
537 virtual void RunWork() {
538 base::PlatformFileError error_code;
539 error_code = file_util_->Touch(fs_context_, file_,
540 last_access_time_, last_modified_time_);
541 if (error_code != base::PLATFORM_FILE_OK)
542 set_error_code(error_code);
543 }
544
545 private:
546 base::PlatformFile file_;
547 base::Time last_access_time_;
548 base::Time last_modified_time_;
549 };
550
551 class RelayTouchFilePath : public RelayWithStatusCallback {
552 public:
553 RelayTouchFilePath(
554 FileSystemOperationContext* fs_context,
555 const FilePath& file_path,
556 const base::Time& last_access_time,
557 const base::Time& last_modified_time,
558 FileSystemFileUtilProxy::StatusCallback* callback)
559 : RelayWithStatusCallback(fs_context, callback),
560 file_path_(file_path),
561 last_access_time_(last_access_time),
562 last_modified_time_(last_modified_time) {
563 }
564
565 protected:
566 virtual void RunWork() {
567 base::PlatformFileError error_code;
568 error_code = file_util_->TouchFilePath(fs_context_, file_path_,
569 last_access_time_,
570 last_modified_time_);
571 if (error_code != base::PLATFORM_FILE_OK)
572 set_error_code(error_code);
573 }
574
575 private:
576 FilePath file_path_;
577 base::Time last_access_time_;
578 base::Time last_modified_time_;
579 };
580
581 class RelayTruncatePlatformFile : public RelayWithStatusCallback {
582 public:
583 RelayTruncatePlatformFile(
584 FileSystemOperationContext* fs_context,
585 base::PlatformFile file,
586 int64 length,
587 FileSystemFileUtilProxy::StatusCallback* callback)
588 : RelayWithStatusCallback(fs_context, callback),
589 file_(file),
590 length_(length) {
591 }
592
593 protected:
594 virtual void RunWork() {
595 base::PlatformFileError error_code;
596 error_code = file_util_->TruncatePlatformFile(fs_context_,
597 file_, length_);
598 if (error_code != base::PLATFORM_FILE_OK)
599 set_error_code(error_code);
600 }
601
602 private:
603 base::PlatformFile file_;
604 int64 length_;
605 };
606
607 class RelayTruncate : public RelayWithStatusCallback {
608 public:
609 RelayTruncate(FileSystemOperationContext* fs_context,
610 const FilePath& path,
611 int64 length,
612 FileSystemFileUtilProxy::StatusCallback* callback)
613 : RelayWithStatusCallback(fs_context, callback),
614 path_(path),
615 length_(length) {
616 }
617
618 protected:
619 virtual void RunWork() {
620 base::PlatformFileError error_code;
621 error_code = file_util_->Truncate(fs_context_, path_, length_);
622 if (error_code != base::PLATFORM_FILE_OK)
623 set_error_code(error_code);
624 }
625
626 private:
627 FilePath path_;
628 int64 length_;
629 };
630
631 class RelayFlush : public RelayWithStatusCallback {
632 public:
633 RelayFlush(FileSystemOperationContext* fs_context,
634 base::PlatformFile file,
635 FileSystemFileUtilProxy::StatusCallback* callback)
636 : RelayWithStatusCallback(fs_context, callback),
637 file_(file) {
638 }
639
640 protected:
641 virtual void RunWork() {
642 base::PlatformFileError error_code;
643 error_code = file_util_->Flush(fs_context_, file_);
644 if (error_code != base::PLATFORM_FILE_OK)
645 set_error_code(error_code);
646 }
647
648 private:
649 base::PlatformFile file_;
650 };
651
652 bool Start(const tracked_objects::Location& from_here,
653 scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
654 scoped_refptr<MessageLoopRelay> relay) {
655 return relay->Start(message_loop_proxy, from_here);
656 }
657
658 // static
659 bool FileSystemFileUtilProxy::CreateOrOpen(
660 FileSystemOperationContext* fs_context,
661 scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
662 const FilePath& file_path, int file_flags,
663 CreateOrOpenCallback* callback) {
664 return Start(FROM_HERE, message_loop_proxy, new RelayCreateOrOpen(
665 fs_context, message_loop_proxy, file_path, file_flags, callback));
666 }
667
668 // static
669 bool FileSystemFileUtilProxy::CreateTemporary(
670 FileSystemOperationContext* fs_context,
671 scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
672 CreateTemporaryCallback* callback) {
673 return Start(FROM_HERE, message_loop_proxy, new RelayCreateTemporary(
674 fs_context, message_loop_proxy, callback));
675 }
676
677 // static
678 bool FileSystemFileUtilProxy::Close(
679 FileSystemOperationContext* fs_context,
680 scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
681 base::PlatformFile file_handle,
682 StatusCallback* callback) {
683 return Start(FROM_HERE, message_loop_proxy,
684 new RelayClose(fs_context, file_handle, callback));
685 }
686
687 // static
688 bool FileSystemFileUtilProxy::EnsureFileExists(
689 FileSystemOperationContext* fs_context,
690 scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
691 const FilePath& file_path,
692 EnsureFileExistsCallback* callback) {
693 return Start(FROM_HERE, message_loop_proxy, new RelayEnsureFileExists(
694 fs_context, message_loop_proxy, file_path, callback));
695 }
696
697 // Retrieves the information about a file. It is invalid to pass NULL for the
698 // callback.
699 bool FileSystemFileUtilProxy::GetFileInfo(
700 FileSystemOperationContext* fs_context,
701 scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
702 const FilePath& file_path,
703 GetFileInfoCallback* callback) {
704 return Start(FROM_HERE, message_loop_proxy, new RelayGetFileInfo(
705 fs_context, file_path, callback));
706 }
707
708 // static
709 bool FileSystemFileUtilProxy::GetFileInfoFromPlatformFile(
710 FileSystemOperationContext* fs_context,
711 scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
712 base::PlatformFile file,
713 GetFileInfoCallback* callback) {
714 return Start(FROM_HERE, message_loop_proxy,
715 new RelayGetFileInfoFromPlatformFile(fs_context,
716 file, callback));
717 }
718
719 // static
720 bool FileSystemFileUtilProxy::ReadDirectory(
721 FileSystemOperationContext* fs_context,
722 scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
723 const FilePath& file_path,
724 ReadDirectoryCallback* callback) {
725 return Start(FROM_HERE, message_loop_proxy, new RelayReadDirectory(
726 fs_context, file_path, callback));
727 }
728
729 // static
730 bool FileSystemFileUtilProxy::CreateDirectory(
731 FileSystemOperationContext* fs_context,
732 scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
733 const FilePath& file_path,
734 bool exclusive,
735 bool recursive,
736 StatusCallback* callback) {
737 return Start(FROM_HERE, message_loop_proxy, new RelayCreateDirectory(
738 fs_context, file_path, exclusive, recursive, callback));
739 }
740
741 // static
742 bool FileSystemFileUtilProxy::Copy(
743 FileSystemOperationContext* fs_context,
744 scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
745 const FilePath& src_file_path,
746 const FilePath& dest_file_path,
747 StatusCallback* callback) {
748 return Start(FROM_HERE, message_loop_proxy,
749 new RelayCopy(fs_context,
750 src_file_path, dest_file_path, callback));
751 }
752
753 // static
754 bool FileSystemFileUtilProxy::Move(
755 FileSystemOperationContext* fs_context,
756 scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
757 const FilePath& src_file_path,
758 const FilePath& dest_file_path,
759 StatusCallback* callback) {
760 return Start(FROM_HERE, message_loop_proxy,
761 new RelayMove(fs_context,
762 src_file_path, dest_file_path, callback));
763 }
764
765 // static
766 bool FileSystemFileUtilProxy::Delete(
767 FileSystemOperationContext* fs_context,
768 scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
769 const FilePath& file_path,
770 bool recursive,
771 StatusCallback* callback) {
772 return Start(FROM_HERE, message_loop_proxy,
773 new RelayDelete(fs_context, file_path, recursive, callback));
774 }
775
776 // static
777 bool FileSystemFileUtilProxy::RecursiveDelete(
778 FileSystemOperationContext* fs_context,
779 scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
780 const FilePath& file_path,
781 StatusCallback* callback) {
782 return Start(FROM_HERE, message_loop_proxy,
783 new RelayDelete(fs_context, file_path, true, callback));
784 }
785
786 // static
787 bool FileSystemFileUtilProxy::Read(
788 FileSystemOperationContext* fs_context,
789 scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
790 base::PlatformFile file,
791 int64 offset,
792 int bytes_to_read,
793 ReadCallback* callback) {
794 return Start(FROM_HERE, message_loop_proxy,
795 new RelayRead(fs_context,
796 file, offset, bytes_to_read, callback));
797 }
798
799 // static
800 bool FileSystemFileUtilProxy::Write(
801 FileSystemOperationContext* fs_context,
802 scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
803 base::PlatformFile file,
804 int64 offset,
805 const char* buffer,
806 int bytes_to_write,
807 WriteCallback* callback) {
808 return Start(FROM_HERE, message_loop_proxy,
809 new RelayWrite(fs_context,
810 file, offset, buffer, bytes_to_write, callback));
811 }
812
813 // static
814 bool FileSystemFileUtilProxy::Touch(
815 FileSystemOperationContext* fs_context,
816 scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
817 base::PlatformFile file,
818 const base::Time& last_access_time,
819 const base::Time& last_modified_time,
820 StatusCallback* callback) {
821 return Start(FROM_HERE, message_loop_proxy,
822 new RelayTouch(fs_context,
823 file, last_access_time, last_modified_time,
824 callback));
825 }
826
827 // static
828 bool FileSystemFileUtilProxy::Touch(
829 FileSystemOperationContext* fs_context,
830 scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
831 const FilePath& file_path,
832 const base::Time& last_access_time,
833 const base::Time& last_modified_time,
834 StatusCallback* callback) {
835 return Start(FROM_HERE, message_loop_proxy,
836 new RelayTouchFilePath(fs_context,
837 file_path, last_access_time,
838 last_modified_time, callback));
839 }
840
841 // static
842 bool FileSystemFileUtilProxy::Truncate(
843 FileSystemOperationContext* fs_context,
844 scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
845 base::PlatformFile file,
846 int64 length,
847 StatusCallback* callback) {
848 return Start(FROM_HERE, message_loop_proxy,
849 new RelayTruncatePlatformFile(fs_context,
850 file, length, callback));
851 }
852
853 // static
854 bool FileSystemFileUtilProxy::Truncate(
855 FileSystemOperationContext* fs_context,
856 scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
857 const FilePath& path,
858 int64 length,
859 StatusCallback* callback) {
860 return Start(FROM_HERE, message_loop_proxy,
861 new RelayTruncate(fs_context, path, length, callback));
862 }
863
864 // static
865 bool FileSystemFileUtilProxy::Flush(
866 FileSystemOperationContext* fs_context,
867 scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
868 base::PlatformFile file,
869 StatusCallback* callback) {
870 return Start(FROM_HERE, message_loop_proxy,
871 new RelayFlush(fs_context, file, callback));
872 }
873
874 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/file_system_file_util_proxy.h ('k') | webkit/fileapi/file_system_operation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698