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

Side by Side Diff: chrome/browser/chromeos/drive/file_system.h

Issue 15681009: Extract GetResolveFile into DownloadOperation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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_DRIVE_FILE_SYSTEM_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_H_
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_H_ 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 162
163 // Used in tests to update the file system from |feed_list|. 163 // Used in tests to update the file system from |feed_list|.
164 // See also the comment at ChangeListLoader::UpdateFromFeed(). 164 // See also the comment at ChangeListLoader::UpdateFromFeed().
165 internal::ChangeListLoader* change_list_loader() { 165 internal::ChangeListLoader* change_list_loader() {
166 return change_list_loader_.get(); 166 return change_list_loader_.get();
167 } 167 }
168 168
169 private: 169 private:
170 friend class DriveFileSystemTest; 170 friend class DriveFileSystemTest;
171 171
172 // Defines set of parameters passed to an intermediate callback
173 // OnGetFileCompleteForOpen, during execution of OpenFile() method.
174 struct GetFileCompleteForOpenParams;
175
176 // Defines set of parameters for GetResolvedFileByPath().
177 struct GetResolvedFileParams;
178
179 // Used to implement Reload(). 172 // Used to implement Reload().
180 void ReloadAfterReset(FileError error); 173 void ReloadAfterReset(FileError error);
181 174
182 // Sets up ChangeListLoader. 175 // Sets up ChangeListLoader.
183 void SetupChangeListLoader(); 176 void SetupChangeListLoader();
184 177
185 // Called on preference change. 178 // Called on preference change.
186 void OnDisableDriveHostedFilesChanged(); 179 void OnDisableDriveHostedFilesChanged();
187 180
188 // Part of Search(). Called after DriveOperations::Search is completed. 181 // Part of Search(). Called after DriveOperations::Search is completed.
(...skipping 14 matching lines...) Expand all
203 // Used to implement Pin(). 196 // Used to implement Pin().
204 void PinAfterGetResourceEntryByPath(const FileOperationCallback& callback, 197 void PinAfterGetResourceEntryByPath(const FileOperationCallback& callback,
205 FileError error, 198 FileError error,
206 scoped_ptr<ResourceEntry> entry); 199 scoped_ptr<ResourceEntry> entry);
207 200
208 // Used to implement Unpin(). 201 // Used to implement Unpin().
209 void UnpinAfterGetResourceEntryByPath(const FileOperationCallback& callback, 202 void UnpinAfterGetResourceEntryByPath(const FileOperationCallback& callback,
210 FileError error, 203 FileError error,
211 scoped_ptr<ResourceEntry> entry); 204 scoped_ptr<ResourceEntry> entry);
212 205
213 // Invoked upon completion of GetResourceEntryByPath initiated by 206 // Part of OpenFile(). Called after the file downloading is completed.
214 // GetFileByPath. It then continues to invoke GetResolvedFileByPath. 207 void OpenFileAfterFileDownloaded(
215 // |callback| must not be null.
216 void OnGetResourceEntryCompleteForGetFileByPath(
217 const base::FilePath& file_path,
218 const GetFileCallback& callback,
219 FileError error,
220 scoped_ptr<ResourceEntry> file_info);
221
222 // Invoked upon completion of GetResourceEntryByPath initiated by OpenFile.
223 // It then continues to invoke GetResolvedFileByPath and proceeds to
224 // OnGetFileCompleteForOpenFile.
225 void OnGetResourceEntryCompleteForOpenFile(
226 const base::FilePath& file_path, 208 const base::FilePath& file_path,
227 const OpenFileCallback& callback, 209 const OpenFileCallback& callback,
228 FileError error, 210 FileError error,
229 scoped_ptr<ResourceEntry> file_info); 211 const base::FilePath& local_file_path,
212 scoped_ptr<ResourceEntry> entry);
213
214 // Part of OpenFile(). Called after the cache file is marked dirty.
215 void OpenFileAfterMarkDirty(
216 const std::string& resource_id,
217 const std::string& md5,
218 const OpenFileCallback& callback,
219 FileError error);
230 220
231 // Invoked at the last step of OpenFile. It removes |file_path| from the 221 // Invoked at the last step of OpenFile. It removes |file_path| from the
232 // current set of opened files if |result| is an error, and then invokes the 222 // current set of opened files if |result| is an error, and then invokes the
233 // |callback| function. 223 // |callback| function.
234 void OnOpenFileFinished(const base::FilePath& file_path, 224 void OnOpenFileFinished(const base::FilePath& file_path,
235 const OpenFileCallback& callback, 225 const OpenFileCallback& callback,
236 FileError result, 226 FileError result,
237 const base::FilePath& cache_file_path); 227 const base::FilePath& cache_file_path);
238 228
239 // Invoked during the process of CloseFile. What is done here is as follows: 229 // Invoked during the process of CloseFile. What is done here is as follows:
240 // 1) Gets resource_id and md5 of the entry at |file_path|. 230 // 1) Gets resource_id and md5 of the entry at |file_path|.
241 // 2) Commits the modification to the cache system. 231 // 2) Commits the modification to the cache system.
242 // 3) Removes the |file_path| from the remembered set of opened files. 232 // 3) Removes the |file_path| from the remembered set of opened files.
243 // 4) Invokes the user-supplied |callback|. 233 // 4) Invokes the user-supplied |callback|.
244 // |callback| must not be null. 234 // |callback| must not be null.
245 void CloseFileAfterGetResourceEntry(const base::FilePath& file_path, 235 void CloseFileAfterGetResourceEntry(const base::FilePath& file_path,
246 const FileOperationCallback& callback, 236 const FileOperationCallback& callback,
247 FileError error, 237 FileError error,
248 scoped_ptr<ResourceEntry> entry); 238 scoped_ptr<ResourceEntry> entry);
249 void CloseFileFinalize(const base::FilePath& file_path, 239 void CloseFileFinalize(const base::FilePath& file_path,
250 const FileOperationCallback& callback, 240 const FileOperationCallback& callback,
251 FileError result); 241 FileError result);
252 242
253 // Invoked upon completion of GetFileByPath initiated by OpenFile. If
254 // GetFileByPath is successful, calls MarkDirtyInCache to mark the cache
255 // file as dirty for the file identified by |file_info.resource_id| and
256 // |file_info.md5|.
257 void OnGetFileCompleteForOpenFile(const GetFileCompleteForOpenParams& params,
258 FileError error,
259 const base::FilePath& file_path,
260 scoped_ptr<ResourceEntry> entry);
261
262 // Invoked upon completion of MarkDirtyInCache initiated by OpenFile.
263 void OnMarkDirtyInCacheCompleteForOpenFile(
264 const GetFileCompleteForOpenParams& params,
265 FileError error);
266
267 // Callback for handling about resource fetch. 243 // Callback for handling about resource fetch.
268 void OnGetAboutResource( 244 void OnGetAboutResource(
269 const GetAvailableSpaceCallback& callback, 245 const GetAvailableSpaceCallback& callback,
270 google_apis::GDataErrorCode status, 246 google_apis::GDataErrorCode status,
271 scoped_ptr<google_apis::AboutResource> about_resource); 247 scoped_ptr<google_apis::AboutResource> about_resource);
272 248
273 // Callback for handling results of ReloadFeedFromServerIfNeeded() initiated 249 // Callback for handling results of ReloadFeedFromServerIfNeeded() initiated
274 // from CheckForUpdates(). 250 // from CheckForUpdates().
275 void OnUpdateChecked(FileError error); 251 void OnUpdateChecked(FileError error);
276 252
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 // |callback| must not be null. 291 // |callback| must not be null.
316 void ReadDirectoryByPathAfterLoad( 292 void ReadDirectoryByPathAfterLoad(
317 const base::FilePath& directory_path, 293 const base::FilePath& directory_path,
318 const ReadDirectoryWithSettingCallback& callback, 294 const ReadDirectoryWithSettingCallback& callback,
319 FileError error); 295 FileError error);
320 void ReadDirectoryByPathAfterRead( 296 void ReadDirectoryByPathAfterRead(
321 const ReadDirectoryWithSettingCallback& callback, 297 const ReadDirectoryWithSettingCallback& callback,
322 FileError error, 298 FileError error,
323 scoped_ptr<ResourceEntryVector> entries); 299 scoped_ptr<ResourceEntryVector> entries);
324 300
325 // Gets the file at |file_path| from the cache (if found in the cache),
326 // or the server (if not found in the cache) after the file info is
327 // already resolved with GetResourceEntryByPath() or GetResourceEntryById().
328 void GetResolvedFileByPath(scoped_ptr<GetResolvedFileParams> params);
329 void GetResolvedFileByPathAfterCreateDocumentJsonFile(
330 scoped_ptr<GetResolvedFileParams> params,
331 const base::FilePath* file_path,
332 FileError error);
333 void GetResolvedFileByPathAfterGetFileFromCache(
334 scoped_ptr<GetResolvedFileParams> params,
335 FileError error,
336 const base::FilePath& cache_file_path);
337 void GetResolvedFileByPathAfterGetResourceEntry(
338 scoped_ptr<GetResolvedFileParams> params,
339 google_apis::GDataErrorCode status,
340 scoped_ptr<google_apis::ResourceEntry> entry);
341 void GetResolvedFileByPathAfterRefreshEntry(
342 scoped_ptr<GetResolvedFileParams> params,
343 const GURL& download_url,
344 FileError error,
345 const base::FilePath& drive_file_path,
346 scoped_ptr<ResourceEntry> entry);
347 void GetResolvedFileByPathAfterFreeDiskSpace(
348 scoped_ptr<GetResolvedFileParams> params,
349 const GURL& download_url,
350 bool has_enough_space);
351 void GetResolveFileByPathAfterCreateTemporaryFile(
352 scoped_ptr<GetResolvedFileParams> params,
353 const GURL& download_url,
354 base::FilePath* temp_file,
355 bool success);
356 void GetResolvedFileByPathAfterDownloadFile(
357 scoped_ptr<GetResolvedFileParams> params,
358 google_apis::GDataErrorCode status,
359 const base::FilePath& downloaded_file_path);
360 void GetResolvedFileByPathAfterGetCacheEntryForCancel(
361 const std::string& resource_id,
362 const std::string& md5,
363 bool success,
364 const FileCacheEntry& cache_entry);
365 void GetResolvedFileByPathAfterStore(
366 scoped_ptr<GetResolvedFileParams> params,
367 const base::FilePath& downloaded_file_path,
368 FileError error);
369 void GetResolvedFileByPathAfterGetFile(
370 scoped_ptr<GetResolvedFileParams> params,
371 FileError error,
372 const base::FilePath& cache_file);
373
374 // Part of GetResourceEntryById(). Called after 301 // Part of GetResourceEntryById(). Called after
375 // ResourceMetadata::GetResourceEntryById() is complete. 302 // ResourceMetadata::GetResourceEntryById() is complete.
376 // |callback| must not be null. 303 // |callback| must not be null.
377 void GetResourceEntryByIdAfterGetEntry( 304 void GetResourceEntryByIdAfterGetEntry(
378 const GetResourceEntryWithFilePathCallback& callback, 305 const GetResourceEntryWithFilePathCallback& callback,
379 FileError error, 306 FileError error,
380 const base::FilePath& file_path, 307 const base::FilePath& file_path,
381 scoped_ptr<ResourceEntry> entry); 308 scoped_ptr<ResourceEntry> entry);
382 309
383 // Part of GetFileByResourceId(). Called after 310 // Part of GetFileByResourceId(). Called after
384 // ResourceMetadata::GetResourceEntryById() is complete. 311 // ResourceMetadata::GetResourceEntryById() is complete.
385 // |get_file_callback| must not be null. 312 // |get_file_callback| must not be null.
386 // |get_content_callback| may be null. 313 // |get_content_callback| may be null.
387 void GetFileByResourceIdAfterGetEntry( 314 void GetFileByResourceIdAfterGetEntry(
388 const DriveClientContext& context, 315 const DriveClientContext& context,
389 const GetFileCallback& get_file_callback, 316 const GetFileCallback& get_file_callback,
390 const google_apis::GetContentCallback& get_content_callback, 317 const google_apis::GetContentCallback& get_content_callback,
391 FileError error, 318 FileError error,
392 const base::FilePath& file_path, 319 const base::FilePath& file_path,
393 scoped_ptr<ResourceEntry> entry); 320 scoped_ptr<ResourceEntry> entry);
394 321
395 // Part of GetFileContentByPath(). Called after
396 // ResourceMetadata::GetResourceEntryByPath() is complete.
397 // |initialized_callback|, |get_content_callback| and |completion_callback|
398 // must not be null.
399 void GetFileContentByPathAfterGetEntry(
400 const base::FilePath& file_path,
401 const GetFileContentInitializedCallback& initialized_callback,
402 const google_apis::GetContentCallback& get_content_callback,
403 const FileOperationCallback& completion_callback,
404 FileError error,
405 scoped_ptr<ResourceEntry> entry);
406
407 // Part of RefreshDirectory(). Called after 322 // Part of RefreshDirectory(). Called after
408 // GetResourceEntryByPath() is complete. 323 // GetResourceEntryByPath() is complete.
409 void RefreshDirectoryAfterGetResourceEntry( 324 void RefreshDirectoryAfterGetResourceEntry(
410 const base::FilePath& directory_path, 325 const base::FilePath& directory_path,
411 const FileOperationCallback& callback, 326 const FileOperationCallback& callback,
412 FileError error, 327 FileError error,
413 scoped_ptr<ResourceEntry> entry); 328 scoped_ptr<ResourceEntry> entry);
414 329
415 // Part of GetEntryByResourceId and GetEntryByPath. Checks whether there is a 330 // Part of GetEntryByResourceId and GetEntryByPath. Checks whether there is a
416 // local dirty cache for the entry, and if there is, replace the 331 // local dirty cache for the entry, and if there is, replace the
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 // Note: This should remain the last member so it'll be destroyed and 397 // Note: This should remain the last member so it'll be destroyed and
483 // invalidate the weak pointers before any other members are destroyed. 398 // invalidate the weak pointers before any other members are destroyed.
484 base::WeakPtrFactory<FileSystem> weak_ptr_factory_; 399 base::WeakPtrFactory<FileSystem> weak_ptr_factory_;
485 400
486 DISALLOW_COPY_AND_ASSIGN(FileSystem); 401 DISALLOW_COPY_AND_ASSIGN(FileSystem);
487 }; 402 };
488 403
489 } // namespace drive 404 } // namespace drive
490 405
491 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_H_ 406 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698