| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 // for testing purpose. Returns true for success. | 46 // for testing purpose. Returns true for success. |
| 47 bool InitializeForTesting(); | 47 bool InitializeForTesting(); |
| 48 | 48 |
| 49 // FileSystemInterface Overrides. | 49 // FileSystemInterface Overrides. |
| 50 virtual void Initialize() OVERRIDE; | 50 virtual void Initialize() OVERRIDE; |
| 51 virtual void AddObserver(FileSystemObserver* observer) OVERRIDE; | 51 virtual void AddObserver(FileSystemObserver* observer) OVERRIDE; |
| 52 virtual void RemoveObserver(FileSystemObserver* observer) OVERRIDE; | 52 virtual void RemoveObserver(FileSystemObserver* observer) OVERRIDE; |
| 53 virtual void CheckForUpdates() OVERRIDE; | 53 virtual void CheckForUpdates() OVERRIDE; |
| 54 virtual void GetResourceEntryById( | 54 virtual void GetResourceEntryById( |
| 55 const std::string& resource_id, | 55 const std::string& resource_id, |
| 56 const GetResourceEntryWithFilePathCallback& callback) OVERRIDE; | 56 const GetResourceEntryCallback& callback) OVERRIDE; |
| 57 virtual void TransferFileFromRemoteToLocal( | 57 virtual void TransferFileFromRemoteToLocal( |
| 58 const base::FilePath& remote_src_file_path, | 58 const base::FilePath& remote_src_file_path, |
| 59 const base::FilePath& local_dest_file_path, | 59 const base::FilePath& local_dest_file_path, |
| 60 const FileOperationCallback& callback) OVERRIDE; | 60 const FileOperationCallback& callback) OVERRIDE; |
| 61 virtual void TransferFileFromLocalToRemote( | 61 virtual void TransferFileFromLocalToRemote( |
| 62 const base::FilePath& local_src_file_path, | 62 const base::FilePath& local_src_file_path, |
| 63 const base::FilePath& remote_dest_file_path, | 63 const base::FilePath& remote_dest_file_path, |
| 64 const FileOperationCallback& callback) OVERRIDE; | 64 const FileOperationCallback& callback) OVERRIDE; |
| 65 virtual void OpenFile(const base::FilePath& file_path, | 65 virtual void OpenFile(const base::FilePath& file_path, |
| 66 const OpenFileCallback& callback) OVERRIDE; | 66 const OpenFileCallback& callback) OVERRIDE; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 virtual void MarkCacheFileAsUnmounted( | 132 virtual void MarkCacheFileAsUnmounted( |
| 133 const base::FilePath& cache_file_path, | 133 const base::FilePath& cache_file_path, |
| 134 const FileOperationCallback& callback) OVERRIDE; | 134 const FileOperationCallback& callback) OVERRIDE; |
| 135 virtual void GetCacheEntryByResourceId( | 135 virtual void GetCacheEntryByResourceId( |
| 136 const std::string& resource_id, | 136 const std::string& resource_id, |
| 137 const std::string& md5, | 137 const std::string& md5, |
| 138 const GetCacheEntryCallback& callback) OVERRIDE; | 138 const GetCacheEntryCallback& callback) OVERRIDE; |
| 139 virtual void Reload() OVERRIDE; | 139 virtual void Reload() OVERRIDE; |
| 140 | 140 |
| 141 private: | 141 private: |
| 142 // Callback to return the result of GetFilePath. | 142 // Helper of GetResourceEntryById. |
| 143 typedef base::Callback<void(const base::FilePath& file_path)> | 143 void GetResourceEntryByIdAfterGetResourceEntry( |
| 144 GetFilePathCallback; | 144 const GetResourceEntryCallback& callback, |
| 145 | |
| 146 // Returns the path for the |resource_id| via |callback|. | |
| 147 // How the method works: | |
| 148 // 1) Gets AboutResource from the drive service to obtain root resource id. | |
| 149 // 2) Gets ResourceEntry from the drive service to get the base name, | |
| 150 // prepends it to the |file_path|. Unless it is root, also tries for | |
| 151 // the parent recursively. | |
| 152 void GetFilePath(const std::string& resource_id, | |
| 153 const GetFilePathCallback& callback); | |
| 154 void GetFilePathAfterGetAboutResource( | |
| 155 const std::string& resource_id, | |
| 156 const GetFilePathCallback& callback, | |
| 157 google_apis::GDataErrorCode error, | |
| 158 scoped_ptr<google_apis::AboutResource> about_resource); | |
| 159 void GetFilePathInternal( | |
| 160 const std::string& root_resource_id, | |
| 161 const std::string& resource_id, | |
| 162 const base::FilePath& file_path, | |
| 163 const GetFilePathCallback& callback); | |
| 164 void GetFilePathAfterGetResourceEntry( | |
| 165 const std::string& root_resource_id, | |
| 166 const base::FilePath& remaining_file_path, | |
| 167 const GetFilePathCallback& callback, | |
| 168 google_apis::GDataErrorCode error_in, | 145 google_apis::GDataErrorCode error_in, |
| 169 scoped_ptr<google_apis::ResourceEntry> resource_entry); | 146 scoped_ptr<google_apis::ResourceEntry> resource_entry); |
| 170 | 147 |
| 171 // Helpers of GetResourceEntryById. | |
| 172 // How the method works: | |
| 173 // 1) Gets ResourceEntry from the drive service. | |
| 174 // 2) Gets the file path of the resource. | |
| 175 // 3) Runs the |callback|. | |
| 176 void GetResourceEntryByIdAfterGetResourceEntry( | |
| 177 const GetResourceEntryWithFilePathCallback& callback, | |
| 178 google_apis::GDataErrorCode error_in, | |
| 179 scoped_ptr<google_apis::ResourceEntry> resource_entry); | |
| 180 void GetResourceEntryByIdAfterGetFilePath( | |
| 181 const GetResourceEntryWithFilePathCallback& callback, | |
| 182 FileError error, | |
| 183 scoped_ptr<ResourceEntry> entry, | |
| 184 const base::FilePath& parent_file_path); | |
| 185 | |
| 186 // Helpers of GetFileContentByPath. | 148 // Helpers of GetFileContentByPath. |
| 187 // How the method works: | 149 // How the method works: |
| 188 // 1) Gets ResourceEntry of the path. | 150 // 1) Gets ResourceEntry of the path. |
| 189 // 2) Look at if there is a cache file or not. If found return it. | 151 // 2) Look at if there is a cache file or not. If found return it. |
| 190 // 3) Otherwise start DownloadFile. | 152 // 3) Otherwise start DownloadFile. |
| 191 // 4) Runs the |completion_callback| upon the download completion. | 153 // 4) Runs the |completion_callback| upon the download completion. |
| 192 void GetFileContentByPathAfterGetResourceEntry( | 154 void GetFileContentByPathAfterGetResourceEntry( |
| 193 const base::FilePath& file_path, | 155 const base::FilePath& file_path, |
| 194 const GetFileContentInitializedCallback& initialized_callback, | 156 const GetFileContentInitializedCallback& initialized_callback, |
| 195 const google_apis::GetContentCallback& get_content_callback, | 157 const google_apis::GetContentCallback& get_content_callback, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 // invalidate the weak pointers before any other members are destroyed. | 203 // invalidate the weak pointers before any other members are destroyed. |
| 242 base::WeakPtrFactory<FakeFileSystem> weak_ptr_factory_; | 204 base::WeakPtrFactory<FakeFileSystem> weak_ptr_factory_; |
| 243 | 205 |
| 244 DISALLOW_COPY_AND_ASSIGN(FakeFileSystem); | 206 DISALLOW_COPY_AND_ASSIGN(FakeFileSystem); |
| 245 }; | 207 }; |
| 246 | 208 |
| 247 } // namespace test_util | 209 } // namespace test_util |
| 248 } // namespace drive | 210 } // namespace drive |
| 249 | 211 |
| 250 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FAKE_FILE_SYSTEM_H_ | 212 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FAKE_FILE_SYSTEM_H_ |
| OLD | NEW |