| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #ifndef WEBKIT_FILEAPI_REMOVE_OPERATION_DELEGATE_H_ | 5 #ifndef WEBKIT_FILEAPI_REMOVE_OPERATION_DELEGATE_H_ |
| 6 #define WEBKIT_FILEAPI_REMOVE_OPERATION_DELEGATE_H_ | 6 #define WEBKIT_FILEAPI_REMOVE_OPERATION_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <queue> | |
| 9 #include <stack> | 8 #include <stack> |
| 10 | 9 |
| 11 #include "base/basictypes.h" | 10 #include "webkit/fileapi/recursive_operation_delegate.h" |
| 12 #include "base/callback.h" | |
| 13 #include "base/memory/weak_ptr.h" | |
| 14 #include "webkit/fileapi/file_system_operation.h" | |
| 15 #include "webkit/fileapi/file_system_url.h" | |
| 16 | 11 |
| 17 namespace fileapi { | 12 namespace fileapi { |
| 18 | 13 |
| 19 class FileSystemURL; | |
| 20 class LocalFileSystemOperation; | |
| 21 | |
| 22 class RemoveOperationDelegate | 14 class RemoveOperationDelegate |
| 23 : public base::SupportsWeakPtr<RemoveOperationDelegate> { | 15 : public RecursiveOperationDelegate, |
| 16 public base::SupportsWeakPtr<RemoveOperationDelegate> { |
| 24 public: | 17 public: |
| 25 typedef FileSystemOperation::StatusCallback StatusCallback; | |
| 26 typedef FileSystemOperation::FileEntryList FileEntryList; | |
| 27 | |
| 28 RemoveOperationDelegate(LocalFileSystemOperation* original_operation, | 18 RemoveOperationDelegate(LocalFileSystemOperation* original_operation, |
| 19 const FileSystemURL& url, |
| 29 const StatusCallback& callback); | 20 const StatusCallback& callback); |
| 30 virtual ~RemoveOperationDelegate(); | 21 virtual ~RemoveOperationDelegate(); |
| 31 | 22 |
| 32 void Run(const FileSystemURL& url); | 23 // RecursiveOperationDelegate overrides: |
| 33 void RunRecursively(const FileSystemURL& url); | 24 virtual void Run() OVERRIDE; |
| 25 virtual void RunRecursively() OVERRIDE; |
| 26 virtual void ProcessFile(const FileSystemURL& url, |
| 27 const StatusCallback& callback) OVERRIDE; |
| 28 virtual void ProcessDirectory(const FileSystemURL& url, |
| 29 const StatusCallback& callback) OVERRIDE; |
| 30 |
| 31 using base::SupportsWeakPtr<RemoveOperationDelegate>::AsWeakPtr; |
| 34 | 32 |
| 35 private: | 33 private: |
| 36 void ProcessNextDirectory(base::PlatformFileError error); | 34 void DidTryRemoveFile(base::PlatformFileError error); |
| 37 void DidTryRemoveFile( | 35 void DidRemoveFile(const StatusCallback& callback, |
| 38 const FileSystemURL& url, | 36 base::PlatformFileError error); |
| 39 base::PlatformFileError error); | |
| 40 void DidReadDirectory( | |
| 41 const FileSystemURL& parent, | |
| 42 base::PlatformFileError error, | |
| 43 const FileEntryList& entries, | |
| 44 bool has_more); | |
| 45 void RemoveFile(const FileSystemURL& url); | |
| 46 void DidRemoveFile(base::PlatformFileError error); | |
| 47 void RemoveNextDirectory(base::PlatformFileError error); | 37 void RemoveNextDirectory(base::PlatformFileError error); |
| 48 | 38 |
| 49 LocalFileSystemOperation* NewOperation(const FileSystemURL& url); | 39 FileSystemURL url_; |
| 50 | |
| 51 LocalFileSystemOperation* original_operation_; | |
| 52 StatusCallback callback_; | 40 StatusCallback callback_; |
| 53 | 41 |
| 54 std::queue<FileSystemURL> pending_directories_; | |
| 55 std::stack<FileSystemURL> to_remove_directories_; | 42 std::stack<FileSystemURL> to_remove_directories_; |
| 56 | 43 |
| 57 int inflight_operations_; | |
| 58 | |
| 59 DISALLOW_COPY_AND_ASSIGN(RemoveOperationDelegate); | 44 DISALLOW_COPY_AND_ASSIGN(RemoveOperationDelegate); |
| 60 }; | 45 }; |
| 61 | 46 |
| 62 } // namespace fileapi | 47 } // namespace fileapi |
| 63 | 48 |
| 64 #endif // WEBKIT_FILEAPI_REMOVE_OPERATION_DELEGATE_H_ | 49 #endif // WEBKIT_FILEAPI_REMOVE_OPERATION_DELEGATE_H_ |
| OLD | NEW |