Chromium Code Reviews| 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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 185 delete callback_; | 185 delete callback_; |
| 186 } | 186 } |
| 187 | 187 |
| 188 private: | 188 private: |
| 189 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; | 189 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; |
| 190 FilePath file_path_; | 190 FilePath file_path_; |
| 191 fileapi::FileSystemFileUtilProxy::EnsureFileExistsCallback* callback_; | 191 fileapi::FileSystemFileUtilProxy::EnsureFileExistsCallback* callback_; |
| 192 bool created_; | 192 bool created_; |
| 193 }; | 193 }; |
| 194 | 194 |
| 195 | |
| 196 class RelayGetLocalPath : public MessageLoopRelay { | |
| 197 public: | |
| 198 RelayGetLocalPath( | |
| 199 const fileapi::FileSystemOperationContext& context, | |
| 200 const FilePath& virtual_path, | |
| 201 fileapi::FileSystemFileUtilProxy::GetGetLocalPath* callback) | |
| 202 : MessageLoopRelay(context), | |
| 203 callback_(callback), | |
| 204 virtual_path_(virtual_path) { | |
| 205 DCHECK(callback); | |
| 206 } | |
| 207 | |
| 208 protected: | |
| 209 virtual void RunWork() { | |
| 210 set_error_code( | |
| 211 file_system_file_util()->GetLocalFilePath( | |
| 212 context(), virtual_path_, &local_path_)); | |
| 213 } | |
| 214 | |
| 215 virtual void RunCallback() { | |
| 216 callback_->Run(error_code(), local_path_); | |
| 217 delete callback_; | |
| 218 } | |
| 219 | |
| 220 private: | |
| 221 fileapi::FileSystemFileUtilProxy::GetGetLocalPath* callback_; | |
| 222 FilePath virtual_path_; | |
| 223 FilePath local_path_; | |
| 224 }; | |
| 225 | |
| 195 class RelayGetFileInfo : public MessageLoopRelay { | 226 class RelayGetFileInfo : public MessageLoopRelay { |
| 196 public: | 227 public: |
| 197 RelayGetFileInfo( | 228 RelayGetFileInfo( |
| 198 const fileapi::FileSystemOperationContext& context, | 229 const fileapi::FileSystemOperationContext& context, |
| 199 const FilePath& file_path, | 230 const FilePath& file_path, |
| 200 fileapi::FileSystemFileUtilProxy::GetFileInfoCallback* callback) | 231 fileapi::FileSystemFileUtilProxy::GetFileInfoCallback* callback) |
| 201 : MessageLoopRelay(context), | 232 : MessageLoopRelay(context), |
| 202 callback_(callback), | 233 callback_(callback), |
| 203 file_path_(file_path) { | 234 file_path_(file_path) { |
| 204 DCHECK(callback); | 235 DCHECK(callback); |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 430 // static | 461 // static |
| 431 bool FileSystemFileUtilProxy::EnsureFileExists( | 462 bool FileSystemFileUtilProxy::EnsureFileExists( |
| 432 const FileSystemOperationContext& context, | 463 const FileSystemOperationContext& context, |
| 433 scoped_refptr<MessageLoopProxy> message_loop_proxy, | 464 scoped_refptr<MessageLoopProxy> message_loop_proxy, |
| 434 const FilePath& file_path, | 465 const FilePath& file_path, |
| 435 EnsureFileExistsCallback* callback) { | 466 EnsureFileExistsCallback* callback) { |
| 436 return Start(FROM_HERE, message_loop_proxy, new RelayEnsureFileExists( | 467 return Start(FROM_HERE, message_loop_proxy, new RelayEnsureFileExists( |
| 437 context, message_loop_proxy, file_path, callback)); | 468 context, message_loop_proxy, file_path, callback)); |
| 438 } | 469 } |
| 439 | 470 |
| 471 // Retrieves the information about a file local path. | |
|
ericu
2011/04/19 20:30:49
Remove the comment, replace with "// static".
Woul
zel
2011/04/19 23:14:00
Done.
| |
| 472 bool FileSystemFileUtilProxy::GetLocalPath( | |
| 473 const FileSystemOperationContext& context, | |
| 474 scoped_refptr<MessageLoopProxy> message_loop_proxy, | |
| 475 const FilePath& virtual_path, | |
| 476 GetGetLocalPath* callback) { | |
| 477 return Start(FROM_HERE, message_loop_proxy, | |
| 478 new RelayGetLocalPath(context, virtual_path, callback)); | |
| 479 } | |
| 480 | |
| 440 // Retrieves the information about a file. It is invalid to pass NULL for the | 481 // Retrieves the information about a file. It is invalid to pass NULL for the |
| 441 // callback. | 482 // callback. |
| 442 bool FileSystemFileUtilProxy::GetFileInfo( | 483 bool FileSystemFileUtilProxy::GetFileInfo( |
| 443 const FileSystemOperationContext& context, | 484 const FileSystemOperationContext& context, |
| 444 scoped_refptr<MessageLoopProxy> message_loop_proxy, | 485 scoped_refptr<MessageLoopProxy> message_loop_proxy, |
| 445 const FilePath& file_path, | 486 const FilePath& file_path, |
| 446 GetFileInfoCallback* callback) { | 487 GetFileInfoCallback* callback) { |
| 447 return Start(FROM_HERE, message_loop_proxy, new RelayGetFileInfo(context, | 488 return Start(FROM_HERE, message_loop_proxy, new RelayGetFileInfo(context, |
| 448 file_path, callback)); | 489 file_path, callback)); |
| 449 } | 490 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 523 const FileSystemOperationContext& context, | 564 const FileSystemOperationContext& context, |
| 524 scoped_refptr<MessageLoopProxy> message_loop_proxy, | 565 scoped_refptr<MessageLoopProxy> message_loop_proxy, |
| 525 const FilePath& path, | 566 const FilePath& path, |
| 526 int64 length, | 567 int64 length, |
| 527 StatusCallback* callback) { | 568 StatusCallback* callback) { |
| 528 return Start(FROM_HERE, message_loop_proxy, | 569 return Start(FROM_HERE, message_loop_proxy, |
| 529 new RelayTruncate(context, path, length, callback)); | 570 new RelayTruncate(context, path, length, callback)); |
| 530 } | 571 } |
| 531 | 572 |
| 532 } // namespace fileapi | 573 } // namespace fileapi |
| OLD | NEW |