| 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 <sys/stat.h> | 9 #include <sys/stat.h> |
| 10 | 10 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 GDataEntry* entry)> | 69 GDataEntry* entry)> |
| 70 FindEntryCallback; | 70 FindEntryCallback; |
| 71 | 71 |
| 72 // Used to get files from the file system. | 72 // Used to get files from the file system. |
| 73 typedef base::Callback<void(base::PlatformFileError error, | 73 typedef base::Callback<void(base::PlatformFileError error, |
| 74 const FilePath& file_path, | 74 const FilePath& file_path, |
| 75 const std::string& mime_type, | 75 const std::string& mime_type, |
| 76 GDataFileType file_type)> | 76 GDataFileType file_type)> |
| 77 GetFileCallback; | 77 GetFileCallback; |
| 78 | 78 |
| 79 // Callback for SetMountedState. |
| 80 typedef base::Callback<void(base::PlatformFileError error, |
| 81 const FilePath& file_path)> |
| 82 SetMountedStateCallback; |
| 83 |
| 79 // Used for file operations like removing files. | 84 // Used for file operations like removing files. |
| 80 typedef base::Callback<void(base::PlatformFileError error, | 85 typedef base::Callback<void(base::PlatformFileError error, |
| 81 base::ListValue* feed_list)> | 86 base::ListValue* feed_list)> |
| 82 GetJsonDocumentCallback; | 87 GetJsonDocumentCallback; |
| 83 | 88 |
| 84 // Used to get available space for the account from GData. | 89 // Used to get available space for the account from GData. |
| 85 typedef base::Callback<void(base::PlatformFileError error, | 90 typedef base::Callback<void(base::PlatformFileError error, |
| 86 int bytes_total, | 91 int bytes_total, |
| 87 int bytes_used)> | 92 int bytes_used)> |
| 88 GetAvailableSpaceCallback; | 93 GetAvailableSpaceCallback; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 virtual void Initialize() = 0; | 190 virtual void Initialize() = 0; |
| 186 | 191 |
| 187 // Adds and removes the observer. | 192 // Adds and removes the observer. |
| 188 virtual void AddObserver(Observer* observer) = 0; | 193 virtual void AddObserver(Observer* observer) = 0; |
| 189 virtual void RemoveObserver(Observer* observer) = 0; | 194 virtual void RemoveObserver(Observer* observer) = 0; |
| 190 | 195 |
| 191 // Enum defining origin of a cached file. | 196 // Enum defining origin of a cached file. |
| 192 enum CachedFileOrigin { | 197 enum CachedFileOrigin { |
| 193 CACHED_FILE_FROM_SERVER = 0, | 198 CACHED_FILE_FROM_SERVER = 0, |
| 194 CACHED_FILE_LOCALLY_MODIFIED, | 199 CACHED_FILE_LOCALLY_MODIFIED, |
| 200 CACHED_FILE_MOUNTED, |
| 195 }; | 201 }; |
| 196 | 202 |
| 197 // Enum defining type of file operation e.g. copy or move, etc. | 203 // Enum defining type of file operation e.g. copy or move, etc. |
| 198 // For now, it's used for StoreToCache. | 204 // For now, it's used for StoreToCache. |
| 199 enum FileOperationType { | 205 enum FileOperationType { |
| 200 FILE_OPERATION_MOVE = 0, | 206 FILE_OPERATION_MOVE = 0, |
| 201 FILE_OPERATION_COPY, | 207 FILE_OPERATION_COPY, |
| 202 }; | 208 }; |
| 203 | 209 |
| 204 // Authenticates the user by fetching the auth token as | 210 // Authenticates the user by fetching the auth token as |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 // otherwise. | 357 // otherwise. |
| 352 virtual void GetCacheState(const std::string& resource_id, | 358 virtual void GetCacheState(const std::string& resource_id, |
| 353 const std::string& md5, | 359 const std::string& md5, |
| 354 const GetCacheStateCallback& callback) = 0; | 360 const GetCacheStateCallback& callback) = 0; |
| 355 | 361 |
| 356 // Finds a file (not a directory) by |file_path| and returns its key | 362 // Finds a file (not a directory) by |file_path| and returns its key |
| 357 // |properties|. Returns true if file was found. | 363 // |properties|. Returns true if file was found. |
| 358 virtual bool GetFileInfoByPath(const FilePath& gdata_file_path, | 364 virtual bool GetFileInfoByPath(const FilePath& gdata_file_path, |
| 359 GDataFileProperties* properties) = 0; | 365 GDataFileProperties* properties) = 0; |
| 360 | 366 |
| 367 // Returns true if the given path is under gdata cache directory, i.e. |
| 368 // <user_profile_dir>/GCache/v1 |
| 369 virtual bool IsUnderGDataCacheDirectory(const FilePath& path) const = 0; |
| 370 |
| 361 // Returns the tmp sub-directory under gdata cache directory, i.e. | 371 // Returns the tmp sub-directory under gdata cache directory, i.e. |
| 362 // <user_profile_dir>/GCache/v1/tmp | 372 // <user_profile_dir>/GCache/v1/tmp |
| 363 virtual FilePath GetGDataCacheTmpDirectory() const = 0; | 373 virtual FilePath GetGDataCacheTmpDirectory() const = 0; |
| 364 | 374 |
| 365 // Returns the tmp downloads sub-directory under gdata cache directory, i.e. | 375 // Returns the tmp downloads sub-directory under gdata cache directory, i.e. |
| 366 // <user_profile_dir>/GCache/v1/tmp/downloads/ | 376 // <user_profile_dir>/GCache/v1/tmp/downloads/ |
| 367 virtual FilePath GetGDataTempDownloadFolderPath() const = 0; | 377 virtual FilePath GetGDataTempDownloadFolderPath() const = 0; |
| 368 | 378 |
| 369 // Returns the tmp documents sub-directory under gdata cache directory, i.e. | 379 // Returns the tmp documents sub-directory under gdata cache directory, i.e. |
| 370 // <user_profile_dir>/GCache/v1/tmp/documents/ | 380 // <user_profile_dir>/GCache/v1/tmp/documents/ |
| (...skipping 15 matching lines...) Expand all Loading... |
| 386 CachedFileOrigin file_orign) const = 0; | 396 CachedFileOrigin file_orign) const = 0; |
| 387 | 397 |
| 388 // Fetches the user's Account Metadata to find out current quota information | 398 // Fetches the user's Account Metadata to find out current quota information |
| 389 // and returns it to the callback. | 399 // and returns it to the callback. |
| 390 virtual void GetAvailableSpace(const GetAvailableSpaceCallback& callback) = 0; | 400 virtual void GetAvailableSpace(const GetAvailableSpaceCallback& callback) = 0; |
| 391 | 401 |
| 392 // Pin or unpin file. | 402 // Pin or unpin file. |
| 393 virtual void SetPinState(const FilePath& file_path, bool to_pin, | 403 virtual void SetPinState(const FilePath& file_path, bool to_pin, |
| 394 const FileOperationCallback& callback) = 0; | 404 const FileOperationCallback& callback) = 0; |
| 395 | 405 |
| 406 // Marks or unmarks a file as locally mounted. |
| 407 // When marked as mounted, the file is prevented from being modified |
| 408 // or evicted from cache. |
| 409 virtual void SetMountedState(const FilePath& file_path, bool to_mount, |
| 410 const SetMountedStateCallback& callback) = 0; |
| 411 |
| 396 // Creates a new file from |entry| under |virtual_dir_path|. Stored its | 412 // Creates a new file from |entry| under |virtual_dir_path|. Stored its |
| 397 // content from |file_content_path| into the cache. | 413 // content from |file_content_path| into the cache. |
| 398 virtual void AddUploadedFile(const FilePath& virtual_dir_path, | 414 virtual void AddUploadedFile(const FilePath& virtual_dir_path, |
| 399 DocumentEntry* entry, | 415 DocumentEntry* entry, |
| 400 const FilePath& file_content_path, | 416 const FilePath& file_content_path, |
| 401 FileOperationType cache_operation) = 0; | 417 FileOperationType cache_operation) = 0; |
| 402 | 418 |
| 403 // Returns true if hosted documents should be hidden. | 419 // Returns true if hosted documents should be hidden. |
| 404 virtual bool hide_hosted_documents() = 0; | 420 virtual bool hide_hosted_documents() = 0; |
| 405 }; | 421 }; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 virtual bool CancelOperation(const FilePath& file_path) OVERRIDE; | 465 virtual bool CancelOperation(const FilePath& file_path) OVERRIDE; |
| 450 virtual void AddOperationObserver( | 466 virtual void AddOperationObserver( |
| 451 GDataOperationRegistry::Observer* observer) OVERRIDE; | 467 GDataOperationRegistry::Observer* observer) OVERRIDE; |
| 452 virtual void RemoveOperationObserver( | 468 virtual void RemoveOperationObserver( |
| 453 GDataOperationRegistry::Observer* observer) OVERRIDE; | 469 GDataOperationRegistry::Observer* observer) OVERRIDE; |
| 454 virtual void GetCacheState(const std::string& resource_id, | 470 virtual void GetCacheState(const std::string& resource_id, |
| 455 const std::string& md5, | 471 const std::string& md5, |
| 456 const GetCacheStateCallback& callback) OVERRIDE; | 472 const GetCacheStateCallback& callback) OVERRIDE; |
| 457 virtual bool GetFileInfoByPath(const FilePath& gdata_file_path, | 473 virtual bool GetFileInfoByPath(const FilePath& gdata_file_path, |
| 458 GDataFileProperties* properties) OVERRIDE; | 474 GDataFileProperties* properties) OVERRIDE; |
| 475 virtual bool IsUnderGDataCacheDirectory(const FilePath& path) const OVERRIDE; |
| 459 virtual FilePath GetGDataCacheTmpDirectory() const OVERRIDE; | 476 virtual FilePath GetGDataCacheTmpDirectory() const OVERRIDE; |
| 460 virtual FilePath GetGDataTempDownloadFolderPath() const OVERRIDE; | 477 virtual FilePath GetGDataTempDownloadFolderPath() const OVERRIDE; |
| 461 virtual FilePath GetGDataTempDocumentFolderPath() const OVERRIDE; | 478 virtual FilePath GetGDataTempDocumentFolderPath() const OVERRIDE; |
| 462 virtual FilePath GetGDataCachePinnedDirectory() const OVERRIDE; | 479 virtual FilePath GetGDataCachePinnedDirectory() const OVERRIDE; |
| 463 virtual FilePath GetGDataCachePersistentDirectory() const OVERRIDE; | 480 virtual FilePath GetGDataCachePersistentDirectory() const OVERRIDE; |
| 464 virtual FilePath GetCacheFilePath( | 481 virtual FilePath GetCacheFilePath( |
| 465 const std::string& resource_id, | 482 const std::string& resource_id, |
| 466 const std::string& md5, | 483 const std::string& md5, |
| 467 GDataRootDirectory::CacheSubDirectoryType sub_dir_type, | 484 GDataRootDirectory::CacheSubDirectoryType sub_dir_type, |
| 468 CachedFileOrigin file_orign) const OVERRIDE; | 485 CachedFileOrigin file_orign) const OVERRIDE; |
| 469 virtual void GetAvailableSpace( | 486 virtual void GetAvailableSpace( |
| 470 const GetAvailableSpaceCallback& callback) OVERRIDE; | 487 const GetAvailableSpaceCallback& callback) OVERRIDE; |
| 471 // Calls private Pin or Unpin methods with |callback|. | 488 // Calls private Pin or Unpin methods with |callback|. |
| 472 virtual void SetPinState(const FilePath& file_path, bool pin, | 489 virtual void SetPinState(const FilePath& file_path, bool pin, |
| 473 const FileOperationCallback& callback) OVERRIDE; | 490 const FileOperationCallback& callback) OVERRIDE; |
| 491 virtual void SetMountedState( |
| 492 const FilePath& file_path, |
| 493 bool to_mount, |
| 494 const SetMountedStateCallback& callback) OVERRIDE; |
| 474 virtual void AddUploadedFile(const FilePath& virtual_dir_path, | 495 virtual void AddUploadedFile(const FilePath& virtual_dir_path, |
| 475 DocumentEntry* entry, | 496 DocumentEntry* entry, |
| 476 const FilePath& file_content_path, | 497 const FilePath& file_content_path, |
| 477 FileOperationType cache_operation) OVERRIDE; | 498 FileOperationType cache_operation) OVERRIDE; |
| 478 virtual bool hide_hosted_documents() OVERRIDE; | 499 virtual bool hide_hosted_documents() OVERRIDE; |
| 479 | 500 |
| 480 // content::NotificationObserver implementation. | 501 // content::NotificationObserver implementation. |
| 481 virtual void Observe(int type, | 502 virtual void Observe(int type, |
| 482 const content::NotificationSource& source, | 503 const content::NotificationSource& source, |
| 483 const content::NotificationDetails& details) OVERRIDE; | 504 const content::NotificationDetails& details) OVERRIDE; |
| (...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1152 // Task posted from Unpin to modify cache state on the IO thread pool, which | 1173 // Task posted from Unpin to modify cache state on the IO thread pool, which |
| 1153 // involves the following: | 1174 // involves the following: |
| 1154 // - moves |source_path| to |dest_path| in tmp dir if file is | 1175 // - moves |source_path| to |dest_path| in tmp dir if file is |
| 1155 // not dirty | 1176 // not dirty |
| 1156 // - deletes symlink from pinned dir | 1177 // - deletes symlink from pinned dir |
| 1157 void UnpinOnIOThreadPool(const std::string& resource_id, | 1178 void UnpinOnIOThreadPool(const std::string& resource_id, |
| 1158 const std::string& md5, | 1179 const std::string& md5, |
| 1159 FileOperationType file_operation_type, | 1180 FileOperationType file_operation_type, |
| 1160 base::PlatformFileError* error); | 1181 base::PlatformFileError* error); |
| 1161 | 1182 |
| 1183 // Task posted from SetMountedState to modify cache state on the IO thread |
| 1184 // pool, which involves the following: |
| 1185 // - moves |source_path| to |dest_path|, where |
| 1186 // if we're mounting: |source_path| is the unmounted path and has .<md5> |
| 1187 // extension, and |dest_path| is the mounted path in persistent dir |
| 1188 // and has .<md5>.mounted extension; |
| 1189 // if we're unmounting: the opposite is true for the two paths, i.e. |
| 1190 // |dest_path| is the mounted path and |source_path| the unmounted path. |
| 1191 void SetMountedStateOnIOThreadPool(const FilePath& file_path, |
| 1192 bool to_mount, |
| 1193 base::PlatformFileError* error, |
| 1194 FilePath* cache_file_path); |
| 1195 |
| 1162 // Task posted from MarkDirtyInCache to modify cache state on the IO thread | 1196 // Task posted from MarkDirtyInCache to modify cache state on the IO thread |
| 1163 // pool, which involves the following: | 1197 // pool, which involves the following: |
| 1164 // - moves |source_path| to |dest_path| in persistent dir, where | 1198 // - moves |source_path| to |dest_path| in persistent dir, where |
| 1165 // |source_path| has .<md5> extension and |dest_path| has .local extension | 1199 // |source_path| has .<md5> extension and |dest_path| has .local extension |
| 1166 // - if file is pinned, updates symlink in pinned dir to reference dirty file | 1200 // - if file is pinned, updates symlink in pinned dir to reference dirty file |
| 1167 void MarkDirtyInCacheOnIOThreadPool(const std::string& resource_id, | 1201 void MarkDirtyInCacheOnIOThreadPool(const std::string& resource_id, |
| 1168 const std::string& md5, | 1202 const std::string& md5, |
| 1169 FileOperationType file_operation_type, | 1203 FileOperationType file_operation_type, |
| 1170 base::PlatformFileError* error, | 1204 base::PlatformFileError* error, |
| 1171 FilePath* cache_file_path); | 1205 FilePath* cache_file_path); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1357 }; | 1391 }; |
| 1358 | 1392 |
| 1359 // Sets the free disk space getter for testing. | 1393 // Sets the free disk space getter for testing. |
| 1360 // The existing getter is deleted. | 1394 // The existing getter is deleted. |
| 1361 void SetFreeDiskSpaceGetterForTesting( | 1395 void SetFreeDiskSpaceGetterForTesting( |
| 1362 FreeDiskSpaceGetterInterface* getter); | 1396 FreeDiskSpaceGetterInterface* getter); |
| 1363 | 1397 |
| 1364 } // namespace gdata | 1398 } // namespace gdata |
| 1365 | 1399 |
| 1366 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ | 1400 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ |
| OLD | NEW |