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

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

Issue 10543037: gdata: Convert public synchronous functions in GDataFileSystem to asynchronous. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Toni's comments @ 06/08/12 10:59AM PDT. Created 8 years, 6 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 <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 107
108 // Used by GDataFileSystem::GetDocumentResourceIdOnBlockingPool to return 108 // Used by GDataFileSystem::GetDocumentResourceIdOnBlockingPool to return
109 // the resource ID read from a document JSON file on the local file system. 109 // the resource ID read from a document JSON file on the local file system.
110 typedef base::Callback<void(const std::string& resource_id)> 110 typedef base::Callback<void(const std::string& resource_id)>
111 GetDocumentResourceIdCallback; 111 GetDocumentResourceIdCallback;
112 112
113 // Callback for GetCacheState operation. 113 // Callback for GetCacheState operation.
114 typedef base::Callback<void(base::PlatformFileError error, 114 typedef base::Callback<void(base::PlatformFileError error,
115 int cache_state)> GetCacheStateCallback; 115 int cache_state)> GetCacheStateCallback;
116 116
117 // Helper structure used for extracting key properties from GDataFile object.
118 // TODO(satorux): Remove this as part of crosbug.com/30066
119 struct GDataFileProperties {
120 GDataFileProperties();
121 ~GDataFileProperties();
122
123 base::PlatformFileInfo file_info;
124 std::string resource_id;
125 std::string file_md5;
126 std::string mime_type;
127 GURL content_url;
128 GURL alternate_url;
129 bool is_hosted_document;
130 };
131
132 // GData file system abstraction layer. 117 // GData file system abstraction layer.
133 // The interface is defined to make GDataFileSystem mockable. 118 // The interface is defined to make GDataFileSystem mockable.
134 class GDataFileSystemInterface { 119 class GDataFileSystemInterface {
135 public: 120 public:
136 virtual ~GDataFileSystemInterface() {} 121 virtual ~GDataFileSystemInterface() {}
137 122
138 // Used to notify events on the file system. 123 // Used to notify events on the file system.
139 // All events are notified on UI thread. 124 // All events are notified on UI thread.
140 class Observer { 125 class Observer {
141 public: 126 public:
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 virtual void RequestDirectoryRefresh(const FilePath& file_path) = 0; 370 virtual void RequestDirectoryRefresh(const FilePath& file_path) = 0;
386 371
387 // Does server side content search for |search_query|. Search results will be 372 // Does server side content search for |search_query|. Search results will be
388 // returned as gdata entries in temp directory proto, and their 373 // returned as gdata entries in temp directory proto, and their
389 // title/file_name will be formatted as |<resource_id>.<original_file_name>|. 374 // title/file_name will be formatted as |<resource_id>.<original_file_name>|.
390 // 375 //
391 // Can be called from UI/IO thread. |callback| is run on the calling thread. 376 // Can be called from UI/IO thread. |callback| is run on the calling thread.
392 virtual void SearchAsync(const std::string& search_query, 377 virtual void SearchAsync(const std::string& search_query,
393 const ReadDirectoryCallback& callback) = 0; 378 const ReadDirectoryCallback& callback) = 0;
394 379
395
396 // Finds a file (not a directory) by |file_path| and returns its key
397 // |properties|. Returns true if file was found.
398 // TODO(satorux): Remove this: crosbug.com/30066.
399 virtual bool GetFileInfoByPath(const FilePath& file_path,
400 GDataFileProperties* properties) = 0;
401
402 // Returns true if the given path is under gdata cache directory, i.e. 380 // Returns true if the given path is under gdata cache directory, i.e.
403 // <user_profile_dir>/GCache/v1 381 // <user_profile_dir>/GCache/v1
404 virtual bool IsUnderGDataCacheDirectory(const FilePath& path) const = 0; 382 virtual bool IsUnderGDataCacheDirectory(const FilePath& path) const = 0;
405 383
406 // Returns the sub-directory under gdata cache directory for the given sub 384 // Returns the sub-directory under gdata cache directory for the given sub
407 // directory type. Example: <user_profile_dir>/GCache/v1/tmp 385 // directory type. Example: <user_profile_dir>/GCache/v1/tmp
408 virtual FilePath GetCacheDirectoryPath( 386 virtual FilePath GetCacheDirectoryPath(
409 GDataCache::CacheSubDirectoryType sub_dir_type) const = 0; 387 GDataCache::CacheSubDirectoryType sub_dir_type) const = 0;
410 388
411 // Returns absolute path of the file if it were cached or to be cached. 389 // Returns absolute path of the file if it were cached or to be cached.
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 const FilePath& file_path, 479 const FilePath& file_path,
502 const GetEntryInfoCallback& callback) OVERRIDE; 480 const GetEntryInfoCallback& callback) OVERRIDE;
503 virtual void GetFileInfoByPathAsync( 481 virtual void GetFileInfoByPathAsync(
504 const FilePath& file_path, 482 const FilePath& file_path,
505 const GetFileInfoCallback& callback) OVERRIDE; 483 const GetFileInfoCallback& callback) OVERRIDE;
506 virtual void ReadDirectoryByPathAsync( 484 virtual void ReadDirectoryByPathAsync(
507 const FilePath& file_path, 485 const FilePath& file_path,
508 const ReadDirectoryCallback& callback) OVERRIDE; 486 const ReadDirectoryCallback& callback) OVERRIDE;
509 virtual void RequestDirectoryRefresh( 487 virtual void RequestDirectoryRefresh(
510 const FilePath& file_path) OVERRIDE; 488 const FilePath& file_path) OVERRIDE;
511 virtual bool GetFileInfoByPath(const FilePath& file_path,
512 GDataFileProperties* properties) OVERRIDE;
513 virtual bool IsUnderGDataCacheDirectory(const FilePath& path) const OVERRIDE; 489 virtual bool IsUnderGDataCacheDirectory(const FilePath& path) const OVERRIDE;
514 virtual FilePath GetCacheDirectoryPath( 490 virtual FilePath GetCacheDirectoryPath(
515 GDataCache::CacheSubDirectoryType sub_dir_type) const OVERRIDE; 491 GDataCache::CacheSubDirectoryType sub_dir_type) const OVERRIDE;
516 virtual FilePath GetCacheFilePath( 492 virtual FilePath GetCacheFilePath(
517 const std::string& resource_id, 493 const std::string& resource_id,
518 const std::string& md5, 494 const std::string& md5,
519 GDataCache::CacheSubDirectoryType sub_dir_type, 495 GDataCache::CacheSubDirectoryType sub_dir_type,
520 GDataCache::CachedFileOrigin file_orign) const OVERRIDE; 496 GDataCache::CachedFileOrigin file_orign) const OVERRIDE;
521 virtual void GetAvailableSpace( 497 virtual void GetAvailableSpace(
522 const GetAvailableSpaceCallback& callback) OVERRIDE; 498 const GetAvailableSpaceCallback& callback) OVERRIDE;
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 // Initiates transfer of |local_file_path| to |remote_dest_file_path|. 661 // Initiates transfer of |local_file_path| to |remote_dest_file_path|.
686 // |local_file_path| must be a regular file (i.e. not a hosted document) from 662 // |local_file_path| must be a regular file (i.e. not a hosted document) from
687 // the local file system, |remote_dest_file_path| is the virtual destination 663 // the local file system, |remote_dest_file_path| is the virtual destination
688 // path within gdata file system. 664 // path within gdata file system.
689 // 665 //
690 // Must be called from *UI* thread. |callback| is run on the calling thread. 666 // Must be called from *UI* thread. |callback| is run on the calling thread.
691 void TransferRegularFile(const FilePath& local_file_path, 667 void TransferRegularFile(const FilePath& local_file_path,
692 const FilePath& remote_dest_file_path, 668 const FilePath& remote_dest_file_path,
693 const FileOperationCallback& callback); 669 const FileOperationCallback& callback);
694 670
671 // Invoked upon completion of GetFileInfoByPathAsync initiated by
672 // GetFileByPath. It then continues to invoke GetResolvedFileByPath.
673 void OnGetFileInfoCompleteForGetFileByPath(
674 const FilePath& file_path,
675 const GetFileCallback& get_file_callback,
676 const GetDownloadDataCallback& get_download_data_callback,
677 base::PlatformFileError error,
678 scoped_ptr<GDataFileProto> file_info);
695 // Invoked upon completion of GetFileInfoByPathAsync initiated by OpenFile. 679 // Invoked upon completion of GetFileInfoByPathAsync initiated by OpenFile.
696 // It then continues to invoke GetFileByPath and processed to 680 // It then continues to invoke GetResolvedFileByPath and proceeds to
697 // OnGetFileCompleteForOpenFile. 681 // OnGetFileCompleteForOpenFile.
698 void OnGetFileInfoCompleteForOpenFile(const FilePath& file_path, 682 void OnGetFileInfoCompleteForOpenFile(const FilePath& file_path,
699 const OpenFileCallback& callback, 683 const OpenFileCallback& callback,
700 base::PlatformFileError error, 684 base::PlatformFileError error,
701 scoped_ptr<GDataFileProto> file_info); 685 scoped_ptr<GDataFileProto> file_info);
702 // Invoked upon completion of GetFileInfoByPathAsync initiated by CloseFile. 686 // Invoked upon completion of GetFileInfoByPathAsync initiated by CloseFile.
703 // It then continues to invoke GetFileByPath and processed to 687 // It then continues to invoke CommitDirtyInCache and proceeds to
704 // OnGetFileCompleteForCloseFile. 688 // OnCommitDirtyInCacheCompleteForCloseFile.
705 void OnGetFileInfoCompleteForCloseFile(const FilePath& file_path, 689 void OnGetFileInfoCompleteForCloseFile(const FilePath& file_path,
706 const CloseFileCallback& callback, 690 const CloseFileCallback& callback,
707 base::PlatformFileError error, 691 base::PlatformFileError error,
708 scoped_ptr<GDataFileProto> file_info); 692 scoped_ptr<GDataFileProto> file_info);
709 693
710 // Invoked upon completion of GetFileByPath initiated by Copy. If 694 // Invoked upon completion of GetFileByPath initiated by Copy. If
711 // GetFileByPath reports no error, calls TransferRegularFile to transfer 695 // GetFileByPath reports no error, calls TransferRegularFile to transfer
712 // |local_file_path| to |remote_dest_file_path|. 696 // |local_file_path| to |remote_dest_file_path|.
713 // 697 //
714 // Can be called from UI/IO thread. |callback| is run on the calling thread. 698 // Can be called from UI/IO thread. |callback| is run on the calling thread.
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
1412 // Called when an entry is found for ReadDirectoryByPathAsync(). 1396 // Called when an entry is found for ReadDirectoryByPathAsync().
1413 void OnReadDirectory(const ReadDirectoryCallback& callback, 1397 void OnReadDirectory(const ReadDirectoryCallback& callback,
1414 base::PlatformFileError error, 1398 base::PlatformFileError error,
1415 GDataEntry* entry); 1399 GDataEntry* entry);
1416 1400
1417 // Finds file info by using virtual |file_path|. This call will also 1401 // Finds file info by using virtual |file_path|. This call will also
1418 // retrieve and refresh file system content from server and disk cache. 1402 // retrieve and refresh file system content from server and disk cache.
1419 void FindEntryByPathAsyncOnUIThread(const FilePath& search_file_path, 1403 void FindEntryByPathAsyncOnUIThread(const FilePath& search_file_path,
1420 const FindEntryCallback& callback); 1404 const FindEntryCallback& callback);
1421 1405
1406 // Gets |file_path| from the file system after the file info is already
1407 // resolved with GetFileInfoByPathAsync(). This function is called by
1408 // OnGetFileInfoCompleteForGetFileByPath and OnGetFileInfoCompleteForOpenFile.
1409 void GetResolvedFileByPath(
1410 const FilePath& file_path,
1411 const GetFileCallback& get_file_callback,
1412 const GetDownloadDataCallback& get_download_data_callback,
1413 base::PlatformFileError error,
1414 const GDataFileProto* file_proto);
1415
1422 // The following functions are used to forward calls to asynchronous public 1416 // The following functions are used to forward calls to asynchronous public
1423 // member functions to UI thread. 1417 // member functions to UI thread.
1424 void SearchAsyncOnUIThread(const std::string& search_query, 1418 void SearchAsyncOnUIThread(const std::string& search_query,
1425 const ReadDirectoryCallback& callback); 1419 const ReadDirectoryCallback& callback);
1426 void OpenFileOnUIThread(const FilePath& file_path, 1420 void OpenFileOnUIThread(const FilePath& file_path,
1427 const OpenFileCallback& callback); 1421 const OpenFileCallback& callback);
1428 void CloseFileOnUIThread(const FilePath& file_path, 1422 void CloseFileOnUIThread(const FilePath& file_path,
1429 const CloseFileCallback& callback); 1423 const CloseFileCallback& callback);
1430 void CopyOnUIThread(const FilePath& src_file_path, 1424 void CopyOnUIThread(const FilePath& src_file_path,
1431 const FilePath& dest_file_path, 1425 const FilePath& dest_file_path,
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1533 }; 1527 };
1534 1528
1535 // Sets the free disk space getter for testing. 1529 // Sets the free disk space getter for testing.
1536 // The existing getter is deleted. 1530 // The existing getter is deleted.
1537 void SetFreeDiskSpaceGetterForTesting( 1531 void SetFreeDiskSpaceGetterForTesting(
1538 FreeDiskSpaceGetterInterface* getter); 1532 FreeDiskSpaceGetterInterface* getter);
1539 1533
1540 } // namespace gdata 1534 } // namespace gdata
1541 1535
1542 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ 1536 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/extensions/file_handler_util.cc ('k') | chrome/browser/chromeos/gdata/gdata_file_system.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698