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 #include "chrome/browser/chromeos/file_system_provider/provided_file_system.h" | 5 #include "chrome/browser/chromeos/file_system_provider/provided_file_system.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/files/file.h" | 8 #include "base/files/file.h" |
9 #include "chrome/browser/chromeos/file_system_provider/notification_manager.h" | 9 #include "chrome/browser/chromeos/file_system_provider/notification_manager.h" |
10 #include "chrome/browser/chromeos/file_system_provider/operations/close_file.h" | 10 #include "chrome/browser/chromeos/file_system_provider/operations/close_file.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 file_system_info_(file_system_info), | 40 file_system_info_(file_system_info), |
41 notification_manager_( | 41 notification_manager_( |
42 new NotificationManager(profile_, file_system_info_)), | 42 new NotificationManager(profile_, file_system_info_)), |
43 request_manager_(notification_manager_.get()), | 43 request_manager_(notification_manager_.get()), |
44 weak_ptr_factory_(this) { | 44 weak_ptr_factory_(this) { |
45 } | 45 } |
46 | 46 |
47 ProvidedFileSystem::~ProvidedFileSystem() {} | 47 ProvidedFileSystem::~ProvidedFileSystem() {} |
48 | 48 |
49 void ProvidedFileSystem::RequestUnmount( | 49 void ProvidedFileSystem::RequestUnmount( |
50 const fileapi::AsyncFileUtil::StatusCallback& callback) { | 50 const storage::AsyncFileUtil::StatusCallback& callback) { |
51 if (!request_manager_.CreateRequest( | 51 if (!request_manager_.CreateRequest( |
52 REQUEST_UNMOUNT, | 52 REQUEST_UNMOUNT, |
53 scoped_ptr<RequestManager::HandlerInterface>(new operations::Unmount( | 53 scoped_ptr<RequestManager::HandlerInterface>(new operations::Unmount( |
54 event_router_, file_system_info_, callback)))) { | 54 event_router_, file_system_info_, callback)))) { |
55 callback.Run(base::File::FILE_ERROR_SECURITY); | 55 callback.Run(base::File::FILE_ERROR_SECURITY); |
56 } | 56 } |
57 } | 57 } |
58 | 58 |
59 void ProvidedFileSystem::GetMetadata(const base::FilePath& entry_path, | 59 void ProvidedFileSystem::GetMetadata(const base::FilePath& entry_path, |
60 const GetMetadataCallback& callback) { | 60 const GetMetadataCallback& callback) { |
61 if (!request_manager_.CreateRequest( | 61 if (!request_manager_.CreateRequest( |
62 GET_METADATA, | 62 GET_METADATA, |
63 scoped_ptr<RequestManager::HandlerInterface>( | 63 scoped_ptr<RequestManager::HandlerInterface>( |
64 new operations::GetMetadata( | 64 new operations::GetMetadata( |
65 event_router_, file_system_info_, entry_path, callback)))) { | 65 event_router_, file_system_info_, entry_path, callback)))) { |
66 callback.Run(EntryMetadata(), base::File::FILE_ERROR_SECURITY); | 66 callback.Run(EntryMetadata(), base::File::FILE_ERROR_SECURITY); |
67 } | 67 } |
68 } | 68 } |
69 | 69 |
70 void ProvidedFileSystem::ReadDirectory( | 70 void ProvidedFileSystem::ReadDirectory( |
71 const base::FilePath& directory_path, | 71 const base::FilePath& directory_path, |
72 const fileapi::AsyncFileUtil::ReadDirectoryCallback& callback) { | 72 const storage::AsyncFileUtil::ReadDirectoryCallback& callback) { |
73 if (!request_manager_.CreateRequest( | 73 if (!request_manager_.CreateRequest( |
74 READ_DIRECTORY, | 74 READ_DIRECTORY, |
75 scoped_ptr< | 75 scoped_ptr< |
76 RequestManager::HandlerInterface>(new operations::ReadDirectory( | 76 RequestManager::HandlerInterface>(new operations::ReadDirectory( |
77 event_router_, file_system_info_, directory_path, callback)))) { | 77 event_router_, file_system_info_, directory_path, callback)))) { |
78 callback.Run(base::File::FILE_ERROR_SECURITY, | 78 callback.Run(base::File::FILE_ERROR_SECURITY, |
79 fileapi::AsyncFileUtil::EntryList(), | 79 storage::AsyncFileUtil::EntryList(), |
80 false /* has_more */); | 80 false /* has_more */); |
81 } | 81 } |
82 } | 82 } |
83 | 83 |
84 void ProvidedFileSystem::ReadFile(int file_handle, | 84 void ProvidedFileSystem::ReadFile(int file_handle, |
85 net::IOBuffer* buffer, | 85 net::IOBuffer* buffer, |
86 int64 offset, | 86 int64 offset, |
87 int length, | 87 int length, |
88 const ReadChunkReceivedCallback& callback) { | 88 const ReadChunkReceivedCallback& callback) { |
89 TRACE_EVENT1( | 89 TRACE_EVENT1( |
(...skipping 24 matching lines...) Expand all Loading... |
114 file_system_info_, | 114 file_system_info_, |
115 file_path, | 115 file_path, |
116 mode, | 116 mode, |
117 callback)))) { | 117 callback)))) { |
118 callback.Run(0 /* file_handle */, base::File::FILE_ERROR_SECURITY); | 118 callback.Run(0 /* file_handle */, base::File::FILE_ERROR_SECURITY); |
119 } | 119 } |
120 } | 120 } |
121 | 121 |
122 void ProvidedFileSystem::CloseFile( | 122 void ProvidedFileSystem::CloseFile( |
123 int file_handle, | 123 int file_handle, |
124 const fileapi::AsyncFileUtil::StatusCallback& callback) { | 124 const storage::AsyncFileUtil::StatusCallback& callback) { |
125 if (!request_manager_.CreateRequest( | 125 if (!request_manager_.CreateRequest( |
126 CLOSE_FILE, | 126 CLOSE_FILE, |
127 scoped_ptr<RequestManager::HandlerInterface>( | 127 scoped_ptr<RequestManager::HandlerInterface>( |
128 new operations::CloseFile( | 128 new operations::CloseFile( |
129 event_router_, file_system_info_, file_handle, callback)))) { | 129 event_router_, file_system_info_, file_handle, callback)))) { |
130 callback.Run(base::File::FILE_ERROR_SECURITY); | 130 callback.Run(base::File::FILE_ERROR_SECURITY); |
131 } | 131 } |
132 } | 132 } |
133 | 133 |
134 void ProvidedFileSystem::CreateDirectory( | 134 void ProvidedFileSystem::CreateDirectory( |
135 const base::FilePath& directory_path, | 135 const base::FilePath& directory_path, |
136 bool exclusive, | 136 bool exclusive, |
137 bool recursive, | 137 bool recursive, |
138 const fileapi::AsyncFileUtil::StatusCallback& callback) { | 138 const storage::AsyncFileUtil::StatusCallback& callback) { |
139 if (!request_manager_.CreateRequest( | 139 if (!request_manager_.CreateRequest( |
140 CREATE_DIRECTORY, | 140 CREATE_DIRECTORY, |
141 scoped_ptr<RequestManager::HandlerInterface>( | 141 scoped_ptr<RequestManager::HandlerInterface>( |
142 new operations::CreateDirectory(event_router_, | 142 new operations::CreateDirectory(event_router_, |
143 file_system_info_, | 143 file_system_info_, |
144 directory_path, | 144 directory_path, |
145 exclusive, | 145 exclusive, |
146 recursive, | 146 recursive, |
147 callback)))) { | 147 callback)))) { |
148 callback.Run(base::File::FILE_ERROR_SECURITY); | 148 callback.Run(base::File::FILE_ERROR_SECURITY); |
149 } | 149 } |
150 } | 150 } |
151 | 151 |
152 void ProvidedFileSystem::DeleteEntry( | 152 void ProvidedFileSystem::DeleteEntry( |
153 const base::FilePath& entry_path, | 153 const base::FilePath& entry_path, |
154 bool recursive, | 154 bool recursive, |
155 const fileapi::AsyncFileUtil::StatusCallback& callback) { | 155 const storage::AsyncFileUtil::StatusCallback& callback) { |
156 if (!request_manager_.CreateRequest( | 156 if (!request_manager_.CreateRequest( |
157 DELETE_ENTRY, | 157 DELETE_ENTRY, |
158 scoped_ptr<RequestManager::HandlerInterface>( | 158 scoped_ptr<RequestManager::HandlerInterface>( |
159 new operations::DeleteEntry(event_router_, | 159 new operations::DeleteEntry(event_router_, |
160 file_system_info_, | 160 file_system_info_, |
161 entry_path, | 161 entry_path, |
162 recursive, | 162 recursive, |
163 callback)))) { | 163 callback)))) { |
164 callback.Run(base::File::FILE_ERROR_SECURITY); | 164 callback.Run(base::File::FILE_ERROR_SECURITY); |
165 } | 165 } |
166 } | 166 } |
167 | 167 |
168 void ProvidedFileSystem::CreateFile( | 168 void ProvidedFileSystem::CreateFile( |
169 const base::FilePath& file_path, | 169 const base::FilePath& file_path, |
170 const fileapi::AsyncFileUtil::StatusCallback& callback) { | 170 const storage::AsyncFileUtil::StatusCallback& callback) { |
171 if (!request_manager_.CreateRequest( | 171 if (!request_manager_.CreateRequest( |
172 CREATE_FILE, | 172 CREATE_FILE, |
173 scoped_ptr<RequestManager::HandlerInterface>( | 173 scoped_ptr<RequestManager::HandlerInterface>( |
174 new operations::CreateFile( | 174 new operations::CreateFile( |
175 event_router_, file_system_info_, file_path, callback)))) { | 175 event_router_, file_system_info_, file_path, callback)))) { |
176 callback.Run(base::File::FILE_ERROR_SECURITY); | 176 callback.Run(base::File::FILE_ERROR_SECURITY); |
177 } | 177 } |
178 } | 178 } |
179 | 179 |
180 void ProvidedFileSystem::CopyEntry( | 180 void ProvidedFileSystem::CopyEntry( |
181 const base::FilePath& source_path, | 181 const base::FilePath& source_path, |
182 const base::FilePath& target_path, | 182 const base::FilePath& target_path, |
183 const fileapi::AsyncFileUtil::StatusCallback& callback) { | 183 const storage::AsyncFileUtil::StatusCallback& callback) { |
184 if (!request_manager_.CreateRequest( | 184 if (!request_manager_.CreateRequest( |
185 COPY_ENTRY, | 185 COPY_ENTRY, |
186 scoped_ptr<RequestManager::HandlerInterface>( | 186 scoped_ptr<RequestManager::HandlerInterface>( |
187 new operations::CopyEntry(event_router_, | 187 new operations::CopyEntry(event_router_, |
188 file_system_info_, | 188 file_system_info_, |
189 source_path, | 189 source_path, |
190 target_path, | 190 target_path, |
191 callback)))) { | 191 callback)))) { |
192 callback.Run(base::File::FILE_ERROR_SECURITY); | 192 callback.Run(base::File::FILE_ERROR_SECURITY); |
193 } | 193 } |
194 } | 194 } |
195 | 195 |
196 void ProvidedFileSystem::WriteFile( | 196 void ProvidedFileSystem::WriteFile( |
197 int file_handle, | 197 int file_handle, |
198 net::IOBuffer* buffer, | 198 net::IOBuffer* buffer, |
199 int64 offset, | 199 int64 offset, |
200 int length, | 200 int length, |
201 const fileapi::AsyncFileUtil::StatusCallback& callback) { | 201 const storage::AsyncFileUtil::StatusCallback& callback) { |
202 TRACE_EVENT1("file_system_provider", | 202 TRACE_EVENT1("file_system_provider", |
203 "ProvidedFileSystem::WriteFile", | 203 "ProvidedFileSystem::WriteFile", |
204 "length", | 204 "length", |
205 length); | 205 length); |
206 if (!request_manager_.CreateRequest( | 206 if (!request_manager_.CreateRequest( |
207 WRITE_FILE, | 207 WRITE_FILE, |
208 make_scoped_ptr<RequestManager::HandlerInterface>( | 208 make_scoped_ptr<RequestManager::HandlerInterface>( |
209 new operations::WriteFile(event_router_, | 209 new operations::WriteFile(event_router_, |
210 file_system_info_, | 210 file_system_info_, |
211 file_handle, | 211 file_handle, |
212 make_scoped_refptr(buffer), | 212 make_scoped_refptr(buffer), |
213 offset, | 213 offset, |
214 length, | 214 length, |
215 callback)))) { | 215 callback)))) { |
216 callback.Run(base::File::FILE_ERROR_SECURITY); | 216 callback.Run(base::File::FILE_ERROR_SECURITY); |
217 } | 217 } |
218 } | 218 } |
219 | 219 |
220 void ProvidedFileSystem::MoveEntry( | 220 void ProvidedFileSystem::MoveEntry( |
221 const base::FilePath& source_path, | 221 const base::FilePath& source_path, |
222 const base::FilePath& target_path, | 222 const base::FilePath& target_path, |
223 const fileapi::AsyncFileUtil::StatusCallback& callback) { | 223 const storage::AsyncFileUtil::StatusCallback& callback) { |
224 if (!request_manager_.CreateRequest( | 224 if (!request_manager_.CreateRequest( |
225 MOVE_ENTRY, | 225 MOVE_ENTRY, |
226 scoped_ptr<RequestManager::HandlerInterface>( | 226 scoped_ptr<RequestManager::HandlerInterface>( |
227 new operations::MoveEntry(event_router_, | 227 new operations::MoveEntry(event_router_, |
228 file_system_info_, | 228 file_system_info_, |
229 source_path, | 229 source_path, |
230 target_path, | 230 target_path, |
231 callback)))) { | 231 callback)))) { |
232 callback.Run(base::File::FILE_ERROR_SECURITY); | 232 callback.Run(base::File::FILE_ERROR_SECURITY); |
233 } | 233 } |
234 } | 234 } |
235 | 235 |
236 void ProvidedFileSystem::Truncate( | 236 void ProvidedFileSystem::Truncate( |
237 const base::FilePath& file_path, | 237 const base::FilePath& file_path, |
238 int64 length, | 238 int64 length, |
239 const fileapi::AsyncFileUtil::StatusCallback& callback) { | 239 const storage::AsyncFileUtil::StatusCallback& callback) { |
240 if (!request_manager_.CreateRequest( | 240 if (!request_manager_.CreateRequest( |
241 TRUNCATE, | 241 TRUNCATE, |
242 scoped_ptr<RequestManager::HandlerInterface>( | 242 scoped_ptr<RequestManager::HandlerInterface>( |
243 new operations::Truncate(event_router_, | 243 new operations::Truncate(event_router_, |
244 file_system_info_, | 244 file_system_info_, |
245 file_path, | 245 file_path, |
246 length, | 246 length, |
247 callback)))) { | 247 callback)))) { |
248 callback.Run(base::File::FILE_ERROR_SECURITY); | 248 callback.Run(base::File::FILE_ERROR_SECURITY); |
249 } | 249 } |
250 } | 250 } |
251 | 251 |
252 const ProvidedFileSystemInfo& ProvidedFileSystem::GetFileSystemInfo() const { | 252 const ProvidedFileSystemInfo& ProvidedFileSystem::GetFileSystemInfo() const { |
253 return file_system_info_; | 253 return file_system_info_; |
254 } | 254 } |
255 | 255 |
256 RequestManager* ProvidedFileSystem::GetRequestManager() { | 256 RequestManager* ProvidedFileSystem::GetRequestManager() { |
257 return &request_manager_; | 257 return &request_manager_; |
258 } | 258 } |
259 | 259 |
260 base::WeakPtr<ProvidedFileSystemInterface> ProvidedFileSystem::GetWeakPtr() { | 260 base::WeakPtr<ProvidedFileSystemInterface> ProvidedFileSystem::GetWeakPtr() { |
261 return weak_ptr_factory_.GetWeakPtr(); | 261 return weak_ptr_factory_.GetWeakPtr(); |
262 } | 262 } |
263 | 263 |
264 } // namespace file_system_provider | 264 } // namespace file_system_provider |
265 } // namespace chromeos | 265 } // namespace chromeos |
OLD | NEW |