| 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 <sys/stat.h> | 8 #include <sys/stat.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 virtual FilePath GetGDataCacheTmpDirectory() const = 0; | 310 virtual FilePath GetGDataCacheTmpDirectory() const = 0; |
| 311 | 311 |
| 312 // Returns the tmp downloads sub-directory under gdata cache directory, i.e. | 312 // Returns the tmp downloads sub-directory under gdata cache directory, i.e. |
| 313 // <user_profile_dir>/GCache/v1/tmp/downloads/ | 313 // <user_profile_dir>/GCache/v1/tmp/downloads/ |
| 314 virtual FilePath GetGDataTempDownloadFolderPath() const = 0; | 314 virtual FilePath GetGDataTempDownloadFolderPath() const = 0; |
| 315 | 315 |
| 316 // Returns the pinned sub-directory under gdata cache directory, i.e. | 316 // Returns the pinned sub-directory under gdata cache directory, i.e. |
| 317 // <user_profile_dir>/GCache/v1/pinned | 317 // <user_profile_dir>/GCache/v1/pinned |
| 318 virtual FilePath GetGDataCachePinnedDirectory() const = 0; | 318 virtual FilePath GetGDataCachePinnedDirectory() const = 0; |
| 319 | 319 |
| 320 // Returns the pinned sub-directory under gdata cache directory, i.e. |
| 321 // <user_profile_dir>/GCache/v1/pinned |
| 322 virtual FilePath GetGDataCachePersistentDirectory() const = 0; |
| 323 |
| 324 // Returns absolute path of the file if it were cached or to be cached. |
| 325 virtual FilePath GetCacheFilePath( |
| 326 const std::string& resource_id, |
| 327 const std::string& md5, |
| 328 GDataRootDirectory::CacheSubDirectoryType sub_dir_type, |
| 329 CachedFileOrigin file_orign) const = 0; |
| 330 |
| 320 // Fetches the user's Account Metadata to find out current quota information | 331 // Fetches the user's Account Metadata to find out current quota information |
| 321 // and returns it to the callback. | 332 // and returns it to the callback. |
| 322 virtual void GetAvailableSpace(const GetAvailableSpaceCallback& callback) = 0; | 333 virtual void GetAvailableSpace(const GetAvailableSpaceCallback& callback) = 0; |
| 323 | 334 |
| 324 // Creates a new file from |entry| under |virtual_dir_path|. Stored its | 335 // Creates a new file from |entry| under |virtual_dir_path|. Stored its |
| 325 // content from |file_content_path| into the cache. | 336 // content from |file_content_path| into the cache. |
| 326 virtual void AddDownloadedFile(const FilePath& virtual_dir_path, | 337 virtual void AddDownloadedFile(const FilePath& virtual_dir_path, |
| 327 scoped_ptr<DocumentEntry> entry, | 338 scoped_ptr<DocumentEntry> entry, |
| 328 const FilePath& file_content_path) = 0; | 339 const FilePath& file_content_path) = 0; |
| 329 }; | 340 }; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 virtual void RemoveOperationObserver( | 384 virtual void RemoveOperationObserver( |
| 374 GDataOperationRegistry::Observer* observer) OVERRIDE; | 385 GDataOperationRegistry::Observer* observer) OVERRIDE; |
| 375 virtual void GetCacheState(const std::string& resource_id, | 386 virtual void GetCacheState(const std::string& resource_id, |
| 376 const std::string& md5, | 387 const std::string& md5, |
| 377 const GetCacheStateCallback& callback) OVERRIDE; | 388 const GetCacheStateCallback& callback) OVERRIDE; |
| 378 virtual bool GetFileInfoFromPath(const FilePath& gdata_file_path, | 389 virtual bool GetFileInfoFromPath(const FilePath& gdata_file_path, |
| 379 GDataFileProperties* properties) OVERRIDE; | 390 GDataFileProperties* properties) OVERRIDE; |
| 380 virtual FilePath GetGDataCacheTmpDirectory() const OVERRIDE; | 391 virtual FilePath GetGDataCacheTmpDirectory() const OVERRIDE; |
| 381 virtual FilePath GetGDataTempDownloadFolderPath() const OVERRIDE; | 392 virtual FilePath GetGDataTempDownloadFolderPath() const OVERRIDE; |
| 382 virtual FilePath GetGDataCachePinnedDirectory() const OVERRIDE; | 393 virtual FilePath GetGDataCachePinnedDirectory() const OVERRIDE; |
| 394 virtual FilePath GetGDataCachePersistentDirectory() const OVERRIDE; |
| 395 virtual FilePath GetCacheFilePath( |
| 396 const std::string& resource_id, |
| 397 const std::string& md5, |
| 398 GDataRootDirectory::CacheSubDirectoryType sub_dir_type, |
| 399 CachedFileOrigin file_orign) const OVERRIDE; |
| 383 virtual void GetAvailableSpace( | 400 virtual void GetAvailableSpace( |
| 384 const GetAvailableSpaceCallback& callback) OVERRIDE; | 401 const GetAvailableSpaceCallback& callback) OVERRIDE; |
| 385 virtual void AddDownloadedFile(const FilePath& virtual_dir_path, | 402 virtual void AddDownloadedFile(const FilePath& virtual_dir_path, |
| 386 scoped_ptr<DocumentEntry> entry, | 403 scoped_ptr<DocumentEntry> entry, |
| 387 const FilePath& file_content_path) OVERRIDE; | 404 const FilePath& file_content_path) OVERRIDE; |
| 388 | 405 |
| 389 private: | 406 private: |
| 390 friend class GDataUploader; | 407 friend class GDataUploader; |
| 391 friend class GDataFileSystemTest; | 408 friend class GDataFileSystemTest; |
| 392 FRIEND_TEST_ALL_PREFIXES(GDataFileSystemTest, | 409 FRIEND_TEST_ALL_PREFIXES(GDataFileSystemTest, |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 742 // Cache entry points from within GDataFileSystem. | 759 // Cache entry points from within GDataFileSystem. |
| 743 // The functionalities of GData blob cache include: | 760 // The functionalities of GData blob cache include: |
| 744 // - stores downloaded gdata files on disk, indexed by the resource_id and md5 | 761 // - stores downloaded gdata files on disk, indexed by the resource_id and md5 |
| 745 // of the gdata file. | 762 // of the gdata file. |
| 746 // - provides absolute path for files to be cached or cached. | 763 // - provides absolute path for files to be cached or cached. |
| 747 // - updates the cached file on disk after user has edited it locally | 764 // - updates the cached file on disk after user has edited it locally |
| 748 // - handles eviction when disk runs out of space | 765 // - handles eviction when disk runs out of space |
| 749 // - uploads dirty files to gdata server. | 766 // - uploads dirty files to gdata server. |
| 750 // - etc. | 767 // - etc. |
| 751 | 768 |
| 752 // Returns absolute path of the file if it were cached or to be cached. | |
| 753 FilePath GetCacheFilePath( | |
| 754 const std::string& resource_id, | |
| 755 const std::string& md5, | |
| 756 GDataRootDirectory::CacheSubDirectoryType sub_dir_type, | |
| 757 CachedFileOrigin file_orign); | |
| 758 | |
| 759 // Checks if file corresponding to |resource_id| and |md5| exists in cache. | 769 // Checks if file corresponding to |resource_id| and |md5| exists in cache. |
| 760 // Initializes cache if it has not been initialized. | 770 // Initializes cache if it has not been initialized. |
| 761 // Upon completion, |callback| is invoked on the thread where this method was | 771 // Upon completion, |callback| is invoked on the thread where this method was |
| 762 // called, with the cache file path if it exists or empty otherwise. | 772 // called, with the cache file path if it exists or empty otherwise. |
| 763 // otherwise. | 773 // otherwise. |
| 764 void GetFromCache(const std::string& resource_id, | 774 void GetFromCache(const std::string& resource_id, |
| 765 const std::string& md5, | 775 const std::string& md5, |
| 766 const GetFromCacheCallback& callback); | 776 const GetFromCacheCallback& callback); |
| 767 | 777 |
| 768 // Stores |source_path| corresponding to |resource_id| and |md5| to cache. | 778 // Stores |source_path| corresponding to |resource_id| and |md5| to cache. |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 988 bool in_shutdown_; // True if GDatafileSystem is shutting down. | 998 bool in_shutdown_; // True if GDatafileSystem is shutting down. |
| 989 | 999 |
| 990 base::WeakPtrFactory<GDataFileSystem> weak_ptr_factory_; | 1000 base::WeakPtrFactory<GDataFileSystem> weak_ptr_factory_; |
| 991 | 1001 |
| 992 ObserverList<Observer> observers_; | 1002 ObserverList<Observer> observers_; |
| 993 }; | 1003 }; |
| 994 | 1004 |
| 995 } // namespace gdata | 1005 } // namespace gdata |
| 996 | 1006 |
| 997 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ | 1007 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ |
| OLD | NEW |