| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_DRIVE_FAKE_FILE_SYSTEM_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_FAKE_FILE_SYSTEM_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FAKE_FILE_SYSTEM_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FAKE_FILE_SYSTEM_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 // This class implements a fake FileSystem which acts like a real Drive | 33 // This class implements a fake FileSystem which acts like a real Drive |
| 34 // file system with FakeDriveService, for testing purpose. | 34 // file system with FakeDriveService, for testing purpose. |
| 35 // Note that this class doesn't support "caching" at the moment, so the number | 35 // Note that this class doesn't support "caching" at the moment, so the number |
| 36 // of interactions to the FakeDriveService may be bigger than the real | 36 // of interactions to the FakeDriveService may be bigger than the real |
| 37 // implementation. | 37 // implementation. |
| 38 // Currently most methods are empty (not implemented). | 38 // Currently most methods are empty (not implemented). |
| 39 class FakeFileSystem : public FileSystemInterface { | 39 class FakeFileSystem : public FileSystemInterface { |
| 40 public: | 40 public: |
| 41 explicit FakeFileSystem(DriveServiceInterface* drive_service); | 41 explicit FakeFileSystem(DriveServiceInterface* drive_service); |
| 42 virtual ~FakeFileSystem(); | 42 ~FakeFileSystem() override; |
| 43 | 43 |
| 44 // FileSystemInterface Overrides. | 44 // FileSystemInterface Overrides. |
| 45 virtual void AddObserver(FileSystemObserver* observer) override; | 45 void AddObserver(FileSystemObserver* observer) override; |
| 46 virtual void RemoveObserver(FileSystemObserver* observer) override; | 46 void RemoveObserver(FileSystemObserver* observer) override; |
| 47 virtual void CheckForUpdates() override; | 47 void CheckForUpdates() override; |
| 48 virtual void TransferFileFromLocalToRemote( | 48 void TransferFileFromLocalToRemote( |
| 49 const base::FilePath& local_src_file_path, | 49 const base::FilePath& local_src_file_path, |
| 50 const base::FilePath& remote_dest_file_path, | 50 const base::FilePath& remote_dest_file_path, |
| 51 const FileOperationCallback& callback) override; | 51 const FileOperationCallback& callback) override; |
| 52 virtual void OpenFile(const base::FilePath& file_path, | 52 void OpenFile(const base::FilePath& file_path, |
| 53 OpenMode open_mode, | 53 OpenMode open_mode, |
| 54 const std::string& mime_type, | 54 const std::string& mime_type, |
| 55 const OpenFileCallback& callback) override; | 55 const OpenFileCallback& callback) override; |
| 56 virtual void Copy(const base::FilePath& src_file_path, | 56 void Copy(const base::FilePath& src_file_path, |
| 57 const base::FilePath& dest_file_path, | 57 const base::FilePath& dest_file_path, |
| 58 bool preserve_last_modified, | 58 bool preserve_last_modified, |
| 59 const FileOperationCallback& callback) override; |
| 60 void Move(const base::FilePath& src_file_path, |
| 61 const base::FilePath& dest_file_path, |
| 62 const FileOperationCallback& callback) override; |
| 63 void Remove(const base::FilePath& file_path, |
| 64 bool is_recursive, |
| 65 const FileOperationCallback& callback) override; |
| 66 void CreateDirectory(const base::FilePath& directory_path, |
| 67 bool is_exclusive, |
| 68 bool is_recursive, |
| 69 const FileOperationCallback& callback) override; |
| 70 void CreateFile(const base::FilePath& file_path, |
| 71 bool is_exclusive, |
| 72 const std::string& mime_type, |
| 73 const FileOperationCallback& callback) override; |
| 74 void TouchFile(const base::FilePath& file_path, |
| 75 const base::Time& last_access_time, |
| 76 const base::Time& last_modified_time, |
| 77 const FileOperationCallback& callback) override; |
| 78 void TruncateFile(const base::FilePath& file_path, |
| 79 int64 length, |
| 59 const FileOperationCallback& callback) override; | 80 const FileOperationCallback& callback) override; |
| 60 virtual void Move(const base::FilePath& src_file_path, | 81 void Pin(const base::FilePath& file_path, |
| 61 const base::FilePath& dest_file_path, | 82 const FileOperationCallback& callback) override; |
| 62 const FileOperationCallback& callback) override; | 83 void Unpin(const base::FilePath& file_path, |
| 63 virtual void Remove(const base::FilePath& file_path, | 84 const FileOperationCallback& callback) override; |
| 64 bool is_recursive, | 85 void GetFile(const base::FilePath& file_path, |
| 65 const FileOperationCallback& callback) override; | 86 const GetFileCallback& callback) override; |
| 66 virtual void CreateDirectory(const base::FilePath& directory_path, | 87 void GetFileForSaving(const base::FilePath& file_path, |
| 67 bool is_exclusive, | 88 const GetFileCallback& callback) override; |
| 68 bool is_recursive, | 89 base::Closure GetFileContent( |
| 69 const FileOperationCallback& callback) override; | |
| 70 virtual void CreateFile(const base::FilePath& file_path, | |
| 71 bool is_exclusive, | |
| 72 const std::string& mime_type, | |
| 73 const FileOperationCallback& callback) override; | |
| 74 virtual void TouchFile(const base::FilePath& file_path, | |
| 75 const base::Time& last_access_time, | |
| 76 const base::Time& last_modified_time, | |
| 77 const FileOperationCallback& callback) override; | |
| 78 virtual void TruncateFile(const base::FilePath& file_path, | |
| 79 int64 length, | |
| 80 const FileOperationCallback& callback) override; | |
| 81 virtual void Pin(const base::FilePath& file_path, | |
| 82 const FileOperationCallback& callback) override; | |
| 83 virtual void Unpin(const base::FilePath& file_path, | |
| 84 const FileOperationCallback& callback) override; | |
| 85 virtual void GetFile(const base::FilePath& file_path, | |
| 86 const GetFileCallback& callback) override; | |
| 87 virtual void GetFileForSaving(const base::FilePath& file_path, | |
| 88 const GetFileCallback& callback) override; | |
| 89 virtual base::Closure GetFileContent( | |
| 90 const base::FilePath& file_path, | 90 const base::FilePath& file_path, |
| 91 const GetFileContentInitializedCallback& initialized_callback, | 91 const GetFileContentInitializedCallback& initialized_callback, |
| 92 const google_apis::GetContentCallback& get_content_callback, | 92 const google_apis::GetContentCallback& get_content_callback, |
| 93 const FileOperationCallback& completion_callback) override; | 93 const FileOperationCallback& completion_callback) override; |
| 94 virtual void GetResourceEntry( | 94 void GetResourceEntry(const base::FilePath& file_path, |
| 95 const base::FilePath& file_path, | 95 const GetResourceEntryCallback& callback) override; |
| 96 const GetResourceEntryCallback& callback) override; | 96 void ReadDirectory(const base::FilePath& file_path, |
| 97 virtual void ReadDirectory( | 97 const ReadDirectoryEntriesCallback& entries_callback, |
| 98 const base::FilePath& file_path, | 98 const FileOperationCallback& completion_callback) override; |
| 99 const ReadDirectoryEntriesCallback& entries_callback, | 99 void Search(const std::string& search_query, |
| 100 const FileOperationCallback& completion_callback) override; | 100 const GURL& next_link, |
| 101 virtual void Search(const std::string& search_query, | 101 const SearchCallback& callback) override; |
| 102 const GURL& next_link, | 102 void SearchMetadata(const std::string& query, |
| 103 const SearchCallback& callback) override; | 103 int options, |
| 104 virtual void SearchMetadata(const std::string& query, | 104 int at_most_num_matches, |
| 105 int options, | 105 const SearchMetadataCallback& callback) override; |
| 106 int at_most_num_matches, | 106 void SearchByHashes(const std::vector<std::string>& hashes, |
| 107 const SearchMetadataCallback& callback) override; | 107 const SearchByHashesCallback& callback) override; |
| 108 virtual void SearchByHashes(const std::vector<std::string>& hashes, | 108 void GetAvailableSpace(const GetAvailableSpaceCallback& callback) override; |
| 109 const SearchByHashesCallback& callback) override; | 109 void GetShareUrl(const base::FilePath& file_path, |
| 110 virtual void GetAvailableSpace( | 110 const GURL& embed_origin, |
| 111 const GetAvailableSpaceCallback& callback) override; | 111 const GetShareUrlCallback& callback) override; |
| 112 virtual void GetShareUrl( | 112 void GetMetadata(const GetFilesystemMetadataCallback& callback) override; |
| 113 const base::FilePath& file_path, | 113 void MarkCacheFileAsMounted(const base::FilePath& drive_file_path, |
| 114 const GURL& embed_origin, | 114 const MarkMountedCallback& callback) override; |
| 115 const GetShareUrlCallback& callback) override; | 115 void MarkCacheFileAsUnmounted(const base::FilePath& cache_file_path, |
| 116 virtual void GetMetadata( | 116 const FileOperationCallback& callback) override; |
| 117 const GetFilesystemMetadataCallback& callback) override; | 117 void AddPermission(const base::FilePath& drive_file_path, |
| 118 virtual void MarkCacheFileAsMounted( | 118 const std::string& email, |
| 119 const base::FilePath& drive_file_path, | 119 google_apis::drive::PermissionRole role, |
| 120 const MarkMountedCallback& callback) override; | 120 const FileOperationCallback& callback) override; |
| 121 virtual void MarkCacheFileAsUnmounted( | 121 void Reset(const FileOperationCallback& callback) override; |
| 122 const base::FilePath& cache_file_path, | 122 void GetPathFromResourceId(const std::string& resource_id, |
| 123 const FileOperationCallback& callback) override; | 123 const GetFilePathCallback& callback) override; |
| 124 virtual void AddPermission(const base::FilePath& drive_file_path, | |
| 125 const std::string& email, | |
| 126 google_apis::drive::PermissionRole role, | |
| 127 const FileOperationCallback& callback) override; | |
| 128 virtual void Reset(const FileOperationCallback& callback) override; | |
| 129 virtual void GetPathFromResourceId(const std::string& resource_id, | |
| 130 const GetFilePathCallback& callback) | |
| 131 override; | |
| 132 | 124 |
| 133 private: | 125 private: |
| 134 // Helpers of GetFileContent. | 126 // Helpers of GetFileContent. |
| 135 // How the method works: | 127 // How the method works: |
| 136 // 1) Gets ResourceEntry of the path. | 128 // 1) Gets ResourceEntry of the path. |
| 137 // 2) Look at if there is a cache file or not. If found return it. | 129 // 2) Look at if there is a cache file or not. If found return it. |
| 138 // 3) Otherwise start DownloadFile. | 130 // 3) Otherwise start DownloadFile. |
| 139 // 4) Runs the |completion_callback| upon the download completion. | 131 // 4) Runs the |completion_callback| upon the download completion. |
| 140 void GetFileContentAfterGetResourceEntry( | 132 void GetFileContentAfterGetResourceEntry( |
| 141 const GetFileContentInitializedCallback& initialized_callback, | 133 const GetFileContentInitializedCallback& initialized_callback, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 // invalidate the weak pointers before any other members are destroyed. | 179 // invalidate the weak pointers before any other members are destroyed. |
| 188 base::WeakPtrFactory<FakeFileSystem> weak_ptr_factory_; | 180 base::WeakPtrFactory<FakeFileSystem> weak_ptr_factory_; |
| 189 | 181 |
| 190 DISALLOW_COPY_AND_ASSIGN(FakeFileSystem); | 182 DISALLOW_COPY_AND_ASSIGN(FakeFileSystem); |
| 191 }; | 183 }; |
| 192 | 184 |
| 193 } // namespace test_util | 185 } // namespace test_util |
| 194 } // namespace drive | 186 } // namespace drive |
| 195 | 187 |
| 196 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FAKE_FILE_SYSTEM_H_ | 188 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FAKE_FILE_SYSTEM_H_ |
| OLD | NEW |