| 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 "webkit/fileapi/file_system_operation.h" | 5 #include "webkit/fileapi/file_system_operation.h" |
| 6 | 6 |
| 7 #include "base/time.h" |
| 7 #include "webkit/fileapi/file_system_callback_dispatcher.h" | 8 #include "webkit/fileapi/file_system_callback_dispatcher.h" |
| 8 | 9 |
| 9 namespace fileapi { | 10 namespace fileapi { |
| 10 | 11 |
| 11 FileSystemOperation::FileSystemOperation( | 12 FileSystemOperation::FileSystemOperation( |
| 12 FileSystemCallbackDispatcher* dispatcher, | 13 FileSystemCallbackDispatcher* dispatcher, |
| 13 scoped_refptr<base::MessageLoopProxy> proxy) | 14 scoped_refptr<base::MessageLoopProxy> proxy) |
| 14 : proxy_(proxy), | 15 : proxy_(proxy), |
| 15 dispatcher_(dispatcher), | 16 dispatcher_(dispatcher), |
| 16 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 17 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 void FileSystemOperation::Remove(const FilePath& path) { | 119 void FileSystemOperation::Remove(const FilePath& path) { |
| 119 #ifndef NDEBUG | 120 #ifndef NDEBUG |
| 120 DCHECK(!operation_pending_); | 121 DCHECK(!operation_pending_); |
| 121 operation_pending_ = true; | 122 operation_pending_ = true; |
| 122 #endif | 123 #endif |
| 123 | 124 |
| 124 base::FileUtilProxy::Delete(proxy_, path, callback_factory_.NewCallback( | 125 base::FileUtilProxy::Delete(proxy_, path, callback_factory_.NewCallback( |
| 125 &FileSystemOperation::DidFinishFileOperation)); | 126 &FileSystemOperation::DidFinishFileOperation)); |
| 126 } | 127 } |
| 127 | 128 |
| 129 void FileSystemOperation::TouchFile(const FilePath& path, |
| 130 const base::Time& last_access_time, |
| 131 const base::Time& last_modified_time) { |
| 132 #ifndef NDEBUG |
| 133 DCHECK(!operation_pending_); |
| 134 operation_pending_ = true; |
| 135 #endif |
| 136 |
| 137 base::FileUtilProxy::Touch( |
| 138 proxy_, path, last_access_time, last_modified_time, |
| 139 callback_factory_.NewCallback(&FileSystemOperation::DidTouchFile)); |
| 140 } |
| 141 |
| 128 void FileSystemOperation::DidCreateFileExclusive( | 142 void FileSystemOperation::DidCreateFileExclusive( |
| 129 base::PlatformFileError rv, | 143 base::PlatformFileError rv, |
| 130 base::PassPlatformFile file, | 144 base::PassPlatformFile file, |
| 131 bool created) { | 145 bool created) { |
| 132 DidFinishFileOperation(rv); | 146 DidFinishFileOperation(rv); |
| 133 } | 147 } |
| 134 | 148 |
| 135 void FileSystemOperation::DidCreateFileNonExclusive( | 149 void FileSystemOperation::DidCreateFileNonExclusive( |
| 136 base::PlatformFileError rv, | 150 base::PlatformFileError rv, |
| 137 base::PassPlatformFile file, | 151 base::PassPlatformFile file, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 | 201 |
| 188 void FileSystemOperation::DidReadDirectory( | 202 void FileSystemOperation::DidReadDirectory( |
| 189 base::PlatformFileError rv, | 203 base::PlatformFileError rv, |
| 190 const std::vector<base::file_util_proxy::Entry>& entries) { | 204 const std::vector<base::file_util_proxy::Entry>& entries) { |
| 191 if (rv == base::PLATFORM_FILE_OK) | 205 if (rv == base::PLATFORM_FILE_OK) |
| 192 dispatcher_->DidReadDirectory(entries, false /* has_more */); | 206 dispatcher_->DidReadDirectory(entries, false /* has_more */); |
| 193 else | 207 else |
| 194 dispatcher_->DidFail(rv); | 208 dispatcher_->DidFail(rv); |
| 195 } | 209 } |
| 196 | 210 |
| 211 void FileSystemOperation::DidTouchFile(base::PlatformFileError rv) { |
| 212 if (rv == base::PLATFORM_FILE_OK) |
| 213 dispatcher_->DidSucceed(); |
| 214 else |
| 215 dispatcher_->DidFail(rv); |
| 216 } |
| 217 |
| 197 } // namespace fileapi | 218 } // namespace fileapi |
| OLD | NEW |