| 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 "googleurl/src/gurl.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 |
| 130 void FileSystemOperation::Write( |
| 131 const FilePath&, |
| 132 const GURL&, |
| 133 int64) { |
| 134 #ifndef NDEBUG |
| 135 DCHECK(!operation_pending_); |
| 136 operation_pending_ = true; |
| 137 #endif |
| 138 NOTREACHED(); |
| 139 // TODO(ericu): |
| 140 // Set up a loop that, via multiple callback invocations, reads from a |
| 141 // URLRequest wrapping blob_url, writes the bytes to the file, reports |
| 142 // progress events no more frequently than some set rate, and periodically |
| 143 // checks to see if it's been cancelled. |
| 144 } |
| 145 |
| 146 void FileSystemOperation::Truncate(const FilePath& path, int64 length) { |
| 147 #ifndef NDEBUG |
| 148 DCHECK(!operation_pending_); |
| 149 operation_pending_ = true; |
| 150 #endif |
| 151 // TODO(ericu): |
| 152 NOTREACHED(); |
| 153 } |
| 154 |
| 155 void FileSystemOperation::Cancel() { |
| 156 #ifndef NDEBUG |
| 157 DCHECK(operation_pending_); |
| 158 #endif |
| 159 NOTREACHED(); |
| 160 // TODO(ericu): |
| 161 // Make sure this was done on a FileSystemOperation used for a Write. |
| 162 // Then set a flag that ensures that the Write loop will exit without |
| 163 // reporting any more progress, with a failure notification. |
| 164 } |
| 165 |
| 128 void FileSystemOperation::DidCreateFileExclusive( | 166 void FileSystemOperation::DidCreateFileExclusive( |
| 129 base::PlatformFileError rv, | 167 base::PlatformFileError rv, |
| 130 base::PassPlatformFile file, | 168 base::PassPlatformFile file, |
| 131 bool created) { | 169 bool created) { |
| 132 DidFinishFileOperation(rv); | 170 DidFinishFileOperation(rv); |
| 133 } | 171 } |
| 134 | 172 |
| 135 void FileSystemOperation::DidCreateFileNonExclusive( | 173 void FileSystemOperation::DidCreateFileNonExclusive( |
| 136 base::PlatformFileError rv, | 174 base::PlatformFileError rv, |
| 137 base::PassPlatformFile file, | 175 base::PassPlatformFile file, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 | 225 |
| 188 void FileSystemOperation::DidReadDirectory( | 226 void FileSystemOperation::DidReadDirectory( |
| 189 base::PlatformFileError rv, | 227 base::PlatformFileError rv, |
| 190 const std::vector<base::file_util_proxy::Entry>& entries) { | 228 const std::vector<base::file_util_proxy::Entry>& entries) { |
| 191 if (rv == base::PLATFORM_FILE_OK) | 229 if (rv == base::PLATFORM_FILE_OK) |
| 192 dispatcher_->DidReadDirectory(entries, false /* has_more */); | 230 dispatcher_->DidReadDirectory(entries, false /* has_more */); |
| 193 else | 231 else |
| 194 dispatcher_->DidFail(rv); | 232 dispatcher_->DidFail(rv); |
| 195 } | 233 } |
| 196 | 234 |
| 235 void FileSystemOperation::DidWrite( |
| 236 base::PlatformFileError rv, |
| 237 int64 bytes, |
| 238 bool complete) { |
| 239 if (rv == base::PLATFORM_FILE_OK) |
| 240 /* dispatcher_->DidWrite(bytes, complete) TODO(ericu): Coming soon. */ {} |
| 241 else |
| 242 dispatcher_->DidFail(rv); |
| 243 } |
| 244 |
| 197 } // namespace fileapi | 245 } // namespace fileapi |
| OLD | NEW |