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" |
11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
12 #include "base/files/scoped_temp_dir.h" | 12 #include "base/files/scoped_temp_dir.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "chrome/browser/chromeos/drive/file_errors.h" | 14 #include "chrome/browser/chromeos/drive/file_errors.h" |
15 #include "chrome/browser/chromeos/drive/file_system_interface.h" | 15 #include "chrome/browser/chromeos/drive/file_system_interface.h" |
16 #include "google_apis/drive/gdata_errorcode.h" | 16 #include "google_apis/drive/drive_api_error_codes.h" |
17 | 17 |
18 namespace google_apis { | 18 namespace google_apis { |
19 | 19 |
20 class AboutResource; | 20 class AboutResource; |
21 class FileResource; | 21 class FileResource; |
22 | 22 |
23 } // namespace google_apis | 23 } // namespace google_apis |
24 | 24 |
25 namespace drive { | 25 namespace drive { |
26 | 26 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 void GetFileContentAfterGetResourceEntry( | 132 void GetFileContentAfterGetResourceEntry( |
133 const GetFileContentInitializedCallback& initialized_callback, | 133 const GetFileContentInitializedCallback& initialized_callback, |
134 const google_apis::GetContentCallback& get_content_callback, | 134 const google_apis::GetContentCallback& get_content_callback, |
135 const FileOperationCallback& completion_callback, | 135 const FileOperationCallback& completion_callback, |
136 FileError error, | 136 FileError error, |
137 scoped_ptr<ResourceEntry> entry); | 137 scoped_ptr<ResourceEntry> entry); |
138 void GetFileContentAfterGetFileResource( | 138 void GetFileContentAfterGetFileResource( |
139 const GetFileContentInitializedCallback& initialized_callback, | 139 const GetFileContentInitializedCallback& initialized_callback, |
140 const google_apis::GetContentCallback& get_content_callback, | 140 const google_apis::GetContentCallback& get_content_callback, |
141 const FileOperationCallback& completion_callback, | 141 const FileOperationCallback& completion_callback, |
142 google_apis::GDataErrorCode gdata_error, | 142 google_apis::DriveApiErrorCode gdata_error, |
143 scoped_ptr<google_apis::FileResource> gdata_entry); | 143 scoped_ptr<google_apis::FileResource> gdata_entry); |
144 void GetFileContentAfterDownloadFile( | 144 void GetFileContentAfterDownloadFile( |
145 const FileOperationCallback& completion_callback, | 145 const FileOperationCallback& completion_callback, |
146 google_apis::GDataErrorCode gdata_error, | 146 google_apis::DriveApiErrorCode gdata_error, |
147 const base::FilePath& temp_file); | 147 const base::FilePath& temp_file); |
148 | 148 |
149 // Helpers of GetResourceEntry. | 149 // Helpers of GetResourceEntry. |
150 // How the method works: | 150 // How the method works: |
151 // 1) If the path is root, gets AboutResrouce from the drive service | 151 // 1) If the path is root, gets AboutResrouce from the drive service |
152 // and create ResourceEntry. | 152 // and create ResourceEntry. |
153 // 2-1) Otherwise, gets the parent's ResourceEntry by recursive call. | 153 // 2-1) Otherwise, gets the parent's ResourceEntry by recursive call. |
154 // 2-2) Then, gets the resource list by restricting the parent with its id. | 154 // 2-2) Then, gets the resource list by restricting the parent with its id. |
155 // 2-3) Search the results based on title, and return the ResourceEntry. | 155 // 2-3) Search the results based on title, and return the ResourceEntry. |
156 // Note that adding suffix (e.g. " (2)") for files sharing a same name is | 156 // Note that adding suffix (e.g. " (2)") for files sharing a same name is |
157 // not supported in FakeFileSystem. Thus, even if the server has | 157 // not supported in FakeFileSystem. Thus, even if the server has |
158 // files sharing the same name under a directory, the second (or later) | 158 // files sharing the same name under a directory, the second (or later) |
159 // file cannot be taken with the suffixed name. | 159 // file cannot be taken with the suffixed name. |
160 void GetResourceEntryAfterGetAboutResource( | 160 void GetResourceEntryAfterGetAboutResource( |
161 const GetResourceEntryCallback& callback, | 161 const GetResourceEntryCallback& callback, |
162 google_apis::GDataErrorCode gdata_error, | 162 google_apis::DriveApiErrorCode gdata_error, |
163 scoped_ptr<google_apis::AboutResource> about_resource); | 163 scoped_ptr<google_apis::AboutResource> about_resource); |
164 void GetResourceEntryAfterGetParentEntryInfo( | 164 void GetResourceEntryAfterGetParentEntryInfo( |
165 const base::FilePath& base_name, | 165 const base::FilePath& base_name, |
166 const GetResourceEntryCallback& callback, | 166 const GetResourceEntryCallback& callback, |
167 FileError error, | 167 FileError error, |
168 scoped_ptr<ResourceEntry> parent_entry); | 168 scoped_ptr<ResourceEntry> parent_entry); |
169 void GetResourceEntryAfterGetFileList( | 169 void GetResourceEntryAfterGetFileList( |
170 const base::FilePath& base_name, | 170 const base::FilePath& base_name, |
171 const GetResourceEntryCallback& callback, | 171 const GetResourceEntryCallback& callback, |
172 google_apis::GDataErrorCode gdata_error, | 172 google_apis::DriveApiErrorCode gdata_error, |
173 scoped_ptr<google_apis::FileList> file_list); | 173 scoped_ptr<google_apis::FileList> file_list); |
174 | 174 |
175 DriveServiceInterface* drive_service_; // Not owned. | 175 DriveServiceInterface* drive_service_; // Not owned. |
176 base::ScopedTempDir cache_dir_; | 176 base::ScopedTempDir cache_dir_; |
177 | 177 |
178 // Note: This should remain the last member so it'll be destroyed and | 178 // Note: This should remain the last member so it'll be destroyed and |
179 // invalidate the weak pointers before any other members are destroyed. | 179 // invalidate the weak pointers before any other members are destroyed. |
180 base::WeakPtrFactory<FakeFileSystem> weak_ptr_factory_; | 180 base::WeakPtrFactory<FakeFileSystem> weak_ptr_factory_; |
181 | 181 |
182 DISALLOW_COPY_AND_ASSIGN(FakeFileSystem); | 182 DISALLOW_COPY_AND_ASSIGN(FakeFileSystem); |
183 }; | 183 }; |
184 | 184 |
185 } // namespace test_util | 185 } // namespace test_util |
186 } // namespace drive | 186 } // namespace drive |
187 | 187 |
188 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FAKE_FILE_SYSTEM_H_ | 188 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FAKE_FILE_SYSTEM_H_ |
OLD | NEW |