| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_file_util_proxy.h" | 5 #include "webkit/fileapi/file_system_file_util_proxy.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/message_loop_proxy.h" | 9 #include "base/sequenced_task_runner.h" |
| 10 #include "webkit/fileapi/file_system_context.h" |
| 10 #include "webkit/fileapi/file_system_file_util.h" | 11 #include "webkit/fileapi/file_system_file_util.h" |
| 11 #include "webkit/fileapi/file_system_operation_context.h" | 12 #include "webkit/fileapi/file_system_operation_context.h" |
| 12 #include "webkit/fileapi/file_util_helper.h" | 13 #include "webkit/fileapi/file_util_helper.h" |
| 13 | 14 |
| 14 namespace fileapi { | 15 namespace fileapi { |
| 15 | 16 |
| 16 using base::Bind; | 17 using base::Bind; |
| 17 using base::Callback; | 18 using base::Callback; |
| 18 using base::Owned; | 19 using base::Owned; |
| 19 using base::PlatformFileError; | 20 using base::PlatformFileError; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 private: | 86 private: |
| 86 base::PlatformFileError error_; | 87 base::PlatformFileError error_; |
| 87 std::vector<Proxy::Entry> entries_; | 88 std::vector<Proxy::Entry> entries_; |
| 88 DISALLOW_COPY_AND_ASSIGN(ReadDirectoryHelper); | 89 DISALLOW_COPY_AND_ASSIGN(ReadDirectoryHelper); |
| 89 }; | 90 }; |
| 90 | 91 |
| 91 } // namespace | 92 } // namespace |
| 92 | 93 |
| 93 // static | 94 // static |
| 94 bool FileSystemFileUtilProxy::Delete( | 95 bool FileSystemFileUtilProxy::Delete( |
| 95 MessageLoopProxy* message_loop_proxy, | |
| 96 FileSystemOperationContext* context, | 96 FileSystemOperationContext* context, |
| 97 FileSystemFileUtil* file_util, | 97 FileSystemFileUtil* file_util, |
| 98 const FileSystemPath& path, | 98 const FileSystemPath& path, |
| 99 bool recursive, | 99 bool recursive, |
| 100 const StatusCallback& callback) { | 100 const StatusCallback& callback) { |
| 101 return base::FileUtilProxy::RelayFileTask( | 101 return base::FileUtilProxy::RelayFileTask( |
| 102 message_loop_proxy, FROM_HERE, | 102 context->file_task_runner(), FROM_HERE, |
| 103 Bind(&FileUtilHelper::Delete, context, file_util, path, recursive), | 103 Bind(&FileUtilHelper::Delete, context, file_util, path, recursive), |
| 104 callback); | 104 callback); |
| 105 } | 105 } |
| 106 | 106 |
| 107 // static | 107 // static |
| 108 bool FileSystemFileUtilProxy::CreateOrOpen( | 108 bool FileSystemFileUtilProxy::CreateOrOpen( |
| 109 MessageLoopProxy* message_loop_proxy, | |
| 110 FileSystemOperationContext* context, | 109 FileSystemOperationContext* context, |
| 111 FileSystemFileUtil* file_util, | 110 FileSystemFileUtil* file_util, |
| 112 const FileSystemPath& path, | 111 const FileSystemPath& path, |
| 113 int file_flags, | 112 int file_flags, |
| 114 const CreateOrOpenCallback& callback) { | 113 const CreateOrOpenCallback& callback) { |
| 115 return base::FileUtilProxy::RelayCreateOrOpen( | 114 return base::FileUtilProxy::RelayCreateOrOpen( |
| 116 message_loop_proxy, | 115 context->file_task_runner(), |
| 117 Bind(&FileSystemFileUtil::CreateOrOpen, Unretained(file_util), | 116 Bind(&FileSystemFileUtil::CreateOrOpen, Unretained(file_util), |
| 118 context, path, file_flags), | 117 context, path, file_flags), |
| 119 Bind(&FileSystemFileUtil::Close, Unretained(file_util), | 118 Bind(&FileSystemFileUtil::Close, Unretained(file_util), |
| 120 context), | 119 context), |
| 121 callback); | 120 callback); |
| 122 } | 121 } |
| 123 | 122 |
| 124 // static | 123 // static |
| 125 bool FileSystemFileUtilProxy::Copy( | 124 bool FileSystemFileUtilProxy::Copy( |
| 126 MessageLoopProxy* message_loop_proxy, | |
| 127 FileSystemOperationContext* context, | 125 FileSystemOperationContext* context, |
| 128 FileSystemFileUtil* src_util, | 126 FileSystemFileUtil* src_util, |
| 129 FileSystemFileUtil* dest_util, | 127 FileSystemFileUtil* dest_util, |
| 130 const FileSystemPath& src_path, | 128 const FileSystemPath& src_path, |
| 131 const FileSystemPath& dest_path, | 129 const FileSystemPath& dest_path, |
| 132 const StatusCallback& callback) { | 130 const StatusCallback& callback) { |
| 133 return base::FileUtilProxy::RelayFileTask( | 131 return base::FileUtilProxy::RelayFileTask( |
| 134 message_loop_proxy, FROM_HERE, | 132 context->file_task_runner(), FROM_HERE, |
| 135 Bind(&FileUtilHelper::Copy, | 133 Bind(&FileUtilHelper::Copy, |
| 136 context, src_util, dest_util, src_path, dest_path), | 134 context, src_util, dest_util, src_path, dest_path), |
| 137 callback); | 135 callback); |
| 138 } | 136 } |
| 139 | 137 |
| 140 // static | 138 // static |
| 141 bool FileSystemFileUtilProxy::Move( | 139 bool FileSystemFileUtilProxy::Move( |
| 142 MessageLoopProxy* message_loop_proxy, | |
| 143 FileSystemOperationContext* context, | 140 FileSystemOperationContext* context, |
| 144 FileSystemFileUtil* src_util, | 141 FileSystemFileUtil* src_util, |
| 145 FileSystemFileUtil* dest_util, | 142 FileSystemFileUtil* dest_util, |
| 146 const FileSystemPath& src_path, | 143 const FileSystemPath& src_path, |
| 147 const FileSystemPath& dest_path, | 144 const FileSystemPath& dest_path, |
| 148 const StatusCallback& callback) { | 145 const StatusCallback& callback) { |
| 149 return base::FileUtilProxy::RelayFileTask( | 146 return base::FileUtilProxy::RelayFileTask( |
| 150 message_loop_proxy, FROM_HERE, | 147 context->file_task_runner(), FROM_HERE, |
| 151 Bind(&FileUtilHelper::Move, | 148 Bind(&FileUtilHelper::Move, |
| 152 context, src_util, dest_util, src_path, dest_path), | 149 context, src_util, dest_util, src_path, dest_path), |
| 153 callback); | 150 callback); |
| 154 } | 151 } |
| 155 | 152 |
| 156 // static | 153 // static |
| 157 bool FileSystemFileUtilProxy::EnsureFileExists( | 154 bool FileSystemFileUtilProxy::EnsureFileExists( |
| 158 MessageLoopProxy* message_loop_proxy, | |
| 159 FileSystemOperationContext* context, | 155 FileSystemOperationContext* context, |
| 160 FileSystemFileUtil* file_util, | 156 FileSystemFileUtil* file_util, |
| 161 const FileSystemPath& path, | 157 const FileSystemPath& path, |
| 162 const EnsureFileExistsCallback& callback) { | 158 const EnsureFileExistsCallback& callback) { |
| 163 EnsureFileExistsHelper* helper = new EnsureFileExistsHelper; | 159 EnsureFileExistsHelper* helper = new EnsureFileExistsHelper; |
| 164 return message_loop_proxy->PostTaskAndReply( | 160 return context->file_task_runner()->PostTaskAndReply( |
| 165 FROM_HERE, | 161 FROM_HERE, |
| 166 Bind(&EnsureFileExistsHelper::RunWork, Unretained(helper), | 162 Bind(&EnsureFileExistsHelper::RunWork, Unretained(helper), |
| 167 file_util, context, path), | 163 file_util, context, path), |
| 168 Bind(&EnsureFileExistsHelper::Reply, Owned(helper), callback)); | 164 Bind(&EnsureFileExistsHelper::Reply, Owned(helper), callback)); |
| 169 } | 165 } |
| 170 | 166 |
| 171 // static | 167 // static |
| 172 bool FileSystemFileUtilProxy::CreateDirectory( | 168 bool FileSystemFileUtilProxy::CreateDirectory( |
| 173 MessageLoopProxy* message_loop_proxy, | |
| 174 FileSystemOperationContext* context, | 169 FileSystemOperationContext* context, |
| 175 FileSystemFileUtil* file_util, | 170 FileSystemFileUtil* file_util, |
| 176 const FileSystemPath& path, | 171 const FileSystemPath& path, |
| 177 bool exclusive, | 172 bool exclusive, |
| 178 bool recursive, | 173 bool recursive, |
| 179 const StatusCallback& callback) { | 174 const StatusCallback& callback) { |
| 180 return base::FileUtilProxy::RelayFileTask( | 175 return base::FileUtilProxy::RelayFileTask( |
| 181 message_loop_proxy, FROM_HERE, | 176 context->file_task_runner(), FROM_HERE, |
| 182 Bind(&FileSystemFileUtil::CreateDirectory, Unretained(file_util), | 177 Bind(&FileSystemFileUtil::CreateDirectory, Unretained(file_util), |
| 183 context, path, exclusive, recursive), | 178 context, path, exclusive, recursive), |
| 184 callback); | 179 callback); |
| 185 } | 180 } |
| 186 | 181 |
| 187 // static | 182 // static |
| 188 bool FileSystemFileUtilProxy::GetFileInfo( | 183 bool FileSystemFileUtilProxy::GetFileInfo( |
| 189 MessageLoopProxy* message_loop_proxy, | |
| 190 FileSystemOperationContext* context, | 184 FileSystemOperationContext* context, |
| 191 FileSystemFileUtil* file_util, | 185 FileSystemFileUtil* file_util, |
| 192 const FileSystemPath& path, | 186 const FileSystemPath& path, |
| 193 const GetFileInfoCallback& callback) { | 187 const GetFileInfoCallback& callback) { |
| 194 GetFileInfoHelper* helper = new GetFileInfoHelper; | 188 GetFileInfoHelper* helper = new GetFileInfoHelper; |
| 195 return message_loop_proxy->PostTaskAndReply( | 189 return context->file_task_runner()->PostTaskAndReply( |
| 196 FROM_HERE, | 190 FROM_HERE, |
| 197 Bind(&GetFileInfoHelper::RunWork, Unretained(helper), | 191 Bind(&GetFileInfoHelper::RunWork, Unretained(helper), |
| 198 file_util, context, path), | 192 file_util, context, path), |
| 199 Bind(&GetFileInfoHelper::Reply, Owned(helper), callback)); | 193 Bind(&GetFileInfoHelper::Reply, Owned(helper), callback)); |
| 200 } | 194 } |
| 201 | 195 |
| 202 // static | 196 // static |
| 203 bool FileSystemFileUtilProxy::ReadDirectory( | 197 bool FileSystemFileUtilProxy::ReadDirectory( |
| 204 MessageLoopProxy* message_loop_proxy, | |
| 205 FileSystemOperationContext* context, | 198 FileSystemOperationContext* context, |
| 206 FileSystemFileUtil* file_util, | 199 FileSystemFileUtil* file_util, |
| 207 const FileSystemPath& path, | 200 const FileSystemPath& path, |
| 208 const ReadDirectoryCallback& callback) { | 201 const ReadDirectoryCallback& callback) { |
| 209 ReadDirectoryHelper* helper = new ReadDirectoryHelper; | 202 ReadDirectoryHelper* helper = new ReadDirectoryHelper; |
| 210 return message_loop_proxy->PostTaskAndReply( | 203 return context->file_task_runner()->PostTaskAndReply( |
| 211 FROM_HERE, | 204 FROM_HERE, |
| 212 Bind(&ReadDirectoryHelper::RunWork, Unretained(helper), | 205 Bind(&ReadDirectoryHelper::RunWork, Unretained(helper), |
| 213 file_util, context, path), | 206 file_util, context, path), |
| 214 Bind(&ReadDirectoryHelper::Reply, Owned(helper), callback)); | 207 Bind(&ReadDirectoryHelper::Reply, Owned(helper), callback)); |
| 215 } | 208 } |
| 216 | 209 |
| 217 // static | 210 // static |
| 218 bool FileSystemFileUtilProxy::Touch( | 211 bool FileSystemFileUtilProxy::Touch( |
| 219 MessageLoopProxy* message_loop_proxy, | |
| 220 FileSystemOperationContext* context, | 212 FileSystemOperationContext* context, |
| 221 FileSystemFileUtil* file_util, | 213 FileSystemFileUtil* file_util, |
| 222 const FileSystemPath& path, | 214 const FileSystemPath& path, |
| 223 const base::Time& last_access_time, | 215 const base::Time& last_access_time, |
| 224 const base::Time& last_modified_time, | 216 const base::Time& last_modified_time, |
| 225 const StatusCallback& callback) { | 217 const StatusCallback& callback) { |
| 226 return base::FileUtilProxy::RelayFileTask( | 218 return base::FileUtilProxy::RelayFileTask( |
| 227 message_loop_proxy, FROM_HERE, | 219 context->file_task_runner(), FROM_HERE, |
| 228 Bind(&FileSystemFileUtil::Touch, Unretained(file_util), | 220 Bind(&FileSystemFileUtil::Touch, Unretained(file_util), |
| 229 context, path, last_access_time, last_modified_time), | 221 context, path, last_access_time, last_modified_time), |
| 230 callback); | 222 callback); |
| 231 } | 223 } |
| 232 | 224 |
| 233 // static | 225 // static |
| 234 bool FileSystemFileUtilProxy::Truncate( | 226 bool FileSystemFileUtilProxy::Truncate( |
| 235 MessageLoopProxy* message_loop_proxy, | |
| 236 FileSystemOperationContext* context, | 227 FileSystemOperationContext* context, |
| 237 FileSystemFileUtil* file_util, | 228 FileSystemFileUtil* file_util, |
| 238 const FileSystemPath& path, | 229 const FileSystemPath& path, |
| 239 int64 length, | 230 int64 length, |
| 240 const StatusCallback& callback) { | 231 const StatusCallback& callback) { |
| 241 return base::FileUtilProxy::RelayFileTask( | 232 return base::FileUtilProxy::RelayFileTask( |
| 242 message_loop_proxy, FROM_HERE, | 233 context->file_task_runner(), FROM_HERE, |
| 243 Bind(&FileSystemFileUtil::Truncate, Unretained(file_util), | 234 Bind(&FileSystemFileUtil::Truncate, Unretained(file_util), |
| 244 context, path, length), | 235 context, path, length), |
| 245 callback); | 236 callback); |
| 246 } | 237 } |
| 247 | 238 |
| 248 } // namespace fileapi | 239 } // namespace fileapi |
| OLD | NEW |