Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_file_system.h

Issue 10274002: Add gdata content search (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: style nits Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 const GetFileInfoCallback& callback) = 0; 342 const GetFileInfoCallback& callback) = 0;
343 343
344 // Finds and reads a directory by |file_path|. This call will also retrieve 344 // Finds and reads a directory by |file_path|. This call will also retrieve
345 // and refresh file system content from server and disk cache. 345 // and refresh file system content from server and disk cache.
346 // 346 //
347 // Can be called from UI/IO thread. |callback| is run on the calling thread. 347 // Can be called from UI/IO thread. |callback| is run on the calling thread.
348 virtual void ReadDirectoryByPathAsync( 348 virtual void ReadDirectoryByPathAsync(
349 const FilePath& file_path, 349 const FilePath& file_path,
350 const ReadDirectoryCallback& callback) = 0; 350 const ReadDirectoryCallback& callback) = 0;
351 351
352 // Does server side content search for |search_query|. Search results will be
353 // returned as gdata entries in temp directory proto, and their
354 // title/file_name will be formatted as |<resource_id>.<original_file_name>|.
355 //
356 // Can be called from UI/IO thread. |callback| is run on the calling thread.
357 virtual void SearchAsync(const std::string& search_query,
358 const ReadDirectoryCallback& callback) = 0;
359
360
352 // Finds a file (not a directory) by |file_path| and returns its key 361 // Finds a file (not a directory) by |file_path| and returns its key
353 // |properties|. Returns true if file was found. 362 // |properties|. Returns true if file was found.
354 // TODO(satorux): Remove this: crosbug.com/30066. 363 // TODO(satorux): Remove this: crosbug.com/30066.
355 virtual bool GetFileInfoByPath(const FilePath& file_path, 364 virtual bool GetFileInfoByPath(const FilePath& file_path,
356 GDataFileProperties* properties) = 0; 365 GDataFileProperties* properties) = 0;
357 366
358 // Returns true if the given path is under gdata cache directory, i.e. 367 // Returns true if the given path is under gdata cache directory, i.e.
359 // <user_profile_dir>/GCache/v1 368 // <user_profile_dir>/GCache/v1
360 virtual bool IsUnderGDataCacheDirectory(const FilePath& path) const = 0; 369 virtual bool IsUnderGDataCacheDirectory(const FilePath& path) const = 0;
361 370
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 // GDataFileSystem overrides. 416 // GDataFileSystem overrides.
408 virtual void Initialize() OVERRIDE; 417 virtual void Initialize() OVERRIDE;
409 virtual void AddObserver(Observer* observer) OVERRIDE; 418 virtual void AddObserver(Observer* observer) OVERRIDE;
410 virtual void RemoveObserver(Observer* observer) OVERRIDE; 419 virtual void RemoveObserver(Observer* observer) OVERRIDE;
411 virtual void StartUpdates() OVERRIDE; 420 virtual void StartUpdates() OVERRIDE;
412 virtual void StopUpdates() OVERRIDE; 421 virtual void StopUpdates() OVERRIDE;
413 virtual void CheckForUpdates() OVERRIDE; 422 virtual void CheckForUpdates() OVERRIDE;
414 virtual void Authenticate(const AuthStatusCallback& callback) OVERRIDE; 423 virtual void Authenticate(const AuthStatusCallback& callback) OVERRIDE;
415 virtual void FindEntryByResourceIdSync(const std::string& resource_id, 424 virtual void FindEntryByResourceIdSync(const std::string& resource_id,
416 FindEntryDelegate* delegate) OVERRIDE; 425 FindEntryDelegate* delegate) OVERRIDE;
426 virtual void SearchAsync(const std::string& search_query,
427 const ReadDirectoryCallback& callback) OVERRIDE;
417 virtual void TransferFile(const FilePath& local_file_path, 428 virtual void TransferFile(const FilePath& local_file_path,
418 const FilePath& remote_dest_file_path, 429 const FilePath& remote_dest_file_path,
419 const FileOperationCallback& callback) OVERRIDE; 430 const FileOperationCallback& callback) OVERRIDE;
420 virtual void Copy(const FilePath& src_file_path, 431 virtual void Copy(const FilePath& src_file_path,
421 const FilePath& dest_file_path, 432 const FilePath& dest_file_path,
422 const FileOperationCallback& callback) OVERRIDE; 433 const FileOperationCallback& callback) OVERRIDE;
423 virtual void Move(const FilePath& src_file_path, 434 virtual void Move(const FilePath& src_file_path,
424 const FilePath& dest_file_path, 435 const FilePath& dest_file_path,
425 const FileOperationCallback& callback) OVERRIDE; 436 const FileOperationCallback& callback) OVERRIDE;
426 virtual void Remove(const FilePath& file_path, 437 virtual void Remove(const FilePath& file_path,
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 std::string mime_type; 562 std::string mime_type;
552 const GetFileCallback get_file_callback; 563 const GetFileCallback get_file_callback;
553 const GetDownloadDataCallback get_download_data_callback; 564 const GetDownloadDataCallback get_download_data_callback;
554 }; 565 };
555 566
556 // Defines set of parameters sent to callback OnGetDocuments(). 567 // Defines set of parameters sent to callback OnGetDocuments().
557 struct GetDocumentsParams { 568 struct GetDocumentsParams {
558 GetDocumentsParams(int start_changestamp, 569 GetDocumentsParams(int start_changestamp,
559 int root_feed_changestamp, 570 int root_feed_changestamp,
560 std::vector<DocumentFeed*>* feed_list, 571 std::vector<DocumentFeed*>* feed_list,
572 bool should_fetch_multiple_feeds,
561 const FilePath& search_file_path, 573 const FilePath& search_file_path,
574 const std::string& search_query,
562 const FindEntryCallback& callback); 575 const FindEntryCallback& callback);
563 ~GetDocumentsParams(); 576 ~GetDocumentsParams();
564 577
565 // Changestamps are positive numbers in increasing order. The difference 578 // Changestamps are positive numbers in increasing order. The difference
566 // between two changestamps is proportional equal to number of items in 579 // between two changestamps is proportional equal to number of items in
567 // delta feed between them - bigger the difference, more likely bigger 580 // delta feed between them - bigger the difference, more likely bigger
568 // number of items in delta feeds. 581 // number of items in delta feeds.
569 int start_changestamp; 582 int start_changestamp;
570 int root_feed_changestamp; 583 int root_feed_changestamp;
571 scoped_ptr<std::vector<DocumentFeed*> > feed_list; 584 scoped_ptr<std::vector<DocumentFeed*> > feed_list;
585 // Should we stop after getting first feed chunk, even if there is more
586 // data.
587 bool should_fetch_multiple_feeds;
572 FilePath search_file_path; 588 FilePath search_file_path;
589 std::string search_query;
573 FindEntryCallback callback; 590 FindEntryCallback callback;
574 }; 591 };
575 592
576 typedef std::map<std::string /* resource_id */, GDataEntry*> 593 typedef std::map<std::string /* resource_id */, GDataEntry*>
577 FileResourceIdMap; 594 FileResourceIdMap;
578 595
579 // Callback similar to FileOperationCallback but with a given |file_path|. 596 // Callback similar to FileOperationCallback but with a given |file_path|.
580 typedef base::Callback<void(base::PlatformFileError error, 597 typedef base::Callback<void(base::PlatformFileError error,
581 const FilePath& file_path)> 598 const FilePath& file_path)>
582 FilePathUpdateCallback; 599 FilePathUpdateCallback;
583 600
601 // Callback run as a response to LoadFeedFromServer.
602 typedef base::Callback<void(GetDocumentsParams* params,
603 base::PlatformFileError error)>
604 LoadDocumentFeedCallback;
605
584 // Finds entry object by |file_path| and returns the entry object. 606 // Finds entry object by |file_path| and returns the entry object.
585 // Returns NULL if it does not find the entry. 607 // Returns NULL if it does not find the entry.
586 GDataEntry* GetGDataEntryByPath(const FilePath& file_path); 608 GDataEntry* GetGDataEntryByPath(const FilePath& file_path);
587 609
588 // Inits cache directory paths in the provided root. 610 // Inits cache directory paths in the provided root.
589 // Should be called before cache is initialized. 611 // Should be called before cache is initialized.
590 void SetCachePaths(const FilePath& root_path); 612 void SetCachePaths(const FilePath& root_path);
591 613
592 // Initiates upload operation of file defined with |file_name|, 614 // Initiates upload operation of file defined with |file_name|,
593 // |content_type| and |content_length|. The operation will place the newly 615 // |content_type| and |content_length|. The operation will place the newly
(...skipping 14 matching lines...) Expand all
608 // TODO(satorux,achuith): Remove this: crosbug.com/29943 630 // TODO(satorux,achuith): Remove this: crosbug.com/29943
609 void ResumeUpload(const ResumeUploadParams& params, 631 void ResumeUpload(const ResumeUploadParams& params,
610 const ResumeFileUploadCallback& callback); 632 const ResumeFileUploadCallback& callback);
611 633
612 // Converts document feed from gdata service into DirectoryInfo. On failure, 634 // Converts document feed from gdata service into DirectoryInfo. On failure,
613 // returns NULL and fills in |error| with an appropriate value. 635 // returns NULL and fills in |error| with an appropriate value.
614 GDataDirectory* ParseGDataFeed(GDataErrorCode status, 636 GDataDirectory* ParseGDataFeed(GDataErrorCode status,
615 base::Value* data, 637 base::Value* data,
616 base::PlatformFileError *error); 638 base::PlatformFileError *error);
617 639
640 // Callback passed to |LoadFeedFromServer| from |SearchAsync| method.
641 // |callback| is that should be run with data received from
642 // |LoadFeedFromServer|.
643 // |params| params used for getting document feed for content search.
644 // |error| error code returned by |LoadFeedFromServer|.
645 void OnSearch(const ReadDirectoryCallback& callback,
646 GetDocumentsParams* params,
647 base::PlatformFileError error);
648
618 // Initiates transfer of |local_file_path| with |resource_id| to 649 // Initiates transfer of |local_file_path| with |resource_id| to
619 // |remote_dest_file_path|. |local_file_path| must be a file from the local 650 // |remote_dest_file_path|. |local_file_path| must be a file from the local
620 // file system, |remote_dest_file_path| is the virtual destination path within 651 // file system, |remote_dest_file_path| is the virtual destination path within
621 // gdata file system. If |resource_id| is a non-empty string, the transfer is 652 // gdata file system. If |resource_id| is a non-empty string, the transfer is
622 // handled by CopyDocumentToDirectory. Otherwise, the transfer is handled by 653 // handled by CopyDocumentToDirectory. Otherwise, the transfer is handled by
623 // TransferRegularFile. 654 // TransferRegularFile.
624 // 655 //
625 // Must be called from *UI* thread. |callback| is run on the calling thread. 656 // Must be called from *UI* thread. |callback| is run on the calling thread.
626 void TransferFileForResourceId(const FilePath& local_file_path, 657 void TransferFileForResourceId(const FilePath& local_file_path,
627 const FilePath& remote_dest_file_path, 658 const FilePath& remote_dest_file_path,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 base::PlatformFileError error, 714 base::PlatformFileError error,
684 const FilePath& file_path); 715 const FilePath& file_path);
685 716
686 // Removes file under |file_path| from in-memory snapshot of the file system. 717 // Removes file under |file_path| from in-memory snapshot of the file system.
687 // |resource_id| contains the resource id of the removed file if it was a 718 // |resource_id| contains the resource id of the removed file if it was a
688 // file. 719 // file.
689 // Return PLATFORM_FILE_OK if successful. 720 // Return PLATFORM_FILE_OK if successful.
690 base::PlatformFileError RemoveEntryFromGData(const FilePath& file_path, 721 base::PlatformFileError RemoveEntryFromGData(const FilePath& file_path,
691 std::string* resource_id); 722 std::string* resource_id);
692 723
693 // Callback for handling feed content fetching while searching for file info. 724 // Callback for handling response from |GDataDocumentsService::GetDocuments|.
694 // This callback is invoked after async feed fetch operation that was 725 // Invokes |callback| when done.
695 // invoked by StartDirectoryRefresh() completes. This callback will update 726 void OnGetDocuments(const LoadDocumentFeedCallback& callback,
696 // the content of the refreshed directory object and continue initially 727 GetDocumentsParams* params,
697 // started FindEntryByPath() request.
698 void OnGetDocuments(GetDocumentsParams* params,
699 GDataErrorCode status, 728 GDataErrorCode status,
700 scoped_ptr<base::Value> data); 729 scoped_ptr<base::Value> data);
701 730
702 // A pass-through callback used for bridging from 731 // A pass-through callback used for bridging from
703 // FilePathUpdateCallback to FileOperationCallback. 732 // FilePathUpdateCallback to FileOperationCallback.
704 void OnFilePathUpdated(const FileOperationCallback& cllback, 733 void OnFilePathUpdated(const FileOperationCallback& cllback,
705 base::PlatformFileError error, 734 base::PlatformFileError error,
706 const FilePath& file_path); 735 const FilePath& file_path);
707 736
708 // Callback for handling resource rename attempt. 737 // Callback for handling resource rename attempt.
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 const FilePath& search_file_path, 886 const FilePath& search_file_path,
858 const FindEntryCallback& callback, 887 const FindEntryCallback& callback,
859 GDataErrorCode error, 888 GDataErrorCode error,
860 scoped_ptr<base::Value> feed_data); 889 scoped_ptr<base::Value> feed_data);
861 890
862 // Starts root feed load from the server. Value of |start_changestamp| 891 // Starts root feed load from the server. Value of |start_changestamp|
863 // determines the type of feed to load - 0 means root feed, every other 892 // determines the type of feed to load - 0 means root feed, every other
864 // value would trigger delta feed. 893 // value would trigger delta feed.
865 // In the case of loading the root feed we use |root_feed_changestamp| as its 894 // In the case of loading the root feed we use |root_feed_changestamp| as its
866 // initial changestamp value since it does not come with that info. 895 // initial changestamp value since it does not come with that info.
867 // If successful, it will try to find the file upon retrieval completion. 896 // When done |load_feed_callback| is invoked.
897 // |entry_found_callback| is used only when this is invoked while searching
898 // for file info, and is used in |load_feed_callback|. If successful, it will
899 // try to find the file upon retrieval completion.
900 // |should_fetch_multiple_feeds| is true iff don't want to stop feed loading
901 // after we retrieve first feed chunk.
902 // If invoked as a part of content search, query will be set in
903 // |search_query|.
868 void LoadFeedFromServer(int start_changestamp, 904 void LoadFeedFromServer(int start_changestamp,
869 int root_feed_changestamp, 905 int root_feed_changestamp,
906 bool should_fetch_multiple_feeds,
870 const FilePath& search_file_path, 907 const FilePath& search_file_path,
871 const FindEntryCallback& callback); 908 const std::string& search_query,
909 const FindEntryCallback& entry_found_callback,
910 const LoadDocumentFeedCallback& load_feed_callback);
911
912 // Callback for handling feed content fetching while searching for file info.
913 // This callback is invoked after async feed fetch operation that was
914 // invoked by StartDirectoryRefresh() completes. This callback will update
915 // the content of the refreshed directory object and continue initially
916 // started FindEntryByPath() request.
917 void OnFeedFromServerLoaded(GetDocumentsParams* params,
918 base::PlatformFileError status);
872 919
873 // Starts root feed load from the cache. If successful, it will try to find 920 // Starts root feed load from the cache. If successful, it will try to find
874 // the file upon retrieval completion. In addition to that, it will 921 // the file upon retrieval completion. In addition to that, it will
875 // initate retrieval of the root feed from the server if 922 // initate retrieval of the root feed from the server if
876 // |should_load_from_server| is set. 923 // |should_load_from_server| is set.
877 void LoadRootFeedFromCache(bool should_load_from_server, 924 void LoadRootFeedFromCache(bool should_load_from_server,
878 const FilePath& search_file_path, 925 const FilePath& search_file_path,
879 const FindEntryCallback& callback); 926 const FindEntryCallback& callback);
880 927
881 // Callback for handling root directory refresh from the cache. 928 // Callback for handling root directory refresh from the cache.
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
1266 const FilePath& directory_path, 1313 const FilePath& directory_path,
1267 GDataEntry* entry); 1314 GDataEntry* entry);
1268 1315
1269 // Finds file info by using virtual |file_path|. This call will also 1316 // Finds file info by using virtual |file_path|. This call will also
1270 // retrieve and refresh file system content from server and disk cache. 1317 // retrieve and refresh file system content from server and disk cache.
1271 void FindEntryByPathAsyncOnUIThread(const FilePath& search_file_path, 1318 void FindEntryByPathAsyncOnUIThread(const FilePath& search_file_path,
1272 const FindEntryCallback& callback); 1319 const FindEntryCallback& callback);
1273 1320
1274 // The following functions are used to forward calls to asynchronous public 1321 // The following functions are used to forward calls to asynchronous public
1275 // member functions to UI thread. 1322 // member functions to UI thread.
1323 void SearchAsyncOnUIThread(const std::string& search_query,
1324 const ReadDirectoryCallback& callback);
1276 void CopyOnUIThread(const FilePath& src_file_path, 1325 void CopyOnUIThread(const FilePath& src_file_path,
1277 const FilePath& dest_file_path, 1326 const FilePath& dest_file_path,
1278 const FileOperationCallback& callback); 1327 const FileOperationCallback& callback);
1279 void MoveOnUIThread(const FilePath& src_file_path, 1328 void MoveOnUIThread(const FilePath& src_file_path,
1280 const FilePath& dest_file_path, 1329 const FilePath& dest_file_path,
1281 const FileOperationCallback& callback); 1330 const FileOperationCallback& callback);
1282 void RemoveOnUIThread(const FilePath& file_path, 1331 void RemoveOnUIThread(const FilePath& file_path,
1283 bool is_recursive, 1332 bool is_recursive,
1284 const FileOperationCallback& callback); 1333 const FileOperationCallback& callback);
1285 void CreateDirectoryOnUIThread(const FilePath& directory_path, 1334 void CreateDirectoryOnUIThread(const FilePath& directory_path,
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1378 }; 1427 };
1379 1428
1380 // Sets the free disk space getter for testing. 1429 // Sets the free disk space getter for testing.
1381 // The existing getter is deleted. 1430 // The existing getter is deleted.
1382 void SetFreeDiskSpaceGetterForTesting( 1431 void SetFreeDiskSpaceGetterForTesting(
1383 FreeDiskSpaceGetterInterface* getter); 1432 FreeDiskSpaceGetterInterface* getter);
1384 1433
1385 } // namespace gdata 1434 } // namespace gdata
1386 1435
1387 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ 1436 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698