| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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 "base/file_util_proxy.h" | 5 #include "base/file_util_proxy.h" |
| 6 | 6 |
| 7 #include "base/message_loop_proxy.h" | 7 #include "base/message_loop_proxy.h" |
| 8 | 8 |
| 9 // TODO(jianli): Move the code from anonymous namespace to base namespace so | 9 // TODO(jianli): Move the code from anonymous namespace to base namespace so |
| 10 // that all of the base:: prefixes would be unnecessary. | 10 // that all of the base:: prefixes would be unnecessary. |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 if (!base::TouchPlatformFile(file_, last_access_time_, last_modified_time_)) | 550 if (!base::TouchPlatformFile(file_, last_access_time_, last_modified_time_)) |
| 551 set_error_code(base::PLATFORM_FILE_ERROR_FAILED); | 551 set_error_code(base::PLATFORM_FILE_ERROR_FAILED); |
| 552 } | 552 } |
| 553 | 553 |
| 554 private: | 554 private: |
| 555 base::PlatformFile file_; | 555 base::PlatformFile file_; |
| 556 base::Time last_access_time_; | 556 base::Time last_access_time_; |
| 557 base::Time last_modified_time_; | 557 base::Time last_modified_time_; |
| 558 }; | 558 }; |
| 559 | 559 |
| 560 class RelayTouchFilePath : public RelayWithStatusCallback { |
| 561 public: |
| 562 RelayTouchFilePath(const FilePath& file_path, |
| 563 const base::Time& last_access_time, |
| 564 const base::Time& last_modified_time, |
| 565 base::FileUtilProxy::StatusCallback* callback) |
| 566 : RelayWithStatusCallback(callback), |
| 567 file_path_(file_path_), |
| 568 last_access_time_(last_access_time), |
| 569 last_modified_time_(last_modified_time) { |
| 570 } |
| 571 |
| 572 protected: |
| 573 virtual void RunWork() { |
| 574 if (!file_util::TouchFile( |
| 575 file_path_, last_access_time_, last_modified_time_)) |
| 576 set_error_code(base::PLATFORM_FILE_ERROR_FAILED); |
| 577 } |
| 578 |
| 579 private: |
| 580 FilePath file_path_; |
| 581 base::Time last_access_time_; |
| 582 base::Time last_modified_time_; |
| 583 }; |
| 584 |
| 560 class RelayTruncate : public RelayWithStatusCallback { | 585 class RelayTruncate : public RelayWithStatusCallback { |
| 561 public: | 586 public: |
| 562 RelayTruncate(base::PlatformFile file, | 587 RelayTruncate(base::PlatformFile file, |
| 563 int64 length, | 588 int64 length, |
| 564 base::FileUtilProxy::StatusCallback* callback) | 589 base::FileUtilProxy::StatusCallback* callback) |
| 565 : RelayWithStatusCallback(callback), | 590 : RelayWithStatusCallback(callback), |
| 566 file_(file), | 591 file_(file), |
| 567 length_(length) { | 592 length_(length) { |
| 568 } | 593 } |
| 569 | 594 |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 PlatformFile file, | 760 PlatformFile file, |
| 736 const base::Time& last_access_time, | 761 const base::Time& last_access_time, |
| 737 const base::Time& last_modified_time, | 762 const base::Time& last_modified_time, |
| 738 StatusCallback* callback) { | 763 StatusCallback* callback) { |
| 739 return Start(FROM_HERE, message_loop_proxy, | 764 return Start(FROM_HERE, message_loop_proxy, |
| 740 new RelayTouch(file, last_access_time, last_modified_time, | 765 new RelayTouch(file, last_access_time, last_modified_time, |
| 741 callback)); | 766 callback)); |
| 742 } | 767 } |
| 743 | 768 |
| 744 // static | 769 // static |
| 770 bool FileUtilProxy::Touch( |
| 771 scoped_refptr<MessageLoopProxy> message_loop_proxy, |
| 772 const FilePath& file_path, |
| 773 const base::Time& last_access_time, |
| 774 const base::Time& last_modified_time, |
| 775 StatusCallback* callback) { |
| 776 return Start(FROM_HERE, message_loop_proxy, |
| 777 new RelayTouchFilePath(file_path, last_access_time, |
| 778 last_modified_time, callback)); |
| 779 } |
| 780 |
| 781 // static |
| 745 bool FileUtilProxy::Truncate( | 782 bool FileUtilProxy::Truncate( |
| 746 scoped_refptr<MessageLoopProxy> message_loop_proxy, | 783 scoped_refptr<MessageLoopProxy> message_loop_proxy, |
| 747 PlatformFile file, | 784 PlatformFile file, |
| 748 long long length, | 785 long long length, |
| 749 StatusCallback* callback) { | 786 StatusCallback* callback) { |
| 750 return Start(FROM_HERE, message_loop_proxy, | 787 return Start(FROM_HERE, message_loop_proxy, |
| 751 new RelayTruncate(file, length, callback)); | 788 new RelayTruncate(file, length, callback)); |
| 752 } | 789 } |
| 753 | 790 |
| 754 // static | 791 // static |
| 755 bool FileUtilProxy::Flush( | 792 bool FileUtilProxy::Flush( |
| 756 scoped_refptr<MessageLoopProxy> message_loop_proxy, | 793 scoped_refptr<MessageLoopProxy> message_loop_proxy, |
| 757 PlatformFile file, | 794 PlatformFile file, |
| 758 StatusCallback* callback) { | 795 StatusCallback* callback) { |
| 759 return Start(FROM_HERE, message_loop_proxy, new RelayFlush(file, callback)); | 796 return Start(FROM_HERE, message_loop_proxy, new RelayFlush(file, callback)); |
| 760 } | 797 } |
| 761 | 798 |
| 762 } // namespace base | 799 } // namespace base |
| OLD | NEW |