| 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 DCHECK(callback); | 129 DCHECK(callback); |
| 130 } | 130 } |
| 131 | 131 |
| 132 protected: | 132 protected: |
| 133 virtual ~RelayCreateOrOpen() { | 133 virtual ~RelayCreateOrOpen() { |
| 134 if (file_handle_ != base::kInvalidPlatformFileValue) | 134 if (file_handle_ != base::kInvalidPlatformFileValue) |
| 135 base::FileUtilProxy::Close(message_loop_proxy_, file_handle_, NULL); | 135 base::FileUtilProxy::Close(message_loop_proxy_, file_handle_, NULL); |
| 136 } | 136 } |
| 137 | 137 |
| 138 virtual void RunWork() { | 138 virtual void RunWork() { |
| 139 if (!file_util::DirectoryExists(file_path_.DirName())) { |
| 140 // If its parent does not exist, should return NOT_FOUND error. |
| 141 set_error_code(base::PLATFORM_FILE_ERROR_NOT_FOUND); |
| 142 return; |
| 143 } |
| 139 base::PlatformFileError error_code = base::PLATFORM_FILE_OK; | 144 base::PlatformFileError error_code = base::PLATFORM_FILE_OK; |
| 140 file_handle_ = base::CreatePlatformFile(file_path_, file_flags_, | 145 file_handle_ = base::CreatePlatformFile(file_path_, file_flags_, |
| 141 &created_, &error_code); | 146 &created_, &error_code); |
| 142 set_error_code(error_code); | 147 set_error_code(error_code); |
| 143 } | 148 } |
| 144 | 149 |
| 145 virtual void RunCallback() { | 150 virtual void RunCallback() { |
| 146 callback_->Run(error_code(), base::PassPlatformFile(&file_handle_), | 151 callback_->Run(error_code(), base::PassPlatformFile(&file_handle_), |
| 147 created_); | 152 created_); |
| 148 delete callback_; | 153 delete callback_; |
| (...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 | 849 |
| 845 // static | 850 // static |
| 846 bool FileUtilProxy::Flush( | 851 bool FileUtilProxy::Flush( |
| 847 scoped_refptr<MessageLoopProxy> message_loop_proxy, | 852 scoped_refptr<MessageLoopProxy> message_loop_proxy, |
| 848 PlatformFile file, | 853 PlatformFile file, |
| 849 StatusCallback* callback) { | 854 StatusCallback* callback) { |
| 850 return Start(FROM_HERE, message_loop_proxy, new RelayFlush(file, callback)); | 855 return Start(FROM_HERE, message_loop_proxy, new RelayFlush(file, callback)); |
| 851 } | 856 } |
| 852 | 857 |
| 853 } // namespace base | 858 } // namespace base |
| OLD | NEW |