| 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_GDATA_GDATA_FILE_SYSTEM_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ | 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 // Fetches the user's Account Metadata to find out current quota information | 365 // Fetches the user's Account Metadata to find out current quota information |
| 366 // and returns it to the callback. | 366 // and returns it to the callback. |
| 367 virtual void GetAvailableSpace(const GetAvailableSpaceCallback& callback) = 0; | 367 virtual void GetAvailableSpace(const GetAvailableSpaceCallback& callback) = 0; |
| 368 | 368 |
| 369 // Pin or unpin file. | 369 // Pin or unpin file. |
| 370 virtual void SetPinState(const FilePath& file_path, bool to_pin, | 370 virtual void SetPinState(const FilePath& file_path, bool to_pin, |
| 371 const FileOperationCallback& callback) = 0; | 371 const FileOperationCallback& callback) = 0; |
| 372 | 372 |
| 373 // Creates a new file from |entry| under |virtual_dir_path|. Stored its | 373 // Creates a new file from |entry| under |virtual_dir_path|. Stored its |
| 374 // content from |file_content_path| into the cache. | 374 // content from |file_content_path| into the cache. |
| 375 virtual void AddUploadedFile( | 375 // |
| 376 const FilePath& virtual_dir_path, | 376 // |callback| will be called on the UI thread upon completion of operation. |
| 377 DocumentEntry* entry, | 377 virtual void AddUploadedFile(const FilePath& virtual_dir_path, |
| 378 const FilePath& file_content_path, | 378 DocumentEntry* entry, |
| 379 GDataCache::FileOperationType cache_operation) = 0; | 379 const FilePath& file_content_path, |
| 380 GDataCache::FileOperationType cache_operation, |
| 381 const base::Closure& callback) = 0; |
| 380 | 382 |
| 381 // Returns true if hosted documents should be hidden. | 383 // Returns true if hosted documents should be hidden. |
| 382 virtual bool hide_hosted_documents() = 0; | 384 virtual bool hide_hosted_documents() = 0; |
| 383 }; | 385 }; |
| 384 | 386 |
| 385 // The production implementation of GDataFileSystemInterface. | 387 // The production implementation of GDataFileSystemInterface. |
| 386 class GDataFileSystem : public GDataFileSystemInterface, | 388 class GDataFileSystem : public GDataFileSystemInterface, |
| 387 public content::NotificationObserver { | 389 public content::NotificationObserver { |
| 388 public: | 390 public: |
| 389 GDataFileSystem( | 391 GDataFileSystem( |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 virtual void ReadDirectoryByPathAsync( | 453 virtual void ReadDirectoryByPathAsync( |
| 452 const FilePath& file_path, | 454 const FilePath& file_path, |
| 453 const ReadDirectoryCallback& callback) OVERRIDE; | 455 const ReadDirectoryCallback& callback) OVERRIDE; |
| 454 virtual void RequestDirectoryRefresh( | 456 virtual void RequestDirectoryRefresh( |
| 455 const FilePath& file_path) OVERRIDE; | 457 const FilePath& file_path) OVERRIDE; |
| 456 virtual void GetAvailableSpace( | 458 virtual void GetAvailableSpace( |
| 457 const GetAvailableSpaceCallback& callback) OVERRIDE; | 459 const GetAvailableSpaceCallback& callback) OVERRIDE; |
| 458 // Calls private Pin or Unpin methods with |callback|. | 460 // Calls private Pin or Unpin methods with |callback|. |
| 459 virtual void SetPinState(const FilePath& file_path, bool pin, | 461 virtual void SetPinState(const FilePath& file_path, bool pin, |
| 460 const FileOperationCallback& callback) OVERRIDE; | 462 const FileOperationCallback& callback) OVERRIDE; |
| 461 virtual void AddUploadedFile( | 463 virtual void AddUploadedFile(const FilePath& virtual_dir_path, |
| 462 const FilePath& virtual_dir_path, | 464 DocumentEntry* entry, |
| 463 DocumentEntry* entry, | 465 const FilePath& file_content_path, |
| 464 const FilePath& file_content_path, | 466 GDataCache::FileOperationType cache_operation, |
| 465 GDataCache::FileOperationType cache_operation) OVERRIDE; | 467 const base::Closure& callback) OVERRIDE; |
| 466 virtual bool hide_hosted_documents() OVERRIDE; | 468 virtual bool hide_hosted_documents() OVERRIDE; |
| 467 | 469 |
| 468 // content::NotificationObserver implementation. | 470 // content::NotificationObserver implementation. |
| 469 virtual void Observe(int type, | 471 virtual void Observe(int type, |
| 470 const content::NotificationSource& source, | 472 const content::NotificationSource& source, |
| 471 const content::NotificationDetails& details) OVERRIDE; | 473 const content::NotificationDetails& details) OVERRIDE; |
| 472 | 474 |
| 473 // Used in tests to inject mock document service. | 475 // Used in tests to inject mock document service. |
| 474 void SetDocumentsServiceForTesting(DocumentsServiceInterface* | 476 void SetDocumentsServiceForTesting(DocumentsServiceInterface* |
| 475 new_document_service) { | 477 new_document_service) { |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 990 void NotifyInitialLoadFinished(); | 992 void NotifyInitialLoadFinished(); |
| 991 void NotifyDocumentFeedFetched(int num_accumulated_entries); | 993 void NotifyDocumentFeedFetched(int num_accumulated_entries); |
| 992 | 994 |
| 993 // Helper function that completes bookkeeping tasks related to | 995 // Helper function that completes bookkeeping tasks related to |
| 994 // completed file transfer. | 996 // completed file transfer. |
| 995 void OnTransferCompleted( | 997 void OnTransferCompleted( |
| 996 const FileOperationCallback& callback, | 998 const FileOperationCallback& callback, |
| 997 base::PlatformFileError error, | 999 base::PlatformFileError error, |
| 998 UploadFileInfo* upload_file_info); | 1000 UploadFileInfo* upload_file_info); |
| 999 | 1001 |
| 1002 // Helper function called upon completion of AddUploadFile invoked by |
| 1003 // OnTransferCompleted. |
| 1004 void OnAddUploadFileCompleted( |
| 1005 const FileOperationCallback& callback, |
| 1006 base::PlatformFileError error, |
| 1007 UploadFileInfo* upload_file_info); |
| 1008 |
| 1000 // Kicks off file upload once it receives |upload_file_info|. | 1009 // Kicks off file upload once it receives |upload_file_info|. |
| 1001 void StartFileUploadOnUIThread( | 1010 void StartFileUploadOnUIThread( |
| 1002 const FileOperationCallback& callback, | 1011 const FileOperationCallback& callback, |
| 1003 base::PlatformFileError* error, | 1012 base::PlatformFileError* error, |
| 1004 UploadFileInfo* upload_file_info); | 1013 UploadFileInfo* upload_file_info); |
| 1005 | 1014 |
| 1006 // Cache entry points from within GDataFileSystem. | 1015 // Cache entry points from within GDataFileSystem. |
| 1007 // The functionalities of GData blob cache include: | 1016 // The functionalities of GData blob cache include: |
| 1008 // - stores downloaded gdata files on disk, indexed by the resource_id and md5 | 1017 // - stores downloaded gdata files on disk, indexed by the resource_id and md5 |
| 1009 // of the gdata file. | 1018 // of the gdata file. |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1407 void RequestDirectoryRefreshOnUIThread( | 1416 void RequestDirectoryRefreshOnUIThread( |
| 1408 const FilePath& file_path); | 1417 const FilePath& file_path); |
| 1409 void OnRequestDirectoryRefresh(GetDocumentsParams* params, | 1418 void OnRequestDirectoryRefresh(GetDocumentsParams* params, |
| 1410 base::PlatformFileError error); | 1419 base::PlatformFileError error); |
| 1411 void GetCacheStateOnUIThread(const std::string& resource_id, | 1420 void GetCacheStateOnUIThread(const std::string& resource_id, |
| 1412 const std::string& md5, | 1421 const std::string& md5, |
| 1413 const GetCacheStateCallback& callback); | 1422 const GetCacheStateCallback& callback); |
| 1414 void GetAvailableSpaceOnUIThread(const GetAvailableSpaceCallback& callback); | 1423 void GetAvailableSpaceOnUIThread(const GetAvailableSpaceCallback& callback); |
| 1415 void SetPinStateOnUIThread(const FilePath& file_path, bool to_pin, | 1424 void SetPinStateOnUIThread(const FilePath& file_path, bool to_pin, |
| 1416 const FileOperationCallback& callback); | 1425 const FileOperationCallback& callback); |
| 1426 void AddUploadedFileOnUIThread(const FilePath& virtual_dir_path, |
| 1427 DocumentEntry* entry, |
| 1428 const FilePath& file_content_path, |
| 1429 GDataCache::FileOperationType cache_operation, |
| 1430 const base::Closure& callback); |
| 1417 | 1431 |
| 1418 scoped_ptr<GDataRootDirectory> root_; | 1432 scoped_ptr<GDataRootDirectory> root_; |
| 1419 | 1433 |
| 1420 // This guards regular states. | 1434 // This guards regular states. |
| 1421 base::Lock lock_; | 1435 base::Lock lock_; |
| 1422 | 1436 |
| 1423 // The profile hosts the GDataFileSystem via GDataSystemService. | 1437 // The profile hosts the GDataFileSystem via GDataSystemService. |
| 1424 Profile* profile_; | 1438 Profile* profile_; |
| 1425 | 1439 |
| 1426 // The cache owned by GDataSystemService. | 1440 // The cache owned by GDataSystemService. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1455 | 1469 |
| 1456 ObserverList<Observer> observers_; | 1470 ObserverList<Observer> observers_; |
| 1457 | 1471 |
| 1458 // The token is used to post tasks to the blocking pool in sequence. | 1472 // The token is used to post tasks to the blocking pool in sequence. |
| 1459 const base::SequencedWorkerPool::SequenceToken sequence_token_; | 1473 const base::SequencedWorkerPool::SequenceToken sequence_token_; |
| 1460 }; | 1474 }; |
| 1461 | 1475 |
| 1462 } // namespace gdata | 1476 } // namespace gdata |
| 1463 | 1477 |
| 1464 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ | 1478 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ |
| OLD | NEW |