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 CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_CREATE_DIRECTORY_OPERATION_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_CREATE_DIRECTORY_OPERATION_H_ |
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_CREATE_DIRECTORY_OPERATION_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_CREATE_DIRECTORY_OPERATION_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 class FileChange; | 22 class FileChange; |
23 class ResourceEntry; | 23 class ResourceEntry; |
24 | 24 |
25 namespace internal { | 25 namespace internal { |
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 Create Directory function. It is | 33 // This class encapsulates the drive Create Directory function. It is |
34 // responsible for sending the request to the drive API, then updating the | 34 // responsible for sending the request to the drive API, then updating the |
35 // local state and metadata to reflect the new state. | 35 // local state and metadata to reflect the new state. |
36 class CreateDirectoryOperation { | 36 class CreateDirectoryOperation { |
37 public: | 37 public: |
38 CreateDirectoryOperation(base::SequencedTaskRunner* blocking_task_runner, | 38 CreateDirectoryOperation(base::SequencedTaskRunner* blocking_task_runner, |
39 OperationObserver* observer, | 39 OperationDelegate* delegate, |
40 internal::ResourceMetadata* metadata); | 40 internal::ResourceMetadata* metadata); |
41 ~CreateDirectoryOperation(); | 41 ~CreateDirectoryOperation(); |
42 | 42 |
43 // Creates a new directory at |directory_path|. | 43 // Creates a new directory at |directory_path|. |
44 // If |is_exclusive| is true, an error is raised in case a directory exists | 44 // If |is_exclusive| is true, an error is raised in case a directory exists |
45 // already at the |directory_path|. | 45 // already at the |directory_path|. |
46 // If |is_recursive| is true, the invocation creates parent directories as | 46 // If |is_recursive| is true, the invocation creates parent directories as |
47 // needed just like mkdir -p does. | 47 // needed just like mkdir -p does. |
48 // Invokes |callback| when finished with the result of the operation. | 48 // Invokes |callback| when finished with the result of the operation. |
49 // |callback| must not be null. | 49 // |callback| must not be null. |
50 void CreateDirectory(const base::FilePath& directory_path, | 50 void CreateDirectory(const base::FilePath& directory_path, |
51 bool is_exclusive, | 51 bool is_exclusive, |
52 bool is_recursive, | 52 bool is_recursive, |
53 const FileOperationCallback& callback); | 53 const FileOperationCallback& callback); |
54 | 54 |
55 private: | 55 private: |
56 // Part of CreateDirectory(). Called after UpdateLocalState(). | 56 // Part of CreateDirectory(). Called after UpdateLocalState(). |
57 void CreateDirectoryAfterUpdateLocalState( | 57 void CreateDirectoryAfterUpdateLocalState( |
58 const FileOperationCallback& callback, | 58 const FileOperationCallback& callback, |
59 const std::set<std::string>* updated_local_ids, | 59 const std::set<std::string>* updated_local_ids, |
60 const FileChange* changed_directories, | 60 const FileChange* changed_directories, |
61 FileError error); | 61 FileError error); |
62 | 62 |
63 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; | 63 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
64 OperationObserver* observer_; | 64 OperationDelegate* delegate_; |
65 internal::ResourceMetadata* metadata_; | 65 internal::ResourceMetadata* metadata_; |
66 | 66 |
67 // Note: This should remain the last member so it'll be destroyed and | 67 // Note: This should remain the last member so it'll be destroyed and |
68 // invalidate the weak pointers before any other members are destroyed. | 68 // invalidate the weak pointers before any other members are destroyed. |
69 base::WeakPtrFactory<CreateDirectoryOperation> weak_ptr_factory_; | 69 base::WeakPtrFactory<CreateDirectoryOperation> weak_ptr_factory_; |
70 DISALLOW_COPY_AND_ASSIGN(CreateDirectoryOperation); | 70 DISALLOW_COPY_AND_ASSIGN(CreateDirectoryOperation); |
71 }; | 71 }; |
72 | 72 |
73 } // namespace file_system | 73 } // namespace file_system |
74 } // namespace drive | 74 } // namespace drive |
75 | 75 |
76 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_CREATE_DIRECTORY_OPERATION_
H_ | 76 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_CREATE_DIRECTORY_OPERATION_
H_ |
OLD | NEW |