| 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 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
| 16 #include "base/platform_file.h" | 16 #include "base/platform_file.h" |
| 17 #include "base/timer.h" | 17 #include "base/timer.h" |
| 18 #include "chrome/browser/api/prefs/pref_change_registrar.h" | 18 #include "chrome/browser/api/prefs/pref_change_registrar.h" |
| 19 #include "chrome/browser/chromeos/gdata/drive_cache.h" |
| 19 #include "chrome/browser/chromeos/gdata/drive_resource_metadata.h" | 20 #include "chrome/browser/chromeos/gdata/drive_resource_metadata.h" |
| 20 #include "chrome/browser/chromeos/gdata/gdata_cache.h" | |
| 21 #include "chrome/browser/chromeos/gdata/gdata_errorcode.h" | 21 #include "chrome/browser/chromeos/gdata/gdata_errorcode.h" |
| 22 #include "chrome/browser/chromeos/gdata/gdata_file_system_interface.h" | 22 #include "chrome/browser/chromeos/gdata/gdata_file_system_interface.h" |
| 23 #include "chrome/browser/chromeos/gdata/gdata_wapi_feed_loader.h" | 23 #include "chrome/browser/chromeos/gdata/gdata_wapi_feed_loader.h" |
| 24 #include "chrome/browser/chromeos/gdata/gdata_wapi_feed_processor.h" | 24 #include "chrome/browser/chromeos/gdata/gdata_wapi_feed_processor.h" |
| 25 #include "content/public/browser/notification_observer.h" | 25 #include "content/public/browser/notification_observer.h" |
| 26 | 26 |
| 27 namespace base { | 27 namespace base { |
| 28 class SequencedTaskRunner; | 28 class SequencedTaskRunner; |
| 29 } | 29 } |
| 30 | 30 |
| 31 namespace gdata { | 31 namespace gdata { |
| 32 | 32 |
| 33 class DriveServiceInterface; | 33 class DriveServiceInterface; |
| 34 class DriveWebAppsRegistryInterface; | 34 class DriveWebAppsRegistryInterface; |
| 35 class GDataUploaderInterface; | 35 class GDataUploaderInterface; |
| 36 class GDataWapiFeedLoader; | 36 class GDataWapiFeedLoader; |
| 37 struct UploadFileInfo; | 37 struct UploadFileInfo; |
| 38 | 38 |
| 39 // The production implementation of GDataFileSystemInterface. | 39 // The production implementation of GDataFileSystemInterface. |
| 40 class GDataFileSystem : public GDataFileSystemInterface, | 40 class GDataFileSystem : public GDataFileSystemInterface, |
| 41 public GDataWapiFeedLoader::Observer, | 41 public GDataWapiFeedLoader::Observer, |
| 42 public content::NotificationObserver { | 42 public content::NotificationObserver { |
| 43 public: | 43 public: |
| 44 GDataFileSystem(Profile* profile, | 44 GDataFileSystem(Profile* profile, |
| 45 GDataCache* cache, | 45 DriveCache* cache, |
| 46 DriveServiceInterface* drive_service, | 46 DriveServiceInterface* drive_service, |
| 47 GDataUploaderInterface* uploader, | 47 GDataUploaderInterface* uploader, |
| 48 DriveWebAppsRegistryInterface* webapps_registry, | 48 DriveWebAppsRegistryInterface* webapps_registry, |
| 49 base::SequencedTaskRunner* blocking_task_runner); | 49 base::SequencedTaskRunner* blocking_task_runner); |
| 50 virtual ~GDataFileSystem(); | 50 virtual ~GDataFileSystem(); |
| 51 | 51 |
| 52 // GDataFileSystem overrides. | 52 // GDataFileSystem overrides. |
| 53 virtual void Initialize() OVERRIDE; | 53 virtual void Initialize() OVERRIDE; |
| 54 virtual void AddObserver( | 54 virtual void AddObserver( |
| 55 GDataFileSystemInterface::Observer* observer) OVERRIDE; | 55 GDataFileSystemInterface::Observer* observer) OVERRIDE; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 const FilePath& file_path, | 112 const FilePath& file_path, |
| 113 const ReadDirectoryWithSettingCallback& callback) OVERRIDE; | 113 const ReadDirectoryWithSettingCallback& callback) OVERRIDE; |
| 114 virtual void RequestDirectoryRefresh( | 114 virtual void RequestDirectoryRefresh( |
| 115 const FilePath& file_path) OVERRIDE; | 115 const FilePath& file_path) OVERRIDE; |
| 116 virtual void GetAvailableSpace( | 116 virtual void GetAvailableSpace( |
| 117 const GetAvailableSpaceCallback& callback) OVERRIDE; | 117 const GetAvailableSpaceCallback& callback) OVERRIDE; |
| 118 virtual void AddUploadedFile(UploadMode upload_mode, | 118 virtual void AddUploadedFile(UploadMode upload_mode, |
| 119 const FilePath& virtual_dir_path, | 119 const FilePath& virtual_dir_path, |
| 120 scoped_ptr<DocumentEntry> entry, | 120 scoped_ptr<DocumentEntry> entry, |
| 121 const FilePath& file_content_path, | 121 const FilePath& file_content_path, |
| 122 GDataCache::FileOperationType cache_operation, | 122 DriveCache::FileOperationType cache_operation, |
| 123 const base::Closure& callback) OVERRIDE; | 123 const base::Closure& callback) OVERRIDE; |
| 124 virtual void UpdateEntryData(const std::string& resource_id, | 124 virtual void UpdateEntryData(const std::string& resource_id, |
| 125 const std::string& md5, | 125 const std::string& md5, |
| 126 scoped_ptr<DocumentEntry> entry, | 126 scoped_ptr<DocumentEntry> entry, |
| 127 const FilePath& file_content_path, | 127 const FilePath& file_content_path, |
| 128 const base::Closure& callback) OVERRIDE; | 128 const base::Closure& callback) OVERRIDE; |
| 129 | 129 |
| 130 // content::NotificationObserver implementation. | 130 // content::NotificationObserver implementation. |
| 131 virtual void Observe(int type, | 131 virtual void Observe(int type, |
| 132 const content::NotificationSource& source, | 132 const content::NotificationSource& source, |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 // Part of UpdateFileByResourceId(). Called when | 669 // Part of UpdateFileByResourceId(). Called when |
| 670 // DriveDirectory::GetEntryInfoByResourceId() is complete. | 670 // DriveDirectory::GetEntryInfoByResourceId() is complete. |
| 671 // |callback| must not be null. | 671 // |callback| must not be null. |
| 672 void UpdateFileByEntryInfo( | 672 void UpdateFileByEntryInfo( |
| 673 const FileOperationCallback& callback, | 673 const FileOperationCallback& callback, |
| 674 GDataFileError error, | 674 GDataFileError error, |
| 675 const FilePath& /* drive_file_path */, | 675 const FilePath& /* drive_file_path */, |
| 676 scoped_ptr<DriveEntryProto> entry_proto); | 676 scoped_ptr<DriveEntryProto> entry_proto); |
| 677 | 677 |
| 678 // Part of UpdateFileByResourceId(). | 678 // Part of UpdateFileByResourceId(). |
| 679 // Called when GDataCache::GetFileOnUIThread() is completed for | 679 // Called when DriveCache::GetFileOnUIThread() is completed for |
| 680 // UpdateFileByResourceId(). | 680 // UpdateFileByResourceId(). |
| 681 // |callback| must not be null. | 681 // |callback| must not be null. |
| 682 void OnGetFileCompleteForUpdateFile(const FileOperationCallback& callback, | 682 void OnGetFileCompleteForUpdateFile(const FileOperationCallback& callback, |
| 683 GDataFileError error, | 683 GDataFileError error, |
| 684 const std::string& resource_id, | 684 const std::string& resource_id, |
| 685 const std::string& md5, | 685 const std::string& md5, |
| 686 const FilePath& cache_file_path); | 686 const FilePath& cache_file_path); |
| 687 | 687 |
| 688 // Part of UpdateFileByResourceId(). | 688 // Part of UpdateFileByResourceId(). |
| 689 // Callback for getting the size of the cache file in the blocking pool. | 689 // Callback for getting the size of the cache file in the blocking pool. |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 const ReadDirectoryWithSettingCallback& callback); | 765 const ReadDirectoryWithSettingCallback& callback); |
| 766 void RequestDirectoryRefreshOnUIThread(const FilePath& file_path); | 766 void RequestDirectoryRefreshOnUIThread(const FilePath& file_path); |
| 767 void OnRequestDirectoryRefresh(const FilePath& directory_path, | 767 void OnRequestDirectoryRefresh(const FilePath& directory_path, |
| 768 GetDocumentsParams* params, | 768 GetDocumentsParams* params, |
| 769 GDataFileError error); | 769 GDataFileError error); |
| 770 void GetAvailableSpaceOnUIThread(const GetAvailableSpaceCallback& callback); | 770 void GetAvailableSpaceOnUIThread(const GetAvailableSpaceCallback& callback); |
| 771 void AddUploadedFileOnUIThread(UploadMode upload_mode, | 771 void AddUploadedFileOnUIThread(UploadMode upload_mode, |
| 772 const FilePath& virtual_dir_path, | 772 const FilePath& virtual_dir_path, |
| 773 scoped_ptr<DocumentEntry> entry, | 773 scoped_ptr<DocumentEntry> entry, |
| 774 const FilePath& file_content_path, | 774 const FilePath& file_content_path, |
| 775 GDataCache::FileOperationType cache_operation, | 775 DriveCache::FileOperationType cache_operation, |
| 776 const base::Closure& callback); | 776 const base::Closure& callback); |
| 777 void UpdateEntryDataOnUIThread(const std::string& resource_id, | 777 void UpdateEntryDataOnUIThread(const std::string& resource_id, |
| 778 const std::string& md5, | 778 const std::string& md5, |
| 779 scoped_ptr<DocumentEntry> entry, | 779 scoped_ptr<DocumentEntry> entry, |
| 780 const FilePath& file_content_path, | 780 const FilePath& file_content_path, |
| 781 const base::Closure& callback); | 781 const base::Closure& callback); |
| 782 | 782 |
| 783 // Part of CopyOnUIThread(). Called after GetEntryInfoPairByPaths() is | 783 // Part of CopyOnUIThread(). Called after GetEntryInfoPairByPaths() is |
| 784 // complete. |callback| must not be null. | 784 // complete. |callback| must not be null. |
| 785 void CopyOnUIThreadAfterGetEntryInfoPair( | 785 void CopyOnUIThreadAfterGetEntryInfoPair( |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 bool* get_file_info_result); | 835 bool* get_file_info_result); |
| 836 | 836 |
| 837 // All members should be accessed only on UI thread. Do not post tasks to | 837 // All members should be accessed only on UI thread. Do not post tasks to |
| 838 // other threads with base::Unretained(this). | 838 // other threads with base::Unretained(this). |
| 839 scoped_ptr<DriveResourceMetadata> resource_metadata_; | 839 scoped_ptr<DriveResourceMetadata> resource_metadata_; |
| 840 | 840 |
| 841 // The profile hosts the GDataFileSystem via GDataSystemService. | 841 // The profile hosts the GDataFileSystem via GDataSystemService. |
| 842 Profile* profile_; | 842 Profile* profile_; |
| 843 | 843 |
| 844 // The cache owned by GDataSystemService. | 844 // The cache owned by GDataSystemService. |
| 845 GDataCache* cache_; | 845 DriveCache* cache_; |
| 846 | 846 |
| 847 // The uploader owned by GDataSystemService. | 847 // The uploader owned by GDataSystemService. |
| 848 GDataUploaderInterface* uploader_; | 848 GDataUploaderInterface* uploader_; |
| 849 | 849 |
| 850 // The document service owned by GDataSystemService. | 850 // The document service owned by GDataSystemService. |
| 851 DriveServiceInterface* drive_service_; | 851 DriveServiceInterface* drive_service_; |
| 852 | 852 |
| 853 // The webapps registry owned by GDataSystemService. | 853 // The webapps registry owned by GDataSystemService. |
| 854 DriveWebAppsRegistryInterface* webapps_registry_; | 854 DriveWebAppsRegistryInterface* webapps_registry_; |
| 855 | 855 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 876 // invalidate the weak pointers before any other members are destroyed. | 876 // invalidate the weak pointers before any other members are destroyed. |
| 877 base::WeakPtrFactory<GDataFileSystem> ui_weak_ptr_factory_; | 877 base::WeakPtrFactory<GDataFileSystem> ui_weak_ptr_factory_; |
| 878 // Unlike other classes, we need this as we need this to redirect a task | 878 // Unlike other classes, we need this as we need this to redirect a task |
| 879 // from IO thread to UI thread. | 879 // from IO thread to UI thread. |
| 880 base::WeakPtr<GDataFileSystem> ui_weak_ptr_; | 880 base::WeakPtr<GDataFileSystem> ui_weak_ptr_; |
| 881 }; | 881 }; |
| 882 | 882 |
| 883 } // namespace gdata | 883 } // namespace gdata |
| 884 | 884 |
| 885 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ | 885 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ |
| OLD | NEW |