| 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 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 GDataFileProperties* properties) = 0; | 334 GDataFileProperties* properties) = 0; |
| 335 | 335 |
| 336 // Returns the tmp sub-directory under gdata cache directory, i.e. | 336 // Returns the tmp sub-directory under gdata cache directory, i.e. |
| 337 // <user_profile_dir>/GCache/v1/tmp | 337 // <user_profile_dir>/GCache/v1/tmp |
| 338 virtual FilePath GetGDataCacheTmpDirectory() const = 0; | 338 virtual FilePath GetGDataCacheTmpDirectory() const = 0; |
| 339 | 339 |
| 340 // Returns the tmp downloads sub-directory under gdata cache directory, i.e. | 340 // Returns the tmp downloads sub-directory under gdata cache directory, i.e. |
| 341 // <user_profile_dir>/GCache/v1/tmp/downloads/ | 341 // <user_profile_dir>/GCache/v1/tmp/downloads/ |
| 342 virtual FilePath GetGDataTempDownloadFolderPath() const = 0; | 342 virtual FilePath GetGDataTempDownloadFolderPath() const = 0; |
| 343 | 343 |
| 344 // Returns the tmp documents sub-directory under gdata cache directory, i.e. |
| 345 // <user_profile_dir>/GCache/v1/tmp/documents/ |
| 346 virtual FilePath GetGDataTempDocumentFolderPath() const = 0; |
| 347 |
| 344 // Returns the pinned sub-directory under gdata cache directory, i.e. | 348 // Returns the pinned sub-directory under gdata cache directory, i.e. |
| 345 // <user_profile_dir>/GCache/v1/pinned | 349 // <user_profile_dir>/GCache/v1/pinned |
| 346 virtual FilePath GetGDataCachePinnedDirectory() const = 0; | 350 virtual FilePath GetGDataCachePinnedDirectory() const = 0; |
| 347 | 351 |
| 348 // Returns the pinned sub-directory under gdata cache directory, i.e. | 352 // Returns the pinned sub-directory under gdata cache directory, i.e. |
| 349 // <user_profile_dir>/GCache/v1/pinned | 353 // <user_profile_dir>/GCache/v1/pinned |
| 350 virtual FilePath GetGDataCachePersistentDirectory() const = 0; | 354 virtual FilePath GetGDataCachePersistentDirectory() const = 0; |
| 351 | 355 |
| 352 // Returns absolute path of the file if it were cached or to be cached. | 356 // Returns absolute path of the file if it were cached or to be cached. |
| 353 virtual FilePath GetCacheFilePath( | 357 virtual FilePath GetCacheFilePath( |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 GDataOperationRegistry::Observer* observer) OVERRIDE; | 421 GDataOperationRegistry::Observer* observer) OVERRIDE; |
| 418 virtual void RemoveOperationObserver( | 422 virtual void RemoveOperationObserver( |
| 419 GDataOperationRegistry::Observer* observer) OVERRIDE; | 423 GDataOperationRegistry::Observer* observer) OVERRIDE; |
| 420 virtual void GetCacheState(const std::string& resource_id, | 424 virtual void GetCacheState(const std::string& resource_id, |
| 421 const std::string& md5, | 425 const std::string& md5, |
| 422 const GetCacheStateCallback& callback) OVERRIDE; | 426 const GetCacheStateCallback& callback) OVERRIDE; |
| 423 virtual bool GetFileInfoFromPath(const FilePath& gdata_file_path, | 427 virtual bool GetFileInfoFromPath(const FilePath& gdata_file_path, |
| 424 GDataFileProperties* properties) OVERRIDE; | 428 GDataFileProperties* properties) OVERRIDE; |
| 425 virtual FilePath GetGDataCacheTmpDirectory() const OVERRIDE; | 429 virtual FilePath GetGDataCacheTmpDirectory() const OVERRIDE; |
| 426 virtual FilePath GetGDataTempDownloadFolderPath() const OVERRIDE; | 430 virtual FilePath GetGDataTempDownloadFolderPath() const OVERRIDE; |
| 431 virtual FilePath GetGDataTempDocumentFolderPath() const OVERRIDE; |
| 427 virtual FilePath GetGDataCachePinnedDirectory() const OVERRIDE; | 432 virtual FilePath GetGDataCachePinnedDirectory() const OVERRIDE; |
| 428 virtual FilePath GetGDataCachePersistentDirectory() const OVERRIDE; | 433 virtual FilePath GetGDataCachePersistentDirectory() const OVERRIDE; |
| 429 virtual FilePath GetCacheFilePath( | 434 virtual FilePath GetCacheFilePath( |
| 430 const std::string& resource_id, | 435 const std::string& resource_id, |
| 431 const std::string& md5, | 436 const std::string& md5, |
| 432 GDataRootDirectory::CacheSubDirectoryType sub_dir_type, | 437 GDataRootDirectory::CacheSubDirectoryType sub_dir_type, |
| 433 CachedFileOrigin file_orign) const OVERRIDE; | 438 CachedFileOrigin file_orign) const OVERRIDE; |
| 434 virtual void GetAvailableSpace( | 439 virtual void GetAvailableSpace( |
| 435 const GetAvailableSpaceCallback& callback) OVERRIDE; | 440 const GetAvailableSpaceCallback& callback) OVERRIDE; |
| 436 virtual void AddUploadedFile(const FilePath& virtual_dir_path, | 441 virtual void AddUploadedFile(const FilePath& virtual_dir_path, |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 void UnsafeFindFileByPath(const FilePath& file_path, | 583 void UnsafeFindFileByPath(const FilePath& file_path, |
| 579 FindFileDelegate* delegate); | 584 FindFileDelegate* delegate); |
| 580 | 585 |
| 581 // Converts document feed from gdata service into DirectoryInfo. On failure, | 586 // Converts document feed from gdata service into DirectoryInfo. On failure, |
| 582 // returns NULL and fills in |error| with an appropriate value. | 587 // returns NULL and fills in |error| with an appropriate value. |
| 583 GDataDirectory* ParseGDataFeed(GDataErrorCode status, | 588 GDataDirectory* ParseGDataFeed(GDataErrorCode status, |
| 584 base::Value* data, | 589 base::Value* data, |
| 585 base::PlatformFileError *error); | 590 base::PlatformFileError *error); |
| 586 | 591 |
| 587 // Creates a temporary JSON file representing a document with |edit_url| | 592 // Creates a temporary JSON file representing a document with |edit_url| |
| 588 // and |resource_id| on IO thread pool. Upon completion it will invoke | 593 // and |resource_id| under |document_dir| on IO thread pool. Upon completion |
| 589 // |callback| with the path of the created temporary file on thread | 594 // it will invoke |callback| with the path of the created temporary file on |
| 590 // represented by |relay_proxy|. | 595 // thread represented by |relay_proxy|. |
| 591 static void CreateDocumentJsonFileOnIOThreadPool( | 596 static void CreateDocumentJsonFileOnIOThreadPool( |
| 597 const FilePath& document_dir, |
| 592 const GURL& edit_url, | 598 const GURL& edit_url, |
| 593 const std::string& resource_id, | 599 const std::string& resource_id, |
| 594 const GetFileCallback& callback, | 600 const GetFileCallback& callback, |
| 595 scoped_refptr<base::MessageLoopProxy> relay_proxy); | 601 scoped_refptr<base::MessageLoopProxy> relay_proxy); |
| 596 | 602 |
| 597 // Renames a file or directory at |file_path| to |new_name|. | 603 // Renames a file or directory at |file_path| to |new_name|. |
| 598 void Rename(const FilePath& file_path, | 604 void Rename(const FilePath& file_path, |
| 599 const FilePath::StringType& new_name, | 605 const FilePath::StringType& new_name, |
| 600 const FilePathUpdateCallback& callback); | 606 const FilePathUpdateCallback& callback); |
| 601 | 607 |
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1148 // The document service for the GDataFileSystem. | 1154 // The document service for the GDataFileSystem. |
| 1149 scoped_ptr<DocumentsServiceInterface> documents_service_; | 1155 scoped_ptr<DocumentsServiceInterface> documents_service_; |
| 1150 | 1156 |
| 1151 // Base path for GData cache, e.g. <user_profile_dir>/user/GCache/v1. | 1157 // Base path for GData cache, e.g. <user_profile_dir>/user/GCache/v1. |
| 1152 FilePath gdata_cache_path_; | 1158 FilePath gdata_cache_path_; |
| 1153 | 1159 |
| 1154 // Paths for all subdirectories of GCache, one for each | 1160 // Paths for all subdirectories of GCache, one for each |
| 1155 // GDataRootDirectory::CacheSubDirectoryType enum. | 1161 // GDataRootDirectory::CacheSubDirectoryType enum. |
| 1156 std::vector<FilePath> cache_paths_; | 1162 std::vector<FilePath> cache_paths_; |
| 1157 | 1163 |
| 1164 // Directory for hosting temporary document JSON files. |
| 1165 FilePath temp_document_dir_; |
| 1166 |
| 1158 scoped_ptr<base::WaitableEvent> on_io_completed_; | 1167 scoped_ptr<base::WaitableEvent> on_io_completed_; |
| 1159 | 1168 |
| 1160 // True if cache initialization has started, is in progress or has completed, | 1169 // True if cache initialization has started, is in progress or has completed, |
| 1161 // we only want to initialize cache once. | 1170 // we only want to initialize cache once. |
| 1162 bool cache_initialization_started_; | 1171 bool cache_initialization_started_; |
| 1163 | 1172 |
| 1164 // Number of pending tasks on the worker thread pool. | 1173 // Number of pending tasks on the worker thread pool. |
| 1165 int num_pending_tasks_; | 1174 int num_pending_tasks_; |
| 1166 base::Lock num_pending_tasks_lock_; | 1175 base::Lock num_pending_tasks_lock_; |
| 1167 | 1176 |
| 1168 // WeakPtrFactory and WeakPtr bound to the UI thread. | 1177 // WeakPtrFactory and WeakPtr bound to the UI thread. |
| 1169 scoped_ptr<base::WeakPtrFactory<GDataFileSystem> > ui_weak_ptr_factory_; | 1178 scoped_ptr<base::WeakPtrFactory<GDataFileSystem> > ui_weak_ptr_factory_; |
| 1170 base::WeakPtr<GDataFileSystem> ui_weak_ptr_; | 1179 base::WeakPtr<GDataFileSystem> ui_weak_ptr_; |
| 1171 | 1180 |
| 1172 // WeakPtrFactory bound to the IO thread. Created when needed. | 1181 // WeakPtrFactory bound to the IO thread. Created when needed. |
| 1173 scoped_ptr<base::WeakPtrFactory<GDataFileSystem> > io_weak_ptr_factory_; | 1182 scoped_ptr<base::WeakPtrFactory<GDataFileSystem> > io_weak_ptr_factory_; |
| 1174 | 1183 |
| 1175 ObserverList<Observer> observers_; | 1184 ObserverList<Observer> observers_; |
| 1176 }; | 1185 }; |
| 1177 | 1186 |
| 1178 } // namespace gdata | 1187 } // namespace gdata |
| 1179 | 1188 |
| 1180 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ | 1189 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ |
| OLD | NEW |