OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_INTERF
ACE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_INTERF
ACE_H_ |
6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_INTERF
ACE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_INTERF
ACE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 OpenFileCallback; | 53 OpenFileCallback; |
54 | 54 |
55 typedef base::Callback< | 55 typedef base::Callback< |
56 void(int chunk_length, bool has_more, base::File::Error result)> | 56 void(int chunk_length, bool has_more, base::File::Error result)> |
57 ReadChunkReceivedCallback; | 57 ReadChunkReceivedCallback; |
58 | 58 |
59 typedef base::Callback<void(const EntryMetadata& entry_metadata, | 59 typedef base::Callback<void(const EntryMetadata& entry_metadata, |
60 base::File::Error result)> GetMetadataCallback; | 60 base::File::Error result)> GetMetadataCallback; |
61 | 61 |
62 typedef base::Callback<void( | 62 typedef base::Callback<void( |
63 const fileapi::AsyncFileUtil::StatusCallback& callback)> AbortCallback; | 63 const storage::AsyncFileUtil::StatusCallback& callback)> AbortCallback; |
64 | 64 |
65 // Mode of opening a file. Used by OpenFile(). | 65 // Mode of opening a file. Used by OpenFile(). |
66 enum OpenFileMode { OPEN_FILE_MODE_READ, OPEN_FILE_MODE_WRITE }; | 66 enum OpenFileMode { OPEN_FILE_MODE_READ, OPEN_FILE_MODE_WRITE }; |
67 | 67 |
68 virtual ~ProvidedFileSystemInterface() {} | 68 virtual ~ProvidedFileSystemInterface() {} |
69 | 69 |
70 // Requests unmounting of the file system. The callback is called when the | 70 // Requests unmounting of the file system. The callback is called when the |
71 // request is accepted or rejected, with an error code. | 71 // request is accepted or rejected, with an error code. |
72 virtual AbortCallback RequestUnmount( | 72 virtual AbortCallback RequestUnmount( |
73 const fileapi::AsyncFileUtil::StatusCallback& callback) = 0; | 73 const storage::AsyncFileUtil::StatusCallback& callback) = 0; |
74 | 74 |
75 // Requests metadata of the passed |entry_path|. It can be either a file | 75 // Requests metadata of the passed |entry_path|. It can be either a file |
76 // or a directory. | 76 // or a directory. |
77 virtual AbortCallback GetMetadata(const base::FilePath& entry_path, | 77 virtual AbortCallback GetMetadata(const base::FilePath& entry_path, |
78 const GetMetadataCallback& callback) = 0; | 78 const GetMetadataCallback& callback) = 0; |
79 | 79 |
80 // Requests enumerating entries from the passed |directory_path|. The callback | 80 // Requests enumerating entries from the passed |directory_path|. The callback |
81 // can be called multiple times until |has_more| is set to false. | 81 // can be called multiple times until |has_more| is set to false. |
82 virtual AbortCallback ReadDirectory( | 82 virtual AbortCallback ReadDirectory( |
83 const base::FilePath& directory_path, | 83 const base::FilePath& directory_path, |
84 const fileapi::AsyncFileUtil::ReadDirectoryCallback& callback) = 0; | 84 const storage::AsyncFileUtil::ReadDirectoryCallback& callback) = 0; |
85 | 85 |
86 // Requests opening a file at |file_path|. If the file doesn't exist, then the | 86 // Requests opening a file at |file_path|. If the file doesn't exist, then the |
87 // operation will fail. | 87 // operation will fail. |
88 virtual AbortCallback OpenFile(const base::FilePath& file_path, | 88 virtual AbortCallback OpenFile(const base::FilePath& file_path, |
89 OpenFileMode mode, | 89 OpenFileMode mode, |
90 const OpenFileCallback& callback) = 0; | 90 const OpenFileCallback& callback) = 0; |
91 | 91 |
92 // Requests closing a file, previously opened with OpenFile() as a file with | 92 // Requests closing a file, previously opened with OpenFile() as a file with |
93 // |file_handle|. For either succes or error |callback| must be called. | 93 // |file_handle|. For either succes or error |callback| must be called. |
94 virtual AbortCallback CloseFile( | 94 virtual AbortCallback CloseFile( |
95 int file_handle, | 95 int file_handle, |
96 const fileapi::AsyncFileUtil::StatusCallback& callback) = 0; | 96 const storage::AsyncFileUtil::StatusCallback& callback) = 0; |
97 | 97 |
98 // Requests reading a file previously opened with |file_handle|. The callback | 98 // Requests reading a file previously opened with |file_handle|. The callback |
99 // can be called multiple times until |has_more| is set to false. On success | 99 // can be called multiple times until |has_more| is set to false. On success |
100 // it should return |length| bytes starting from |offset| in total. It can | 100 // it should return |length| bytes starting from |offset| in total. It can |
101 // return less only in case EOF is encountered. | 101 // return less only in case EOF is encountered. |
102 virtual AbortCallback ReadFile(int file_handle, | 102 virtual AbortCallback ReadFile(int file_handle, |
103 net::IOBuffer* buffer, | 103 net::IOBuffer* buffer, |
104 int64 offset, | 104 int64 offset, |
105 int length, | 105 int length, |
106 const ReadChunkReceivedCallback& callback) = 0; | 106 const ReadChunkReceivedCallback& callback) = 0; |
107 | 107 |
108 // Requests creating a directory. If |recursive| is passed, then all non | 108 // Requests creating a directory. If |recursive| is passed, then all non |
109 // existing directories on the path will be created. If |exclusive| is true, | 109 // existing directories on the path will be created. If |exclusive| is true, |
110 // then creating the directory will fail, if it already exists. | 110 // then creating the directory will fail, if it already exists. |
111 virtual AbortCallback CreateDirectory( | 111 virtual AbortCallback CreateDirectory( |
112 const base::FilePath& directory_path, | 112 const base::FilePath& directory_path, |
113 bool exclusive, | 113 bool exclusive, |
114 bool recursive, | 114 bool recursive, |
115 const fileapi::AsyncFileUtil::StatusCallback& callback) = 0; | 115 const storage::AsyncFileUtil::StatusCallback& callback) = 0; |
116 | 116 |
117 // Requests creating a file. If the entry already exists, then the | 117 // Requests creating a file. If the entry already exists, then the |
118 // FILE_ERROR_EXISTS error must be returned. | 118 // FILE_ERROR_EXISTS error must be returned. |
119 virtual AbortCallback CreateFile( | 119 virtual AbortCallback CreateFile( |
120 const base::FilePath& file_path, | 120 const base::FilePath& file_path, |
121 const fileapi::AsyncFileUtil::StatusCallback& callback) = 0; | 121 const storage::AsyncFileUtil::StatusCallback& callback) = 0; |
122 | 122 |
123 // Requests deleting a directory. If |recursive| is passed and the entry is | 123 // Requests deleting a directory. If |recursive| is passed and the entry is |
124 // a directory, then all contents of it (recursively) will be deleted too. | 124 // a directory, then all contents of it (recursively) will be deleted too. |
125 virtual AbortCallback DeleteEntry( | 125 virtual AbortCallback DeleteEntry( |
126 const base::FilePath& entry_path, | 126 const base::FilePath& entry_path, |
127 bool recursive, | 127 bool recursive, |
128 const fileapi::AsyncFileUtil::StatusCallback& callback) = 0; | 128 const storage::AsyncFileUtil::StatusCallback& callback) = 0; |
129 | 129 |
130 // Requests copying an entry (recursively in case of a directory) within the | 130 // Requests copying an entry (recursively in case of a directory) within the |
131 // same file system. | 131 // same file system. |
132 virtual AbortCallback CopyEntry( | 132 virtual AbortCallback CopyEntry( |
133 const base::FilePath& source_path, | 133 const base::FilePath& source_path, |
134 const base::FilePath& target_path, | 134 const base::FilePath& target_path, |
135 const fileapi::AsyncFileUtil::StatusCallback& callback) = 0; | 135 const storage::AsyncFileUtil::StatusCallback& callback) = 0; |
136 | 136 |
137 // Requests moving an entry (recursively in case of a directory) within the | 137 // Requests moving an entry (recursively in case of a directory) within the |
138 // same file system. | 138 // same file system. |
139 virtual AbortCallback MoveEntry( | 139 virtual AbortCallback MoveEntry( |
140 const base::FilePath& source_path, | 140 const base::FilePath& source_path, |
141 const base::FilePath& target_path, | 141 const base::FilePath& target_path, |
142 const fileapi::AsyncFileUtil::StatusCallback& callback) = 0; | 142 const storage::AsyncFileUtil::StatusCallback& callback) = 0; |
143 | 143 |
144 // Requests truncating a file to the desired length. | 144 // Requests truncating a file to the desired length. |
145 virtual AbortCallback Truncate( | 145 virtual AbortCallback Truncate( |
146 const base::FilePath& file_path, | 146 const base::FilePath& file_path, |
147 int64 length, | 147 int64 length, |
148 const fileapi::AsyncFileUtil::StatusCallback& callback) = 0; | 148 const storage::AsyncFileUtil::StatusCallback& callback) = 0; |
149 | 149 |
150 // Requests writing to a file previously opened with |file_handle|. | 150 // Requests writing to a file previously opened with |file_handle|. |
151 virtual AbortCallback WriteFile( | 151 virtual AbortCallback WriteFile( |
152 int file_handle, | 152 int file_handle, |
153 net::IOBuffer* buffer, | 153 net::IOBuffer* buffer, |
154 int64 offset, | 154 int64 offset, |
155 int length, | 155 int length, |
156 const fileapi::AsyncFileUtil::StatusCallback& callback) = 0; | 156 const storage::AsyncFileUtil::StatusCallback& callback) = 0; |
157 | 157 |
158 // Returns a provided file system info for this file system. | 158 // Returns a provided file system info for this file system. |
159 virtual const ProvidedFileSystemInfo& GetFileSystemInfo() const = 0; | 159 virtual const ProvidedFileSystemInfo& GetFileSystemInfo() const = 0; |
160 | 160 |
161 // Returns a request manager for the file system. | 161 // Returns a request manager for the file system. |
162 virtual RequestManager* GetRequestManager() = 0; | 162 virtual RequestManager* GetRequestManager() = 0; |
163 | 163 |
164 // Returns a weak pointer to this object. | 164 // Returns a weak pointer to this object. |
165 virtual base::WeakPtr<ProvidedFileSystemInterface> GetWeakPtr() = 0; | 165 virtual base::WeakPtr<ProvidedFileSystemInterface> GetWeakPtr() = 0; |
166 }; | 166 }; |
167 | 167 |
168 } // namespace file_system_provider | 168 } // namespace file_system_provider |
169 } // namespace chromeos | 169 } // namespace chromeos |
170 | 170 |
171 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_INT
ERFACE_H_ | 171 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_INT
ERFACE_H_ |
OLD | NEW |