| 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 24 matching lines...) Expand all Loading... |
| 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 virtual ~FakeFileSystem(); |
| 43 | 43 |
| 44 // FileSystemInterface Overrides. | 44 // FileSystemInterface Overrides. |
| 45 virtual void AddObserver(FileSystemObserver* observer) OVERRIDE; | 45 virtual void AddObserver(FileSystemObserver* observer) override; |
| 46 virtual void RemoveObserver(FileSystemObserver* observer) OVERRIDE; | 46 virtual void RemoveObserver(FileSystemObserver* observer) override; |
| 47 virtual void CheckForUpdates() OVERRIDE; | 47 virtual void CheckForUpdates() override; |
| 48 virtual void TransferFileFromLocalToRemote( | 48 virtual 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 virtual 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 virtual 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; | 59 const FileOperationCallback& callback) override; |
| 60 virtual void Move(const base::FilePath& src_file_path, | 60 virtual void Move(const base::FilePath& src_file_path, |
| 61 const base::FilePath& dest_file_path, | 61 const base::FilePath& dest_file_path, |
| 62 const FileOperationCallback& callback) OVERRIDE; | 62 const FileOperationCallback& callback) override; |
| 63 virtual void Remove(const base::FilePath& file_path, | 63 virtual void Remove(const base::FilePath& file_path, |
| 64 bool is_recursive, | 64 bool is_recursive, |
| 65 const FileOperationCallback& callback) OVERRIDE; | 65 const FileOperationCallback& callback) override; |
| 66 virtual void CreateDirectory(const base::FilePath& directory_path, | 66 virtual void CreateDirectory(const base::FilePath& directory_path, |
| 67 bool is_exclusive, | 67 bool is_exclusive, |
| 68 bool is_recursive, | 68 bool is_recursive, |
| 69 const FileOperationCallback& callback) OVERRIDE; | 69 const FileOperationCallback& callback) override; |
| 70 virtual void CreateFile(const base::FilePath& file_path, | 70 virtual void CreateFile(const base::FilePath& file_path, |
| 71 bool is_exclusive, | 71 bool is_exclusive, |
| 72 const std::string& mime_type, | 72 const std::string& mime_type, |
| 73 const FileOperationCallback& callback) OVERRIDE; | 73 const FileOperationCallback& callback) override; |
| 74 virtual void TouchFile(const base::FilePath& file_path, | 74 virtual void TouchFile(const base::FilePath& file_path, |
| 75 const base::Time& last_access_time, | 75 const base::Time& last_access_time, |
| 76 const base::Time& last_modified_time, | 76 const base::Time& last_modified_time, |
| 77 const FileOperationCallback& callback) OVERRIDE; | 77 const FileOperationCallback& callback) override; |
| 78 virtual void TruncateFile(const base::FilePath& file_path, | 78 virtual void TruncateFile(const base::FilePath& file_path, |
| 79 int64 length, | 79 int64 length, |
| 80 const FileOperationCallback& callback) OVERRIDE; | 80 const FileOperationCallback& callback) override; |
| 81 virtual void Pin(const base::FilePath& file_path, | 81 virtual void Pin(const base::FilePath& file_path, |
| 82 const FileOperationCallback& callback) OVERRIDE; | 82 const FileOperationCallback& callback) override; |
| 83 virtual void Unpin(const base::FilePath& file_path, | 83 virtual void Unpin(const base::FilePath& file_path, |
| 84 const FileOperationCallback& callback) OVERRIDE; | 84 const FileOperationCallback& callback) override; |
| 85 virtual void GetFile(const base::FilePath& file_path, | 85 virtual void GetFile(const base::FilePath& file_path, |
| 86 const GetFileCallback& callback) OVERRIDE; | 86 const GetFileCallback& callback) override; |
| 87 virtual void GetFileForSaving(const base::FilePath& file_path, | 87 virtual void GetFileForSaving(const base::FilePath& file_path, |
| 88 const GetFileCallback& callback) OVERRIDE; | 88 const GetFileCallback& callback) override; |
| 89 virtual base::Closure GetFileContent( | 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 virtual void GetResourceEntry( |
| 95 const base::FilePath& file_path, | 95 const base::FilePath& file_path, |
| 96 const GetResourceEntryCallback& callback) OVERRIDE; | 96 const GetResourceEntryCallback& callback) override; |
| 97 virtual void ReadDirectory( | 97 virtual void ReadDirectory( |
| 98 const base::FilePath& file_path, | 98 const base::FilePath& file_path, |
| 99 const ReadDirectoryEntriesCallback& entries_callback, | 99 const ReadDirectoryEntriesCallback& entries_callback, |
| 100 const FileOperationCallback& completion_callback) OVERRIDE; | 100 const FileOperationCallback& completion_callback) override; |
| 101 virtual void Search(const std::string& search_query, | 101 virtual void Search(const std::string& search_query, |
| 102 const GURL& next_link, | 102 const GURL& next_link, |
| 103 const SearchCallback& callback) OVERRIDE; | 103 const SearchCallback& callback) override; |
| 104 virtual void SearchMetadata(const std::string& query, | 104 virtual void SearchMetadata(const std::string& query, |
| 105 int options, | 105 int options, |
| 106 int at_most_num_matches, | 106 int at_most_num_matches, |
| 107 const SearchMetadataCallback& callback) OVERRIDE; | 107 const SearchMetadataCallback& callback) override; |
| 108 virtual void GetAvailableSpace( | 108 virtual void GetAvailableSpace( |
| 109 const GetAvailableSpaceCallback& callback) OVERRIDE; | 109 const GetAvailableSpaceCallback& callback) override; |
| 110 virtual void GetShareUrl( | 110 virtual void GetShareUrl( |
| 111 const base::FilePath& file_path, | 111 const base::FilePath& file_path, |
| 112 const GURL& embed_origin, | 112 const GURL& embed_origin, |
| 113 const GetShareUrlCallback& callback) OVERRIDE; | 113 const GetShareUrlCallback& callback) override; |
| 114 virtual void GetMetadata( | 114 virtual void GetMetadata( |
| 115 const GetFilesystemMetadataCallback& callback) OVERRIDE; | 115 const GetFilesystemMetadataCallback& callback) override; |
| 116 virtual void MarkCacheFileAsMounted( | 116 virtual void MarkCacheFileAsMounted( |
| 117 const base::FilePath& drive_file_path, | 117 const base::FilePath& drive_file_path, |
| 118 const MarkMountedCallback& callback) OVERRIDE; | 118 const MarkMountedCallback& callback) override; |
| 119 virtual void MarkCacheFileAsUnmounted( | 119 virtual void MarkCacheFileAsUnmounted( |
| 120 const base::FilePath& cache_file_path, | 120 const base::FilePath& cache_file_path, |
| 121 const FileOperationCallback& callback) OVERRIDE; | 121 const FileOperationCallback& callback) override; |
| 122 virtual void AddPermission(const base::FilePath& drive_file_path, | 122 virtual void AddPermission(const base::FilePath& drive_file_path, |
| 123 const std::string& email, | 123 const std::string& email, |
| 124 google_apis::drive::PermissionRole role, | 124 google_apis::drive::PermissionRole role, |
| 125 const FileOperationCallback& callback) OVERRIDE; | 125 const FileOperationCallback& callback) override; |
| 126 virtual void Reset(const FileOperationCallback& callback) OVERRIDE; | 126 virtual void Reset(const FileOperationCallback& callback) override; |
| 127 virtual void GetPathFromResourceId(const std::string& resource_id, | 127 virtual void GetPathFromResourceId(const std::string& resource_id, |
| 128 const GetFilePathCallback& callback) | 128 const GetFilePathCallback& callback) |
| 129 OVERRIDE; | 129 override; |
| 130 | 130 |
| 131 private: | 131 private: |
| 132 // Helpers of GetFileContent. | 132 // Helpers of GetFileContent. |
| 133 // How the method works: | 133 // How the method works: |
| 134 // 1) Gets ResourceEntry of the path. | 134 // 1) Gets ResourceEntry of the path. |
| 135 // 2) Look at if there is a cache file or not. If found return it. | 135 // 2) Look at if there is a cache file or not. If found return it. |
| 136 // 3) Otherwise start DownloadFile. | 136 // 3) Otherwise start DownloadFile. |
| 137 // 4) Runs the |completion_callback| upon the download completion. | 137 // 4) Runs the |completion_callback| upon the download completion. |
| 138 void GetFileContentAfterGetResourceEntry( | 138 void GetFileContentAfterGetResourceEntry( |
| 139 const GetFileContentInitializedCallback& initialized_callback, | 139 const GetFileContentInitializedCallback& initialized_callback, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 // invalidate the weak pointers before any other members are destroyed. | 185 // invalidate the weak pointers before any other members are destroyed. |
| 186 base::WeakPtrFactory<FakeFileSystem> weak_ptr_factory_; | 186 base::WeakPtrFactory<FakeFileSystem> weak_ptr_factory_; |
| 187 | 187 |
| 188 DISALLOW_COPY_AND_ASSIGN(FakeFileSystem); | 188 DISALLOW_COPY_AND_ASSIGN(FakeFileSystem); |
| 189 }; | 189 }; |
| 190 | 190 |
| 191 } // namespace test_util | 191 } // namespace test_util |
| 192 } // namespace drive | 192 } // namespace drive |
| 193 | 193 |
| 194 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FAKE_FILE_SYSTEM_H_ | 194 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FAKE_FILE_SYSTEM_H_ |
| OLD | NEW |