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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 | 118 |
119 // Used by GDataFileSystem::GetDocumentResourceIdOnIOThreadPool to return | 119 // Used by GDataFileSystem::GetDocumentResourceIdOnIOThreadPool to return |
120 // the resource ID read from a document JSON file on the local file system. | 120 // the resource ID read from a document JSON file on the local file system. |
121 typedef base::Callback<void(const std::string& resource_id)> | 121 typedef base::Callback<void(const std::string& resource_id)> |
122 GetDocumentResourceIdCallback; | 122 GetDocumentResourceIdCallback; |
123 | 123 |
124 // Callback for GetCacheState operation. | 124 // Callback for GetCacheState operation. |
125 typedef base::Callback<void(base::PlatformFileError error, | 125 typedef base::Callback<void(base::PlatformFileError error, |
126 int cache_state)> GetCacheStateCallback; | 126 int cache_state)> GetCacheStateCallback; |
127 | 127 |
128 // Helper structure used for extracting key properties from GDataFile object. | |
129 // TODO(satorux): Remove this as part of crosbug.com/30066 | |
130 struct GDataFileProperties { | |
131 GDataFileProperties(); | |
132 ~GDataFileProperties(); | |
133 | |
134 base::PlatformFileInfo file_info; | |
135 std::string resource_id; | |
136 std::string file_md5; | |
137 std::string mime_type; | |
138 GURL content_url; | |
139 GURL alternate_url; | |
140 bool is_hosted_document; | |
141 }; | |
142 | |
143 // GData file system abstraction layer. | 128 // GData file system abstraction layer. |
144 // The interface is defined to make GDataFileSystem mockable. | 129 // The interface is defined to make GDataFileSystem mockable. |
145 class GDataFileSystemInterface { | 130 class GDataFileSystemInterface { |
146 public: | 131 public: |
147 virtual ~GDataFileSystemInterface() {} | 132 virtual ~GDataFileSystemInterface() {} |
148 | 133 |
149 // Used to notify events on the file system. | 134 // Used to notify events on the file system. |
150 // All events are notified on UI thread. | 135 // All events are notified on UI thread. |
151 class Observer { | 136 class Observer { |
152 public: | 137 public: |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 virtual void RequestDirectoryRefresh(const FilePath& file_path) = 0; | 392 virtual void RequestDirectoryRefresh(const FilePath& file_path) = 0; |
408 | 393 |
409 // Does server side content search for |search_query|. Search results will be | 394 // Does server side content search for |search_query|. Search results will be |
410 // returned as gdata entries in temp directory proto, and their | 395 // returned as gdata entries in temp directory proto, and their |
411 // title/file_name will be formatted as |<resource_id>.<original_file_name>|. | 396 // title/file_name will be formatted as |<resource_id>.<original_file_name>|. |
412 // | 397 // |
413 // Can be called from UI/IO thread. |callback| is run on the calling thread. | 398 // Can be called from UI/IO thread. |callback| is run on the calling thread. |
414 virtual void SearchAsync(const std::string& search_query, | 399 virtual void SearchAsync(const std::string& search_query, |
415 const ReadDirectoryCallback& callback) = 0; | 400 const ReadDirectoryCallback& callback) = 0; |
416 | 401 |
417 | |
418 // Finds a file (not a directory) by |file_path| and returns its key | |
419 // |properties|. Returns true if file was found. | |
420 // TODO(satorux): Remove this: crosbug.com/30066. | |
421 virtual bool GetFileInfoByPath(const FilePath& file_path, | |
422 GDataFileProperties* properties) = 0; | |
423 | |
424 // Returns true if the given path is under gdata cache directory, i.e. | 402 // Returns true if the given path is under gdata cache directory, i.e. |
425 // <user_profile_dir>/GCache/v1 | 403 // <user_profile_dir>/GCache/v1 |
426 virtual bool IsUnderGDataCacheDirectory(const FilePath& path) const = 0; | 404 virtual bool IsUnderGDataCacheDirectory(const FilePath& path) const = 0; |
427 | 405 |
428 // Returns the sub-directory under gdata cache directory for the given sub | 406 // Returns the sub-directory under gdata cache directory for the given sub |
429 // directory type. Example: <user_profile_dir>/GCache/v1/tmp | 407 // directory type. Example: <user_profile_dir>/GCache/v1/tmp |
430 virtual FilePath GetCacheDirectoryPath( | 408 virtual FilePath GetCacheDirectoryPath( |
431 GDataCache::CacheSubDirectoryType sub_dir_type) const = 0; | 409 GDataCache::CacheSubDirectoryType sub_dir_type) const = 0; |
432 | 410 |
433 // Returns absolute path of the file if it were cached or to be cached. | 411 // Returns absolute path of the file if it were cached or to be cached. |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 const FilePath& file_path, | 502 const FilePath& file_path, |
525 const GetEntryInfoCallback& callback) OVERRIDE; | 503 const GetEntryInfoCallback& callback) OVERRIDE; |
526 virtual void GetFileInfoByPathAsync( | 504 virtual void GetFileInfoByPathAsync( |
527 const FilePath& file_path, | 505 const FilePath& file_path, |
528 const GetFileInfoCallback& callback) OVERRIDE; | 506 const GetFileInfoCallback& callback) OVERRIDE; |
529 virtual void ReadDirectoryByPathAsync( | 507 virtual void ReadDirectoryByPathAsync( |
530 const FilePath& file_path, | 508 const FilePath& file_path, |
531 const ReadDirectoryCallback& callback) OVERRIDE; | 509 const ReadDirectoryCallback& callback) OVERRIDE; |
532 virtual void RequestDirectoryRefresh( | 510 virtual void RequestDirectoryRefresh( |
533 const FilePath& file_path) OVERRIDE; | 511 const FilePath& file_path) OVERRIDE; |
534 virtual bool GetFileInfoByPath(const FilePath& file_path, | |
535 GDataFileProperties* properties) OVERRIDE; | |
536 virtual bool IsUnderGDataCacheDirectory(const FilePath& path) const OVERRIDE; | 512 virtual bool IsUnderGDataCacheDirectory(const FilePath& path) const OVERRIDE; |
537 virtual FilePath GetCacheDirectoryPath( | 513 virtual FilePath GetCacheDirectoryPath( |
538 GDataCache::CacheSubDirectoryType sub_dir_type) const OVERRIDE; | 514 GDataCache::CacheSubDirectoryType sub_dir_type) const OVERRIDE; |
539 virtual FilePath GetCacheFilePath( | 515 virtual FilePath GetCacheFilePath( |
540 const std::string& resource_id, | 516 const std::string& resource_id, |
541 const std::string& md5, | 517 const std::string& md5, |
542 GDataCache::CacheSubDirectoryType sub_dir_type, | 518 GDataCache::CacheSubDirectoryType sub_dir_type, |
543 CachedFileOrigin file_orign) const OVERRIDE; | 519 CachedFileOrigin file_orign) const OVERRIDE; |
544 virtual void GetAvailableSpace( | 520 virtual void GetAvailableSpace( |
545 const GetAvailableSpaceCallback& callback) OVERRIDE; | 521 const GetAvailableSpaceCallback& callback) OVERRIDE; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 // Initiates transfer of |local_file_path| to |remote_dest_file_path|. | 688 // Initiates transfer of |local_file_path| to |remote_dest_file_path|. |
713 // |local_file_path| must be a regular file (i.e. not a hosted document) from | 689 // |local_file_path| must be a regular file (i.e. not a hosted document) from |
714 // the local file system, |remote_dest_file_path| is the virtual destination | 690 // the local file system, |remote_dest_file_path| is the virtual destination |
715 // path within gdata file system. | 691 // path within gdata file system. |
716 // | 692 // |
717 // Must be called from *UI* thread. |callback| is run on the calling thread. | 693 // Must be called from *UI* thread. |callback| is run on the calling thread. |
718 void TransferRegularFile(const FilePath& local_file_path, | 694 void TransferRegularFile(const FilePath& local_file_path, |
719 const FilePath& remote_dest_file_path, | 695 const FilePath& remote_dest_file_path, |
720 const FileOperationCallback& callback); | 696 const FileOperationCallback& callback); |
721 | 697 |
| 698 // Invoked upon completion of GetFileInfoByPathAsync initiated by |
| 699 // GetFileByPath. It then continues to invoke GetFileByPathOnUIThread. |
| 700 void OnGetFileInfoCompleteForGetFileByPath( |
| 701 const FilePath& file_path, |
| 702 const GetFileCallback& get_file_callback, |
| 703 const GetDownloadDataCallback& get_download_data_callback, |
| 704 base::PlatformFileError error, |
| 705 scoped_ptr<GDataFileProto> file_info); |
722 // Invoked upon completion of GetFileInfoByPathAsync initiated by OpenFile. | 706 // Invoked upon completion of GetFileInfoByPathAsync initiated by OpenFile. |
723 // It then continues to invoke GetFileByPath and processed to | 707 // It then continues to invoke GetFileByPathOnUIThread and proceeds to |
724 // OnGetFileCompleteForOpenFile. | 708 // OnGetFileCompleteForOpenFile. |
725 void OnGetFileInfoCompleteForOpenFile(const FilePath& file_path, | 709 void OnGetFileInfoCompleteForOpenFile(const FilePath& file_path, |
726 const OpenFileCallback& callback, | 710 const OpenFileCallback& callback, |
727 base::PlatformFileError error, | 711 base::PlatformFileError error, |
728 scoped_ptr<GDataFileProto> file_info); | 712 scoped_ptr<GDataFileProto> file_info); |
729 // Invoked upon completion of GetFileInfoByPathAsync initiated by CloseFile. | 713 // Invoked upon completion of GetFileInfoByPathAsync initiated by CloseFile. |
730 // It then continues to invoke GetFileByPath and processed to | 714 // It then continues to invoke CommitDirtyInCache and proceeds to |
731 // OnGetFileCompleteForCloseFile. | 715 // OnCommitDirtyInCacheCompleteForCloseFile. |
732 void OnGetFileInfoCompleteForCloseFile(const FilePath& file_path, | 716 void OnGetFileInfoCompleteForCloseFile(const FilePath& file_path, |
733 const CloseFileCallback& callback, | 717 const CloseFileCallback& callback, |
734 base::PlatformFileError error, | 718 base::PlatformFileError error, |
735 scoped_ptr<GDataFileProto> file_info); | 719 scoped_ptr<GDataFileProto> file_info); |
736 | 720 |
737 // Invoked upon completion of GetFileByPath initiated by Copy. If | 721 // Invoked upon completion of GetFileByPath initiated by Copy. If |
738 // GetFileByPath reports no error, calls TransferRegularFile to transfer | 722 // GetFileByPath reports no error, calls TransferRegularFile to transfer |
739 // |local_file_path| to |remote_dest_file_path|. | 723 // |local_file_path| to |remote_dest_file_path|. |
740 // | 724 // |
741 // Can be called from UI/IO thread. |callback| is run on the calling thread. | 725 // Can be called from UI/IO thread. |callback| is run on the calling thread. |
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1463 void RemoveOnUIThread(const FilePath& file_path, | 1447 void RemoveOnUIThread(const FilePath& file_path, |
1464 bool is_recursive, | 1448 bool is_recursive, |
1465 const FileOperationCallback& callback); | 1449 const FileOperationCallback& callback); |
1466 void CreateDirectoryOnUIThread(const FilePath& directory_path, | 1450 void CreateDirectoryOnUIThread(const FilePath& directory_path, |
1467 bool is_exclusive, | 1451 bool is_exclusive, |
1468 bool is_recursive, | 1452 bool is_recursive, |
1469 const FileOperationCallback& callback); | 1453 const FileOperationCallback& callback); |
1470 void GetFileByPathOnUIThread( | 1454 void GetFileByPathOnUIThread( |
1471 const FilePath& file_path, | 1455 const FilePath& file_path, |
1472 const GetFileCallback& get_file_callback, | 1456 const GetFileCallback& get_file_callback, |
1473 const GetDownloadDataCallback& get_download_data_callback); | 1457 const GetDownloadDataCallback& get_download_data_callback, |
| 1458 base::PlatformFileError error, |
| 1459 const GDataFileProto* file_proto); |
1474 void GetFileByResourceIdOnUIThread( | 1460 void GetFileByResourceIdOnUIThread( |
1475 const std::string& resource_id, | 1461 const std::string& resource_id, |
1476 const GetFileCallback& get_file_callback, | 1462 const GetFileCallback& get_file_callback, |
1477 const GetDownloadDataCallback& get_download_data_callback); | 1463 const GetDownloadDataCallback& get_download_data_callback); |
1478 void GetEntryInfoByPathAsyncOnUIThread( | 1464 void GetEntryInfoByPathAsyncOnUIThread( |
1479 const FilePath& file_path, | 1465 const FilePath& file_path, |
1480 const GetEntryInfoCallback& callback); | 1466 const GetEntryInfoCallback& callback); |
1481 void GetFileInfoByPathAsyncOnUIThread( | 1467 void GetFileInfoByPathAsyncOnUIThread( |
1482 const FilePath& file_path, | 1468 const FilePath& file_path, |
1483 const GetFileInfoCallback& callback); | 1469 const GetFileInfoCallback& callback); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1564 }; | 1550 }; |
1565 | 1551 |
1566 // Sets the free disk space getter for testing. | 1552 // Sets the free disk space getter for testing. |
1567 // The existing getter is deleted. | 1553 // The existing getter is deleted. |
1568 void SetFreeDiskSpaceGetterForTesting( | 1554 void SetFreeDiskSpaceGetterForTesting( |
1569 FreeDiskSpaceGetterInterface* getter); | 1555 FreeDiskSpaceGetterInterface* getter); |
1570 | 1556 |
1571 } // namespace gdata | 1557 } // namespace gdata |
1572 | 1558 |
1573 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ | 1559 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ |
OLD | NEW |