OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/message_loop_proxy.h" | 7 #include "base/message_loop_proxy.h" |
8 #include "webkit/fileapi/file_system_context.h" | 8 #include "webkit/fileapi/file_system_context.h" |
9 #include "webkit/fileapi/file_system_file_util.h" | 9 #include "webkit/fileapi/file_system_file_util.h" |
10 #include "webkit/fileapi/file_system_operation_context.h" | 10 #include "webkit/fileapi/file_system_operation_context.h" |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 FilePath file_path_; | 246 FilePath file_path_; |
247 base::PlatformFileInfo file_info_; | 247 base::PlatformFileInfo file_info_; |
248 FilePath platform_path_; | 248 FilePath platform_path_; |
249 }; | 249 }; |
250 | 250 |
251 class RelayReadDirectory : public MessageLoopRelay { | 251 class RelayReadDirectory : public MessageLoopRelay { |
252 public: | 252 public: |
253 RelayReadDirectory( | 253 RelayReadDirectory( |
254 const fileapi::FileSystemOperationContext& context, | 254 const fileapi::FileSystemOperationContext& context, |
255 const FilePath& file_path, | 255 const FilePath& file_path, |
256 fileapi::FileSystemFileUtilProxy::ReadDirectoryCallback* callback) | 256 const fileapi::FileSystemFileUtilProxy::ReadDirectoryCallback& callback) |
257 : MessageLoopRelay(context), | 257 : MessageLoopRelay(context), |
258 callback_(callback), file_path_(file_path) { | 258 callback_(callback), file_path_(file_path) { |
259 DCHECK(callback); | 259 DCHECK_EQ(false, callback.is_null()); |
260 } | 260 } |
261 | 261 |
262 protected: | 262 protected: |
263 virtual void RunWork() { | 263 virtual void RunWork() { |
264 // TODO(kkanetkar): Implement directory read in multiple chunks. | 264 // TODO(kkanetkar): Implement directory read in multiple chunks. |
265 set_error_code(file_util()->ReadDirectory( | 265 set_error_code(file_util()->ReadDirectory( |
266 context(), file_path_, &entries_)); | 266 context(), file_path_, &entries_)); |
267 } | 267 } |
268 | 268 |
269 virtual void RunCallback() { | 269 virtual void RunCallback() { |
270 callback_->Run(error_code(), entries_); | 270 callback_.Run(error_code(), entries_); |
271 delete callback_; | |
272 } | 271 } |
273 | 272 |
274 private: | 273 private: |
275 fileapi::FileSystemFileUtilProxy::ReadDirectoryCallback* callback_; | 274 fileapi::FileSystemFileUtilProxy::ReadDirectoryCallback callback_; |
276 FilePath file_path_; | 275 FilePath file_path_; |
277 std::vector<base::FileUtilProxy::Entry> entries_; | 276 std::vector<base::FileUtilProxy::Entry> entries_; |
278 }; | 277 }; |
279 | 278 |
280 class RelayCreateDirectory : public RelayWithStatusCallback { | 279 class RelayCreateDirectory : public RelayWithStatusCallback { |
281 public: | 280 public: |
282 RelayCreateDirectory( | 281 RelayCreateDirectory( |
283 const fileapi::FileSystemOperationContext& context, | 282 const fileapi::FileSystemOperationContext& context, |
284 const FilePath& file_path, | 283 const FilePath& file_path, |
285 bool exclusive, | 284 bool exclusive, |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 const GetFileInfoCallback& callback) { | 471 const GetFileInfoCallback& callback) { |
473 return Start(FROM_HERE, message_loop_proxy, new RelayGetFileInfo(context, | 472 return Start(FROM_HERE, message_loop_proxy, new RelayGetFileInfo(context, |
474 file_path, callback)); | 473 file_path, callback)); |
475 } | 474 } |
476 | 475 |
477 // static | 476 // static |
478 bool FileSystemFileUtilProxy::ReadDirectory( | 477 bool FileSystemFileUtilProxy::ReadDirectory( |
479 const FileSystemOperationContext& context, | 478 const FileSystemOperationContext& context, |
480 scoped_refptr<MessageLoopProxy> message_loop_proxy, | 479 scoped_refptr<MessageLoopProxy> message_loop_proxy, |
481 const FilePath& file_path, | 480 const FilePath& file_path, |
482 ReadDirectoryCallback* callback) { | 481 const ReadDirectoryCallback& callback) { |
483 return Start(FROM_HERE, message_loop_proxy, new RelayReadDirectory(context, | 482 return Start(FROM_HERE, message_loop_proxy, new RelayReadDirectory(context, |
484 file_path, callback)); | 483 file_path, callback)); |
485 } | 484 } |
486 | 485 |
487 // static | 486 // static |
488 bool FileSystemFileUtilProxy::CreateDirectory( | 487 bool FileSystemFileUtilProxy::CreateDirectory( |
489 const FileSystemOperationContext& context, | 488 const FileSystemOperationContext& context, |
490 scoped_refptr<MessageLoopProxy> message_loop_proxy, | 489 scoped_refptr<MessageLoopProxy> message_loop_proxy, |
491 const FilePath& file_path, | 490 const FilePath& file_path, |
492 bool exclusive, | 491 bool exclusive, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 const FileSystemOperationContext& context, | 548 const FileSystemOperationContext& context, |
550 scoped_refptr<MessageLoopProxy> message_loop_proxy, | 549 scoped_refptr<MessageLoopProxy> message_loop_proxy, |
551 const FilePath& path, | 550 const FilePath& path, |
552 int64 length, | 551 int64 length, |
553 StatusCallback* callback) { | 552 StatusCallback* callback) { |
554 return Start(FROM_HERE, message_loop_proxy, | 553 return Start(FROM_HERE, message_loop_proxy, |
555 new RelayTruncate(context, path, length, callback)); | 554 new RelayTruncate(context, path, length, callback)); |
556 } | 555 } |
557 | 556 |
558 } // namespace fileapi | 557 } // namespace fileapi |
OLD | NEW |