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 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_REMOVE_OPERATION_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_REMOVE_OPERATION_H_ |
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_REMOVE_OPERATION_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_REMOVE_OPERATION_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 class ResourceEntry; | 22 class ResourceEntry; |
23 | 23 |
24 namespace internal { | 24 namespace internal { |
25 class FileCache; | 25 class FileCache; |
26 class ResourceMetadata; | 26 class ResourceMetadata; |
27 } // namespace internal | 27 } // namespace internal |
28 | 28 |
29 namespace file_system { | 29 namespace file_system { |
30 | 30 |
31 class OperationObserver; | 31 class OperationDelegate; |
32 | 32 |
33 // This class encapsulates the drive Remove function. It is responsible for | 33 // This class encapsulates the drive Remove function. It is responsible for |
34 // moving the removed entry to the trash. | 34 // moving the removed entry to the trash. |
35 class RemoveOperation { | 35 class RemoveOperation { |
36 public: | 36 public: |
37 RemoveOperation(base::SequencedTaskRunner* blocking_task_runner, | 37 RemoveOperation(base::SequencedTaskRunner* blocking_task_runner, |
38 OperationObserver* observer, | 38 OperationDelegate* delegate, |
39 internal::ResourceMetadata* metadata, | 39 internal::ResourceMetadata* metadata, |
40 internal::FileCache* cache); | 40 internal::FileCache* cache); |
41 ~RemoveOperation(); | 41 ~RemoveOperation(); |
42 | 42 |
43 // Removes the resource at |path|. If |path| is a directory and |is_recursive| | 43 // Removes the resource at |path|. If |path| is a directory and |is_recursive| |
44 // is set, it recursively removes all the descendants. If |is_recursive| is | 44 // is set, it recursively removes all the descendants. If |is_recursive| is |
45 // not set, it succeeds only when the directory is empty. | 45 // not set, it succeeds only when the directory is empty. |
46 // | 46 // |
47 // |callback| must not be null. | 47 // |callback| must not be null. |
48 void Remove(const base::FilePath& path, | 48 void Remove(const base::FilePath& path, |
49 bool is_recursive, | 49 bool is_recursive, |
50 const FileOperationCallback& callback); | 50 const FileOperationCallback& callback); |
51 | 51 |
52 private: | 52 private: |
53 // Part of Remove(). Called after UpdateLocalState() completion. | 53 // Part of Remove(). Called after UpdateLocalState() completion. |
54 void RemoveAfterUpdateLocalState(const FileOperationCallback& callback, | 54 void RemoveAfterUpdateLocalState(const FileOperationCallback& callback, |
55 const std::string* local_id, | 55 const std::string* local_id, |
56 const ResourceEntry* entry, | 56 const ResourceEntry* entry, |
57 const base::FilePath* changed_directory_path, | 57 const base::FilePath* changed_directory_path, |
58 FileError error); | 58 FileError error); |
59 | 59 |
60 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; | 60 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
61 OperationObserver* observer_; | 61 OperationDelegate* delegate_; |
62 internal::ResourceMetadata* metadata_; | 62 internal::ResourceMetadata* metadata_; |
63 internal::FileCache* cache_; | 63 internal::FileCache* cache_; |
64 | 64 |
65 // Note: This should remain the last member so it'll be destroyed and | 65 // Note: This should remain the last member so it'll be destroyed and |
66 // invalidate the weak pointers before any other members are destroyed. | 66 // invalidate the weak pointers before any other members are destroyed. |
67 base::WeakPtrFactory<RemoveOperation> weak_ptr_factory_; | 67 base::WeakPtrFactory<RemoveOperation> weak_ptr_factory_; |
68 DISALLOW_COPY_AND_ASSIGN(RemoveOperation); | 68 DISALLOW_COPY_AND_ASSIGN(RemoveOperation); |
69 }; | 69 }; |
70 | 70 |
71 } // namespace file_system | 71 } // namespace file_system |
72 } // namespace drive | 72 } // namespace drive |
73 | 73 |
74 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_REMOVE_OPERATION_H_ | 74 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_REMOVE_OPERATION_H_ |
OLD | NEW |