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_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_H_ |
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 | 162 |
163 // Used in tests to update the file system from |feed_list|. | 163 // Used in tests to update the file system from |feed_list|. |
164 // See also the comment at ChangeListLoader::UpdateFromFeed(). | 164 // See also the comment at ChangeListLoader::UpdateFromFeed(). |
165 internal::ChangeListLoader* change_list_loader() { | 165 internal::ChangeListLoader* change_list_loader() { |
166 return change_list_loader_.get(); | 166 return change_list_loader_.get(); |
167 } | 167 } |
168 | 168 |
169 private: | 169 private: |
170 friend class DriveFileSystemTest; | 170 friend class DriveFileSystemTest; |
171 | 171 |
172 // Defines set of parameters passed to an intermediate callback | |
173 // OnGetFileCompleteForOpen, during execution of OpenFile() method. | |
174 struct GetFileCompleteForOpenParams; | |
175 | |
176 // Defines set of parameters for GetResolvedFileByPath(). | |
177 struct GetResolvedFileParams; | |
178 | |
179 // Used to implement Reload(). | 172 // Used to implement Reload(). |
180 void ReloadAfterReset(FileError error); | 173 void ReloadAfterReset(FileError error); |
181 | 174 |
182 // Sets up ChangeListLoader. | 175 // Sets up ChangeListLoader. |
183 void SetupChangeListLoader(); | 176 void SetupChangeListLoader(); |
184 | 177 |
185 // Called on preference change. | 178 // Called on preference change. |
186 void OnDisableDriveHostedFilesChanged(); | 179 void OnDisableDriveHostedFilesChanged(); |
187 | 180 |
188 // Part of CreateDirectory(). Called after ChangeListLoader::LoadIfNeeded() | 181 // Part of CreateDirectory(). Called after ChangeListLoader::LoadIfNeeded() |
189 // is called and made sure that the resource metadata is loaded. | 182 // is called and made sure that the resource metadata is loaded. |
190 void CreateDirectoryAfterLoad(const base::FilePath& directory_path, | 183 void CreateDirectoryAfterLoad(const base::FilePath& directory_path, |
191 bool is_exclusive, | 184 bool is_exclusive, |
192 bool is_recursive, | 185 bool is_recursive, |
193 const FileOperationCallback& callback, | 186 const FileOperationCallback& callback, |
194 FileError load_error); | 187 FileError load_error); |
195 | 188 |
196 // Used to implement Pin(). | 189 // Used to implement Pin(). |
197 void PinAfterGetResourceEntryByPath(const FileOperationCallback& callback, | 190 void PinAfterGetResourceEntryByPath(const FileOperationCallback& callback, |
198 FileError error, | 191 FileError error, |
199 scoped_ptr<ResourceEntry> entry); | 192 scoped_ptr<ResourceEntry> entry); |
200 | 193 |
201 // Used to implement Unpin(). | 194 // Used to implement Unpin(). |
202 void UnpinAfterGetResourceEntryByPath(const FileOperationCallback& callback, | 195 void UnpinAfterGetResourceEntryByPath(const FileOperationCallback& callback, |
203 FileError error, | 196 FileError error, |
204 scoped_ptr<ResourceEntry> entry); | 197 scoped_ptr<ResourceEntry> entry); |
205 | 198 |
206 // Invoked upon completion of GetResourceEntryByPath initiated by | 199 // Part of OpenFile(). Called after the file downloading is completed. |
207 // GetFileByPath. It then continues to invoke GetResolvedFileByPath. | 200 void OpenFileAfterFileDownloaded( |
208 // |callback| must not be null. | |
209 void OnGetResourceEntryCompleteForGetFileByPath( | |
210 const base::FilePath& file_path, | |
211 const GetFileCallback& callback, | |
212 FileError error, | |
213 scoped_ptr<ResourceEntry> file_info); | |
214 | |
215 // Invoked upon completion of GetResourceEntryByPath initiated by OpenFile. | |
216 // It then continues to invoke GetResolvedFileByPath and proceeds to | |
217 // OnGetFileCompleteForOpenFile. | |
218 void OnGetResourceEntryCompleteForOpenFile( | |
219 const base::FilePath& file_path, | 201 const base::FilePath& file_path, |
220 const OpenFileCallback& callback, | 202 const OpenFileCallback& callback, |
221 FileError error, | 203 FileError error, |
222 scoped_ptr<ResourceEntry> file_info); | 204 const base::FilePath& local_file_path, |
| 205 scoped_ptr<ResourceEntry> entry); |
| 206 |
| 207 // Part of OpenFile(). Called after the cache file is marked dirty. |
| 208 void OpenFileAfterMarkDirty( |
| 209 const std::string& resource_id, |
| 210 const std::string& md5, |
| 211 const OpenFileCallback& callback, |
| 212 FileError error); |
223 | 213 |
224 // Invoked at the last step of OpenFile. It removes |file_path| from the | 214 // Invoked at the last step of OpenFile. It removes |file_path| from the |
225 // current set of opened files if |result| is an error, and then invokes the | 215 // current set of opened files if |result| is an error, and then invokes the |
226 // |callback| function. | 216 // |callback| function. |
227 void OnOpenFileFinished(const base::FilePath& file_path, | 217 void OnOpenFileFinished(const base::FilePath& file_path, |
228 const OpenFileCallback& callback, | 218 const OpenFileCallback& callback, |
229 FileError result, | 219 FileError result, |
230 const base::FilePath& cache_file_path); | 220 const base::FilePath& cache_file_path); |
231 | 221 |
232 // Invoked during the process of CloseFile. What is done here is as follows: | 222 // Invoked during the process of CloseFile. What is done here is as follows: |
233 // 1) Gets resource_id and md5 of the entry at |file_path|. | 223 // 1) Gets resource_id and md5 of the entry at |file_path|. |
234 // 2) Commits the modification to the cache system. | 224 // 2) Commits the modification to the cache system. |
235 // 3) Removes the |file_path| from the remembered set of opened files. | 225 // 3) Removes the |file_path| from the remembered set of opened files. |
236 // 4) Invokes the user-supplied |callback|. | 226 // 4) Invokes the user-supplied |callback|. |
237 // |callback| must not be null. | 227 // |callback| must not be null. |
238 void CloseFileAfterGetResourceEntry(const base::FilePath& file_path, | 228 void CloseFileAfterGetResourceEntry(const base::FilePath& file_path, |
239 const FileOperationCallback& callback, | 229 const FileOperationCallback& callback, |
240 FileError error, | 230 FileError error, |
241 scoped_ptr<ResourceEntry> entry); | 231 scoped_ptr<ResourceEntry> entry); |
242 void CloseFileFinalize(const base::FilePath& file_path, | 232 void CloseFileFinalize(const base::FilePath& file_path, |
243 const FileOperationCallback& callback, | 233 const FileOperationCallback& callback, |
244 FileError result); | 234 FileError result); |
245 | 235 |
246 // Invoked upon completion of GetFileByPath initiated by OpenFile. If | |
247 // GetFileByPath is successful, calls MarkDirtyInCache to mark the cache | |
248 // file as dirty for the file identified by |file_info.resource_id| and | |
249 // |file_info.md5|. | |
250 void OnGetFileCompleteForOpenFile(const GetFileCompleteForOpenParams& params, | |
251 FileError error, | |
252 const base::FilePath& file_path, | |
253 scoped_ptr<ResourceEntry> entry); | |
254 | |
255 // Invoked upon completion of MarkDirtyInCache initiated by OpenFile. | |
256 void OnMarkDirtyInCacheCompleteForOpenFile( | |
257 const GetFileCompleteForOpenParams& params, | |
258 FileError error); | |
259 | |
260 // Callback for handling about resource fetch. | 236 // Callback for handling about resource fetch. |
261 void OnGetAboutResource( | 237 void OnGetAboutResource( |
262 const GetAvailableSpaceCallback& callback, | 238 const GetAvailableSpaceCallback& callback, |
263 google_apis::GDataErrorCode status, | 239 google_apis::GDataErrorCode status, |
264 scoped_ptr<google_apis::AboutResource> about_resource); | 240 scoped_ptr<google_apis::AboutResource> about_resource); |
265 | 241 |
266 // Callback for handling results of ReloadFeedFromServerIfNeeded() initiated | 242 // Callback for handling results of ReloadFeedFromServerIfNeeded() initiated |
267 // from CheckForUpdates(). | 243 // from CheckForUpdates(). |
268 void OnUpdateChecked(FileError error); | 244 void OnUpdateChecked(FileError error); |
269 | 245 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 // |callback| must not be null. | 284 // |callback| must not be null. |
309 void ReadDirectoryByPathAfterLoad( | 285 void ReadDirectoryByPathAfterLoad( |
310 const base::FilePath& directory_path, | 286 const base::FilePath& directory_path, |
311 const ReadDirectoryWithSettingCallback& callback, | 287 const ReadDirectoryWithSettingCallback& callback, |
312 FileError error); | 288 FileError error); |
313 void ReadDirectoryByPathAfterRead( | 289 void ReadDirectoryByPathAfterRead( |
314 const ReadDirectoryWithSettingCallback& callback, | 290 const ReadDirectoryWithSettingCallback& callback, |
315 FileError error, | 291 FileError error, |
316 scoped_ptr<ResourceEntryVector> entries); | 292 scoped_ptr<ResourceEntryVector> entries); |
317 | 293 |
318 // Gets the file at |file_path| from the cache (if found in the cache), | |
319 // or the server (if not found in the cache) after the file info is | |
320 // already resolved with GetResourceEntryByPath() or GetResourceEntryById(). | |
321 void GetResolvedFileByPath(scoped_ptr<GetResolvedFileParams> params); | |
322 void GetResolvedFileByPathAfterCreateDocumentJsonFile( | |
323 scoped_ptr<GetResolvedFileParams> params, | |
324 const base::FilePath* file_path, | |
325 FileError error); | |
326 void GetResolvedFileByPathAfterGetFileFromCache( | |
327 scoped_ptr<GetResolvedFileParams> params, | |
328 FileError error, | |
329 const base::FilePath& cache_file_path); | |
330 void GetResolvedFileByPathAfterGetResourceEntry( | |
331 scoped_ptr<GetResolvedFileParams> params, | |
332 google_apis::GDataErrorCode status, | |
333 scoped_ptr<google_apis::ResourceEntry> entry); | |
334 void GetResolvedFileByPathAfterRefreshEntry( | |
335 scoped_ptr<GetResolvedFileParams> params, | |
336 const GURL& download_url, | |
337 FileError error, | |
338 const base::FilePath& drive_file_path, | |
339 scoped_ptr<ResourceEntry> entry); | |
340 void GetResolvedFileByPathAfterFreeDiskSpace( | |
341 scoped_ptr<GetResolvedFileParams> params, | |
342 const GURL& download_url, | |
343 bool has_enough_space); | |
344 void GetResolveFileByPathAfterCreateTemporaryFile( | |
345 scoped_ptr<GetResolvedFileParams> params, | |
346 const GURL& download_url, | |
347 base::FilePath* temp_file, | |
348 bool success); | |
349 void GetResolvedFileByPathAfterDownloadFile( | |
350 scoped_ptr<GetResolvedFileParams> params, | |
351 google_apis::GDataErrorCode status, | |
352 const base::FilePath& downloaded_file_path); | |
353 void GetResolvedFileByPathAfterGetCacheEntryForCancel( | |
354 const std::string& resource_id, | |
355 const std::string& md5, | |
356 bool success, | |
357 const FileCacheEntry& cache_entry); | |
358 void GetResolvedFileByPathAfterStore( | |
359 scoped_ptr<GetResolvedFileParams> params, | |
360 const base::FilePath& downloaded_file_path, | |
361 FileError error); | |
362 void GetResolvedFileByPathAfterGetFile( | |
363 scoped_ptr<GetResolvedFileParams> params, | |
364 FileError error, | |
365 const base::FilePath& cache_file); | |
366 | |
367 // Part of GetResourceEntryById(). Called after | 294 // Part of GetResourceEntryById(). Called after |
368 // ResourceMetadata::GetResourceEntryById() is complete. | 295 // ResourceMetadata::GetResourceEntryById() is complete. |
369 // |callback| must not be null. | 296 // |callback| must not be null. |
370 void GetResourceEntryByIdAfterGetEntry( | 297 void GetResourceEntryByIdAfterGetEntry( |
371 const GetResourceEntryWithFilePathCallback& callback, | 298 const GetResourceEntryWithFilePathCallback& callback, |
372 FileError error, | 299 FileError error, |
373 const base::FilePath& file_path, | 300 const base::FilePath& file_path, |
374 scoped_ptr<ResourceEntry> entry); | 301 scoped_ptr<ResourceEntry> entry); |
375 | 302 |
376 // Part of GetFileByResourceId(). Called after | 303 // Part of GetFileByResourceId(). Called after |
377 // ResourceMetadata::GetResourceEntryById() is complete. | 304 // ResourceMetadata::GetResourceEntryById() is complete. |
378 // |get_file_callback| must not be null. | 305 // |get_file_callback| must not be null. |
379 // |get_content_callback| may be null. | 306 // |get_content_callback| may be null. |
380 void GetFileByResourceIdAfterGetEntry( | 307 void GetFileByResourceIdAfterGetEntry( |
381 const DriveClientContext& context, | 308 const DriveClientContext& context, |
382 const GetFileCallback& get_file_callback, | 309 const GetFileCallback& get_file_callback, |
383 const google_apis::GetContentCallback& get_content_callback, | 310 const google_apis::GetContentCallback& get_content_callback, |
384 FileError error, | 311 FileError error, |
385 const base::FilePath& file_path, | 312 const base::FilePath& file_path, |
386 scoped_ptr<ResourceEntry> entry); | 313 scoped_ptr<ResourceEntry> entry); |
387 | 314 |
388 // Part of GetFileContentByPath(). Called after | |
389 // ResourceMetadata::GetResourceEntryByPath() is complete. | |
390 // |initialized_callback|, |get_content_callback| and |completion_callback| | |
391 // must not be null. | |
392 void GetFileContentByPathAfterGetEntry( | |
393 const base::FilePath& file_path, | |
394 const GetFileContentInitializedCallback& initialized_callback, | |
395 const google_apis::GetContentCallback& get_content_callback, | |
396 const FileOperationCallback& completion_callback, | |
397 FileError error, | |
398 scoped_ptr<ResourceEntry> entry); | |
399 | |
400 // Part of RefreshDirectory(). Called after | 315 // Part of RefreshDirectory(). Called after |
401 // GetResourceEntryByPath() is complete. | 316 // GetResourceEntryByPath() is complete. |
402 void RefreshDirectoryAfterGetResourceEntry( | 317 void RefreshDirectoryAfterGetResourceEntry( |
403 const base::FilePath& directory_path, | 318 const base::FilePath& directory_path, |
404 const FileOperationCallback& callback, | 319 const FileOperationCallback& callback, |
405 FileError error, | 320 FileError error, |
406 scoped_ptr<ResourceEntry> entry); | 321 scoped_ptr<ResourceEntry> entry); |
407 | 322 |
408 // Part of GetEntryByResourceId and GetEntryByPath. Checks whether there is a | 323 // Part of GetEntryByResourceId and GetEntryByPath. Checks whether there is a |
409 // local dirty cache for the entry, and if there is, replace the | 324 // local dirty cache for the entry, and if there is, replace the |
(...skipping 17 matching lines...) Expand all Loading... |
427 base::PlatformFileInfo* file_info, | 342 base::PlatformFileInfo* file_info, |
428 bool get_file_info_result); | 343 bool get_file_info_result); |
429 | 344 |
430 // Part of MarkCacheFileAsMounted. Called after GetResourceEntryByPath is | 345 // Part of MarkCacheFileAsMounted. Called after GetResourceEntryByPath is |
431 // completed. |callback| must not be null. | 346 // completed. |callback| must not be null. |
432 void MarkCacheFileAsMountedAfterGetResourceEntry( | 347 void MarkCacheFileAsMountedAfterGetResourceEntry( |
433 const OpenFileCallback& callback, | 348 const OpenFileCallback& callback, |
434 FileError error, | 349 FileError error, |
435 scoped_ptr<ResourceEntry> entry); | 350 scoped_ptr<ResourceEntry> entry); |
436 | 351 |
437 // Cancels the job with |id| in the scheduler. | |
438 void CancelJobInScheduler(JobID id); | |
439 | |
440 // The profile hosts the FileSystem via DriveIntegrationService. | 352 // The profile hosts the FileSystem via DriveIntegrationService. |
441 Profile* profile_; | 353 Profile* profile_; |
442 | 354 |
443 // Sub components owned by DriveIntegrationService. | 355 // Sub components owned by DriveIntegrationService. |
444 internal::FileCache* cache_; | 356 internal::FileCache* cache_; |
445 google_apis::DriveServiceInterface* drive_service_; | 357 google_apis::DriveServiceInterface* drive_service_; |
446 JobScheduler* scheduler_; | 358 JobScheduler* scheduler_; |
447 internal::ResourceMetadata* resource_metadata_; | 359 internal::ResourceMetadata* resource_metadata_; |
448 | 360 |
449 // Time of the last update check. | 361 // Time of the last update check. |
(...skipping 25 matching lines...) Expand all Loading... |
475 // Note: This should remain the last member so it'll be destroyed and | 387 // Note: This should remain the last member so it'll be destroyed and |
476 // invalidate the weak pointers before any other members are destroyed. | 388 // invalidate the weak pointers before any other members are destroyed. |
477 base::WeakPtrFactory<FileSystem> weak_ptr_factory_; | 389 base::WeakPtrFactory<FileSystem> weak_ptr_factory_; |
478 | 390 |
479 DISALLOW_COPY_AND_ASSIGN(FileSystem); | 391 DISALLOW_COPY_AND_ASSIGN(FileSystem); |
480 }; | 392 }; |
481 | 393 |
482 } // namespace drive | 394 } // namespace drive |
483 | 395 |
484 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_H_ | 396 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_H_ |
OLD | NEW |