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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
198 | 198 |
199 // Finds file info by using |resource_id|. This call does not initiate | 199 // Finds file info by using |resource_id|. This call does not initiate |
200 // content refreshing and will invoke one of |delegate| methods directly as | 200 // content refreshing and will invoke one of |delegate| methods directly as |
201 // it executes. | 201 // it executes. |
202 // | 202 // |
203 // Can be called from UI/IO thread. |delegate| is run on the calling thread | 203 // Can be called from UI/IO thread. |delegate| is run on the calling thread |
204 // synchronously. | 204 // synchronously. |
205 virtual void FindEntryByResourceIdSync(const std::string& resource_id, | 205 virtual void FindEntryByResourceIdSync(const std::string& resource_id, |
206 FindEntryDelegate* delegate) = 0; | 206 FindEntryDelegate* delegate) = 0; |
207 | 207 |
208 // Does server side content search for |search_query|. Search results will be | |
satorux1
2012/05/03 17:58:34
please move this function to where ReadDirectoryBy
tbarzic
2012/05/03 23:56:17
Done.
| |
209 // returned as gdata entries in temp directory proto, and their | |
210 // title/file_name will be formatted as |<resource_id>.<original_file_name>|. | |
211 // | |
212 // Can be called from UI/IO thread. |callback| is run on calling thread. | |
213 virtual void SearchContent(const std::string& search_query, | |
satorux1
2012/05/03 17:58:34
maybe GetEntriesByQueryAsync()? (we'll drop Async
tbarzic
2012/05/03 23:56:17
Done.
| |
214 const ReadDirectoryCallback& callback) = 0; | |
215 | |
208 // Initiates transfer of |local_file_path| to |remote_dest_file_path|. | 216 // Initiates transfer of |local_file_path| to |remote_dest_file_path|. |
209 // |local_file_path| must be a file from the local file system, | 217 // |local_file_path| must be a file from the local file system, |
210 // |remote_dest_file_path| is the virtual destination path within gdata file | 218 // |remote_dest_file_path| is the virtual destination path within gdata file |
211 // system. | 219 // system. |
212 // | 220 // |
213 // Must be called from *UI* thread. |callback| is run on the calling thread. | 221 // Must be called from *UI* thread. |callback| is run on the calling thread. |
214 virtual void TransferFile(const FilePath& local_file_path, | 222 virtual void TransferFile(const FilePath& local_file_path, |
215 const FilePath& remote_dest_file_path, | 223 const FilePath& remote_dest_file_path, |
216 const FileOperationCallback& callback) = 0; | 224 const FileOperationCallback& callback) = 0; |
217 | 225 |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
396 DocumentsServiceInterface* documents_service); | 404 DocumentsServiceInterface* documents_service); |
397 virtual ~GDataFileSystem(); | 405 virtual ~GDataFileSystem(); |
398 | 406 |
399 // GDataFileSystem overrides. | 407 // GDataFileSystem overrides. |
400 virtual void Initialize() OVERRIDE; | 408 virtual void Initialize() OVERRIDE; |
401 virtual void AddObserver(Observer* observer) OVERRIDE; | 409 virtual void AddObserver(Observer* observer) OVERRIDE; |
402 virtual void RemoveObserver(Observer* observer) OVERRIDE; | 410 virtual void RemoveObserver(Observer* observer) OVERRIDE; |
403 virtual void Authenticate(const AuthStatusCallback& callback) OVERRIDE; | 411 virtual void Authenticate(const AuthStatusCallback& callback) OVERRIDE; |
404 virtual void FindEntryByResourceIdSync(const std::string& resource_id, | 412 virtual void FindEntryByResourceIdSync(const std::string& resource_id, |
405 FindEntryDelegate* delegate) OVERRIDE; | 413 FindEntryDelegate* delegate) OVERRIDE; |
414 virtual void SearchContent(const std::string& search_query, | |
415 const ReadDirectoryCallback& callback) OVERRIDE; | |
406 virtual void TransferFile(const FilePath& local_file_path, | 416 virtual void TransferFile(const FilePath& local_file_path, |
407 const FilePath& remote_dest_file_path, | 417 const FilePath& remote_dest_file_path, |
408 const FileOperationCallback& callback) OVERRIDE; | 418 const FileOperationCallback& callback) OVERRIDE; |
409 virtual void Copy(const FilePath& src_file_path, | 419 virtual void Copy(const FilePath& src_file_path, |
410 const FilePath& dest_file_path, | 420 const FilePath& dest_file_path, |
411 const FileOperationCallback& callback) OVERRIDE; | 421 const FileOperationCallback& callback) OVERRIDE; |
412 virtual void Move(const FilePath& src_file_path, | 422 virtual void Move(const FilePath& src_file_path, |
413 const FilePath& dest_file_path, | 423 const FilePath& dest_file_path, |
414 const FileOperationCallback& callback) OVERRIDE; | 424 const FileOperationCallback& callback) OVERRIDE; |
415 virtual void Remove(const FilePath& file_path, | 425 virtual void Remove(const FilePath& file_path, |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
540 std::string mime_type; | 550 std::string mime_type; |
541 const GetFileCallback get_file_callback; | 551 const GetFileCallback get_file_callback; |
542 const GetDownloadDataCallback get_download_data_callback; | 552 const GetDownloadDataCallback get_download_data_callback; |
543 }; | 553 }; |
544 | 554 |
545 // Defines set of parameters sent to callback OnGetDocuments(). | 555 // Defines set of parameters sent to callback OnGetDocuments(). |
546 struct GetDocumentsParams { | 556 struct GetDocumentsParams { |
547 GetDocumentsParams(int start_changestamp, | 557 GetDocumentsParams(int start_changestamp, |
548 int root_feed_changestamp, | 558 int root_feed_changestamp, |
549 std::vector<DocumentFeed*>* feed_list, | 559 std::vector<DocumentFeed*>* feed_list, |
560 bool allow_multiple_feeds, | |
550 const FilePath& search_file_path, | 561 const FilePath& search_file_path, |
562 const std::string& search_query, | |
551 const FindEntryCallback& callback); | 563 const FindEntryCallback& callback); |
552 ~GetDocumentsParams(); | 564 ~GetDocumentsParams(); |
553 | 565 |
554 // Changestamps are positive numbers in increasing order. The difference | 566 // Changestamps are positive numbers in increasing order. The difference |
555 // between two changestamps is proportional equal to number of items in | 567 // between two changestamps is proportional equal to number of items in |
556 // delta feed between them - bigger the difference, more likely bigger | 568 // delta feed between them - bigger the difference, more likely bigger |
557 // number of items in delta feeds. | 569 // number of items in delta feeds. |
558 int start_changestamp; | 570 int start_changestamp; |
559 int root_feed_changestamp; | 571 int root_feed_changestamp; |
560 scoped_ptr<std::vector<DocumentFeed*> > feed_list; | 572 scoped_ptr<std::vector<DocumentFeed*> > feed_list; |
573 // Should we stop after getting first feed chunk, even if there is more | |
574 // data. | |
575 bool allow_multiple_feeds; | |
satorux1
2012/05/03 17:58:34
maybe should_fetch_multipe_feeds ?
tbarzic
2012/05/03 23:56:17
Done.
| |
561 FilePath search_file_path; | 576 FilePath search_file_path; |
577 std::string search_query; | |
562 FindEntryCallback callback; | 578 FindEntryCallback callback; |
563 }; | 579 }; |
564 | 580 |
565 typedef std::map<std::string /* resource_id */, GDataEntry*> | 581 typedef std::map<std::string /* resource_id */, GDataEntry*> |
566 FileResourceIdMap; | 582 FileResourceIdMap; |
567 | 583 |
568 // Callback similar to FileOperationCallback but with a given |file_path|. | 584 // Callback similar to FileOperationCallback but with a given |file_path|. |
569 typedef base::Callback<void(base::PlatformFileError error, | 585 typedef base::Callback<void(base::PlatformFileError error, |
570 const FilePath& file_path)> | 586 const FilePath& file_path)> |
571 FilePathUpdateCallback; | 587 FilePathUpdateCallback; |
572 | 588 |
589 // Callback run as a response to LoadFeedFromServer. | |
590 typedef base::Callback<void(GetDocumentsParams* params, | |
591 base::PlatformFileError error)> | |
592 LoadDocumentFeedCallback; | |
593 | |
573 // Finds entry object by |file_path| and returns the entry object. | 594 // Finds entry object by |file_path| and returns the entry object. |
574 // Returns NULL if it does not find the entry. | 595 // Returns NULL if it does not find the entry. |
575 GDataEntry* GetGDataEntryByPath(const FilePath& file_path); | 596 GDataEntry* GetGDataEntryByPath(const FilePath& file_path); |
576 | 597 |
577 // Inits cache directory paths in the provided root. | 598 // Inits cache directory paths in the provided root. |
578 // Should be called before cache is initialized. | 599 // Should be called before cache is initialized. |
579 void SetCachePaths(const FilePath& root_path); | 600 void SetCachePaths(const FilePath& root_path); |
580 | 601 |
581 // Initiates upload operation of file defined with |file_name|, | 602 // Initiates upload operation of file defined with |file_name|, |
582 // |content_type| and |content_length|. The operation will place the newly | 603 // |content_type| and |content_length|. The operation will place the newly |
(...skipping 14 matching lines...) Expand all Loading... | |
597 // TODO(satorux,achuith): Remove this: crosbug.com/29943 | 618 // TODO(satorux,achuith): Remove this: crosbug.com/29943 |
598 void ResumeUpload(const ResumeUploadParams& params, | 619 void ResumeUpload(const ResumeUploadParams& params, |
599 const ResumeFileUploadCallback& callback); | 620 const ResumeFileUploadCallback& callback); |
600 | 621 |
601 // Converts document feed from gdata service into DirectoryInfo. On failure, | 622 // Converts document feed from gdata service into DirectoryInfo. On failure, |
602 // returns NULL and fills in |error| with an appropriate value. | 623 // returns NULL and fills in |error| with an appropriate value. |
603 GDataDirectory* ParseGDataFeed(GDataErrorCode status, | 624 GDataDirectory* ParseGDataFeed(GDataErrorCode status, |
604 base::Value* data, | 625 base::Value* data, |
605 base::PlatformFileError *error); | 626 base::PlatformFileError *error); |
606 | 627 |
628 // Callback passed to |LoadFeedFromServer| from |SearchContent| method. | |
629 // |callback| is that should be run with data received from | |
630 // |LoadFeedFromServer|. | |
631 // |params| params used for getting document feed for content search. | |
632 // |status| was |LoadFeedFromServer| successfull. | |
633 void OnSearchContent(const ReadDirectoryCallback& callback, | |
634 GetDocumentsParams* params, | |
635 base::PlatformFileError status); | |
636 | |
607 // Initiates transfer of |local_file_path| with |resource_id| to | 637 // Initiates transfer of |local_file_path| with |resource_id| to |
608 // |remote_dest_file_path|. |local_file_path| must be a file from the local | 638 // |remote_dest_file_path|. |local_file_path| must be a file from the local |
609 // file system, |remote_dest_file_path| is the virtual destination path within | 639 // file system, |remote_dest_file_path| is the virtual destination path within |
610 // gdata file system. If |resource_id| is a non-empty string, the transfer is | 640 // gdata file system. If |resource_id| is a non-empty string, the transfer is |
611 // handled by CopyDocumentToDirectory. Otherwise, the transfer is handled by | 641 // handled by CopyDocumentToDirectory. Otherwise, the transfer is handled by |
612 // TransferRegularFile. | 642 // TransferRegularFile. |
613 // | 643 // |
614 // Must be called from *UI* thread. |callback| is run on the calling thread. | 644 // Must be called from *UI* thread. |callback| is run on the calling thread. |
615 void TransferFileForResourceId(const FilePath& local_file_path, | 645 void TransferFileForResourceId(const FilePath& local_file_path, |
616 const FilePath& remote_dest_file_path, | 646 const FilePath& remote_dest_file_path, |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
672 base::PlatformFileError error, | 702 base::PlatformFileError error, |
673 const FilePath& file_path); | 703 const FilePath& file_path); |
674 | 704 |
675 // Removes file under |file_path| from in-memory snapshot of the file system. | 705 // Removes file under |file_path| from in-memory snapshot of the file system. |
676 // |resource_id| contains the resource id of the removed file if it was a | 706 // |resource_id| contains the resource id of the removed file if it was a |
677 // file. | 707 // file. |
678 // Return PLATFORM_FILE_OK if successful. | 708 // Return PLATFORM_FILE_OK if successful. |
679 base::PlatformFileError RemoveEntryFromGData(const FilePath& file_path, | 709 base::PlatformFileError RemoveEntryFromGData(const FilePath& file_path, |
680 std::string* resource_id); | 710 std::string* resource_id); |
681 | 711 |
682 // Callback for handling feed content fetching while searching for file info. | 712 // Callback for handling response from |GDataDocumentsService::GetDocuments|. |
683 // This callback is invoked after async feed fetch operation that was | 713 // Invokes |callback| when done. |
684 // invoked by StartDirectoryRefresh() completes. This callback will update | 714 void OnGetDocuments(const LoadDocumentFeedCallback& callback, |
685 // the content of the refreshed directory object and continue initially | 715 GetDocumentsParams* params, |
686 // started FindEntryByPath() request. | |
687 void OnGetDocuments(GetDocumentsParams* params, | |
688 GDataErrorCode status, | 716 GDataErrorCode status, |
689 scoped_ptr<base::Value> data); | 717 scoped_ptr<base::Value> data); |
690 | 718 |
691 // A pass-through callback used for bridging from | 719 // A pass-through callback used for bridging from |
692 // FilePathUpdateCallback to FileOperationCallback. | 720 // FilePathUpdateCallback to FileOperationCallback. |
693 void OnFilePathUpdated(const FileOperationCallback& cllback, | 721 void OnFilePathUpdated(const FileOperationCallback& cllback, |
694 base::PlatformFileError error, | 722 base::PlatformFileError error, |
695 const FilePath& file_path); | 723 const FilePath& file_path); |
696 | 724 |
697 // Callback for handling resource rename attempt. | 725 // Callback for handling resource rename attempt. |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
846 const FilePath& search_file_path, | 874 const FilePath& search_file_path, |
847 const FindEntryCallback& callback, | 875 const FindEntryCallback& callback, |
848 GDataErrorCode error, | 876 GDataErrorCode error, |
849 scoped_ptr<base::Value> feed_data); | 877 scoped_ptr<base::Value> feed_data); |
850 | 878 |
851 // Starts root feed load from the server. Value of |start_changestamp| | 879 // Starts root feed load from the server. Value of |start_changestamp| |
852 // determines the type of feed to load - 0 means root feed, every other | 880 // determines the type of feed to load - 0 means root feed, every other |
853 // value would trigger delta feed. | 881 // value would trigger delta feed. |
854 // In the case of loading the root feed we use |root_feed_changestamp| as its | 882 // In the case of loading the root feed we use |root_feed_changestamp| as its |
855 // initial changestamp value since it does not come with that info. | 883 // initial changestamp value since it does not come with that info. |
856 // If successful, it will try to find the file upon retrieval completion. | 884 // When done |load_feed_callback| is invoked. |
885 // |entry_found_callback| is used only when this is invoked while searching | |
886 // for file info, and is used in |load_feed_callback|. If successful, it will | |
887 // try to find the file upon retrieval completion. | |
888 // |allow_multiple_feeds| is true iff don't want to stop feed loading after we | |
889 // retrieve first feed chunk. | |
890 // If invoked as a part of content search, query will be set in | |
891 // |search_query|. | |
857 void LoadFeedFromServer(int start_changestamp, | 892 void LoadFeedFromServer(int start_changestamp, |
858 int root_feed_changestamp, | 893 int root_feed_changestamp, |
894 bool allow_multiple_feeds, | |
859 const FilePath& search_file_path, | 895 const FilePath& search_file_path, |
860 const FindEntryCallback& callback); | 896 const std::string& search_query, |
897 const FindEntryCallback& entry_found_callback, | |
898 const LoadDocumentFeedCallback& load_feed_callback); | |
899 | |
900 // Callback for handling feed content fetching while searching for file info. | |
901 // This callback is invoked after async feed fetch operation that was | |
902 // invoked by StartDirectoryRefresh() completes. This callback will update | |
903 // the content of the refreshed directory object and continue initially | |
904 // started FindEntryByPath() request. | |
905 void OnFeedFromServerLoaded(GetDocumentsParams* params, | |
906 base::PlatformFileError status); | |
861 | 907 |
862 // Starts root feed load from the cache. If successful, it will try to find | 908 // Starts root feed load from the cache. If successful, it will try to find |
863 // the file upon retrieval completion. In addition to that, it will | 909 // the file upon retrieval completion. In addition to that, it will |
864 // initate retrieval of the root feed from the server if | 910 // initate retrieval of the root feed from the server if |
865 // |should_load_from_server| is set. | 911 // |should_load_from_server| is set. |
866 void LoadRootFeedFromCache(bool should_load_from_server, | 912 void LoadRootFeedFromCache(bool should_load_from_server, |
867 const FilePath& search_file_path, | 913 const FilePath& search_file_path, |
868 const FindEntryCallback& callback); | 914 const FindEntryCallback& callback); |
869 | 915 |
870 // Callback for handling root directory refresh from the cache. | 916 // Callback for handling root directory refresh from the cache. |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1255 const FilePath& directory_path, | 1301 const FilePath& directory_path, |
1256 GDataEntry* entry); | 1302 GDataEntry* entry); |
1257 | 1303 |
1258 // Finds file info by using virtual |file_path|. This call will also | 1304 // Finds file info by using virtual |file_path|. This call will also |
1259 // retrieve and refresh file system content from server and disk cache. | 1305 // retrieve and refresh file system content from server and disk cache. |
1260 void FindEntryByPathAsyncOnUIThread(const FilePath& search_file_path, | 1306 void FindEntryByPathAsyncOnUIThread(const FilePath& search_file_path, |
1261 const FindEntryCallback& callback); | 1307 const FindEntryCallback& callback); |
1262 | 1308 |
1263 // The following functions are used to forward calls to asynchronous public | 1309 // The following functions are used to forward calls to asynchronous public |
1264 // member functions to UI thread. | 1310 // member functions to UI thread. |
1311 void SearchContentOnUIThread(const std::string& search_query, | |
1312 const ReadDirectoryCallback& callback); | |
1265 void CopyOnUIThread(const FilePath& src_file_path, | 1313 void CopyOnUIThread(const FilePath& src_file_path, |
1266 const FilePath& dest_file_path, | 1314 const FilePath& dest_file_path, |
1267 const FileOperationCallback& callback); | 1315 const FileOperationCallback& callback); |
1268 void MoveOnUIThread(const FilePath& src_file_path, | 1316 void MoveOnUIThread(const FilePath& src_file_path, |
1269 const FilePath& dest_file_path, | 1317 const FilePath& dest_file_path, |
1270 const FileOperationCallback& callback); | 1318 const FileOperationCallback& callback); |
1271 void RemoveOnUIThread(const FilePath& file_path, | 1319 void RemoveOnUIThread(const FilePath& file_path, |
1272 bool is_recursive, | 1320 bool is_recursive, |
1273 const FileOperationCallback& callback); | 1321 const FileOperationCallback& callback); |
1274 void CreateDirectoryOnUIThread(const FilePath& directory_path, | 1322 void CreateDirectoryOnUIThread(const FilePath& directory_path, |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1364 }; | 1412 }; |
1365 | 1413 |
1366 // Sets the free disk space getter for testing. | 1414 // Sets the free disk space getter for testing. |
1367 // The existing getter is deleted. | 1415 // The existing getter is deleted. |
1368 void SetFreeDiskSpaceGetterForTesting( | 1416 void SetFreeDiskSpaceGetterForTesting( |
1369 FreeDiskSpaceGetterInterface* getter); | 1417 FreeDiskSpaceGetterInterface* getter); |
1370 | 1418 |
1371 } // namespace gdata | 1419 } // namespace gdata |
1372 | 1420 |
1373 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ | 1421 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ |
OLD | NEW |