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

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_file_system.h

Issue 10827211: Replace GDataDirectory::TakeEntry with GDataDirectoryService::AddEntryToDirectory. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: better tests Created 8 years, 4 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_GDATA_GDATA_FILE_SYSTEM_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_
6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 struct CreateDirectoryParams; 164 struct CreateDirectoryParams;
165 165
166 // Defines set of parameters passed to an intermediate callback 166 // Defines set of parameters passed to an intermediate callback
167 // OnGetFileCompleteForOpen, during execution of OpenFile() method. 167 // OnGetFileCompleteForOpen, during execution of OpenFile() method.
168 struct GetFileCompleteForOpenParams; 168 struct GetFileCompleteForOpenParams;
169 169
170 // Defines set of parameters passed to intermediate callbacks during 170 // Defines set of parameters passed to intermediate callbacks during
171 // execution of GetFileByPath() method. 171 // execution of GetFileByPath() method.
172 struct GetFileFromCacheParams; 172 struct GetFileFromCacheParams;
173 173
174 // Callback similar to FileOperationCallback but with a given |file_path|.
175 typedef base::Callback<void(GDataFileError error,
176 const FilePath& file_path)>
177 FilePathUpdateCallback;
178 174
179 // Struct used for StartFileUploadOnUIThread(). 175 // Struct used for StartFileUploadOnUIThread().
180 struct StartFileUploadParams; 176 struct StartFileUploadParams;
181 177
182 // Callback passed to |LoadFeedFromServer| from |Search| method. 178 // Callback passed to |LoadFeedFromServer| from |Search| method.
183 // |callback| is that should be run with data received from 179 // |callback| is that should be run with data received from
184 // |LoadFeedFromServer|. 180 // |LoadFeedFromServer|.
185 // |params| params used for getting document feed for content search. 181 // |params| params used for getting document feed for content search.
186 // |error| error code returned by |LoadFeedFromServer|. 182 // |error| error code returned by |LoadFeedFromServer|.
187 void OnSearch(const SearchCallback& callback, 183 void OnSearch(const SearchCallback& callback,
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 344
349 // Copies a document with |resource_id| to the directory at |dir_path| 345 // Copies a document with |resource_id| to the directory at |dir_path|
350 // and names the copied document as |new_name|. 346 // and names the copied document as |new_name|.
351 // 347 //
352 // Can be called from UI thread. |callback| is run on the calling thread. 348 // Can be called from UI thread. |callback| is run on the calling thread.
353 void CopyDocumentToDirectory(const FilePath& dir_path, 349 void CopyDocumentToDirectory(const FilePath& dir_path,
354 const std::string& resource_id, 350 const std::string& resource_id,
355 const FilePath::StringType& new_name, 351 const FilePath::StringType& new_name,
356 const FileOperationCallback& callback); 352 const FileOperationCallback& callback);
357 353
358 // Renames a file or directory at |file_path| to |new_name|. 354 // Renames a file or directory at |file_path| to |new_name| in the same
355 // directory. |callback| will receive the new file path if the operation is
356 // successful. If the new name already exists in the same directory, the file
357 // name is uniquified by adding a parenthesized serial number like
358 // "foo (2).txt"
359 // 359 //
360 // Can be called from UI thread. |callback| is run on the calling thread. 360 // Can be called from UI thread. |callback| is run on the calling thread.
361 void Rename(const FilePath& file_path, 361 void Rename(const FilePath& file_path,
362 const FilePath::StringType& new_name, 362 const FilePath::StringType& new_name,
363 const FilePathUpdateCallback& callback); 363 const FileMoveCallback& callback);
364 364
365 // Part of Rename(). Called after GetEntryInfoByPath() is complete. 365 // Part of Rename(). Called after GetEntryInfoByPath() is complete.
366 void RenameAfterGetEntryInfo(const FilePath& file_path, 366 void RenameAfterGetEntryInfo(const FilePath& file_path,
367 const FilePath::StringType& new_name, 367 const FilePath::StringType& new_name,
368 const FilePathUpdateCallback& callback, 368 const FileMoveCallback& callback,
369 GDataFileError error, 369 GDataFileError error,
370 scoped_ptr<GDataEntryProto> entry_proto); 370 scoped_ptr<GDataEntryProto> entry_proto);
371 371
372 // Adds a file or directory at |file_path| to the directory at |dir_path|. 372 // Adds a file or directory at |file_path| to the directory at |dir_path|.
373 // 373 //
374 // Can be called from UI thread. |callback| is run on the calling thread. 374 // Can be called from UI thread. |callback| is run on the calling thread.
375 void AddEntryToDirectory(const FilePath& dir_path, 375 void AddEntryToDirectory(const FilePath& dir_path,
376 const FileOperationCallback& callback, 376 const FileOperationCallback& callback,
377 GDataFileError error, 377 GDataFileError error,
378 const FilePath& file_path); 378 const FilePath& file_path);
379 379
380 // Removes a file or directory at |file_path| from the directory at 380 // Removes a file or directory at |file_path| from the directory at
381 // |dir_path| and moves it to the root directory. 381 // |dir_path| and moves it to the root directory.
382 // 382 //
383 // Can be called from UI thread. |callback| is run on the calling thread. 383 // Can be called from UI thread. |callback| is run on the calling thread.
384 void RemoveEntryFromDirectory(const FilePath& dir_path, 384 void RemoveEntryFromDirectory(const FilePath& dir_path,
385 const FilePathUpdateCallback& callback, 385 const FileMoveCallback& callback,
386 GDataFileError error, 386 GDataFileError error,
387 const FilePath& file_path); 387 const FilePath& file_path);
388 388
389 // Removes file under |file_path| from in-memory snapshot of the file system. 389 // Removes file under |file_path| from in-memory snapshot of the file system.
390 // |resource_id| contains the resource id of the removed file if it was a 390 // |resource_id| contains the resource id of the removed file if it was a
391 // file. 391 // file.
392 // Return PLATFORM_FILE_OK if successful. 392 // Return PLATFORM_FILE_OK if successful.
393 GDataFileError RemoveEntryFromGData(const FilePath& file_path, 393 GDataFileError RemoveEntryFromGData(const FilePath& file_path,
394 std::string* resource_id); 394 std::string* resource_id);
395 395
396 // A pass-through callback used for bridging from 396 // A pass-through callback used for bridging from
397 // FilePathUpdateCallback to FileOperationCallback. 397 // FileMoveCallback to FileOperationCallback.
398 void OnFilePathUpdated(const FileOperationCallback& cllback, 398 void OnFilePathUpdated(const FileOperationCallback& cllback,
399 GDataFileError error, 399 GDataFileError error,
400 const FilePath& file_path); 400 const FilePath& file_path);
401 401
402 // Invoked upon completion of MarkDirtyInCache initiated by OpenFile. Invokes 402 // Invoked upon completion of MarkDirtyInCache initiated by OpenFile. Invokes
403 // |callback| with |cache_file_path|, which is the path of the cache file 403 // |callback| with |cache_file_path|, which is the path of the cache file
404 // ready for modification. 404 // ready for modification.
405 // 405 //
406 // Must be called on UI thread. 406 // Must be called on UI thread.
407 void OnMarkDirtyInCacheCompleteForOpenFile( 407 void OnMarkDirtyInCacheCompleteForOpenFile(
408 const OpenFileCallback& callback, 408 const OpenFileCallback& callback,
409 GDataFileError error, 409 GDataFileError error,
410 const std::string& resource_id, 410 const std::string& resource_id,
411 const std::string& md5, 411 const std::string& md5,
412 const FilePath& cache_file_path); 412 const FilePath& cache_file_path);
413 413
414 // Callback for handling resource rename attempt.
415 void OnRenameResourceCompleted(const FilePath& file_path,
416 const FilePath::StringType& new_name,
417 const FilePathUpdateCallback& callback,
418 GDataErrorCode status,
419 const GURL& document_url);
420
421 // Callback for handling document copy attempt. 414 // Callback for handling document copy attempt.
422 void OnCopyDocumentCompleted(const FilePath& dir_path, 415 void OnCopyDocumentCompleted(const FilePath& dir_path,
423 const FileOperationCallback& callback, 416 const FileOperationCallback& callback,
424 GDataErrorCode status, 417 GDataErrorCode status,
425 scoped_ptr<base::Value> data); 418 scoped_ptr<base::Value> data);
426 419
427 // Callback for handling an attempt to add a file or directory to another 420 // Callback for handling an attempt to add a file or directory to another
428 // directory. 421 // directory.
429 void OnAddEntryToDirectoryCompleted(const FileOperationCallback& callback, 422 void OnAddEntryToDirectoryCompleted(const FileOperationCallback& callback,
430 const FilePath& file_path, 423 const FilePath& file_path,
431 const FilePath& dir_path, 424 const FilePath& dir_path,
432 GDataErrorCode status, 425 GDataErrorCode status,
433 const GURL& document_url); 426 const GURL& document_url);
434 427
435 // Callback for handling an attempt to remove a file or directory from
436 // another directory.
437 void OnRemoveEntryFromDirectoryCompleted(
438 const FilePathUpdateCallback& callback,
439 const FilePath& file_path,
440 const FilePath& dir_path,
441 GDataErrorCode status,
442 const GURL& document_url);
443
444 // Callback for handling account metadata fetch. 428 // Callback for handling account metadata fetch.
445 void OnGetAvailableSpace( 429 void OnGetAvailableSpace(
446 const GetAvailableSpaceCallback& callback, 430 const GetAvailableSpaceCallback& callback,
447 GDataErrorCode status, 431 GDataErrorCode status,
448 scoped_ptr<base::Value> data); 432 scoped_ptr<base::Value> data);
449 433
450 // Callback for handling document remove attempt. 434 // Callback for handling document remove attempt.
451 void OnRemovedDocument( 435 void OnRemovedDocument(
452 const FileOperationCallback& callback, 436 const FileOperationCallback& callback,
453 const FilePath& file_path, 437 const FilePath& file_path,
(...skipping 27 matching lines...) Expand all
481 const GURL& content_url, 465 const GURL& content_url,
482 const FilePath& downloaded_file_path, 466 const FilePath& downloaded_file_path,
483 bool* has_enough_space); 467 bool* has_enough_space);
484 468
485 // Callback for handling internal StoreToCache() calls after downloading 469 // Callback for handling internal StoreToCache() calls after downloading
486 // file content. 470 // file content.
487 void OnDownloadStoredToCache(GDataFileError error, 471 void OnDownloadStoredToCache(GDataFileError error,
488 const std::string& resource_id, 472 const std::string& resource_id,
489 const std::string& md5); 473 const std::string& md5);
490 474
491 // Renames a file or directory at |file_path| on in-memory snapshot 475 // Callback for handling resource rename attempt. Renames a file or
492 // of the file system. Returns PLATFORM_FILE_OK if successful. 476 // directory at |file_path| on in-memory snapshot of the file system.
493 GDataFileError RenameFileOnFilesystem( 477 void RenameFileOnFileSystem(const FilePath& file_path,
494 const FilePath& file_path, const FilePath::StringType& new_name, 478 const FilePath::StringType& new_name,
495 FilePath* updated_file_path); 479 const FileMoveCallback& callback,
480 GDataErrorCode status,
481 const GURL& document_url);
496 482
497 // Adds an |entry| to another directory at |dir_path| on in-memory snapshot 483 // Callback for handling an attempt to remove a file or directory from
498 // of the file system. Returns PLATFORM_FILE_OK if successful. 484 // another directory. Removes a file or directory at |file_path| and moves it
499 GDataFileError AddEntryToDirectoryOnFilesystem( 485 // to root on in-memory snapshot of the file system.
500 GDataEntry* entry, const FilePath& dir_path); 486 void RemoveEntryFromDirectoryOnFileSystem(
501 487 const FileMoveCallback& callback,
502 // Removes a file or directory at |file_path| from another directory at 488 const FilePath& file_path,
503 // |dir_path| on in-memory snapshot of the file system. 489 const FilePath& dir_path,
504 // Returns PLATFORM_FILE_OK if successful. 490 GDataErrorCode status,
505 GDataFileError RemoveEntryFromDirectoryOnFilesystem( 491 const GURL& document_url);
506 const FilePath& file_path, const FilePath& dir_path,
507 FilePath* updated_file_path);
508 492
509 // Removes a file or directory under |file_path| from in-memory snapshot of 493 // Removes a file or directory under |file_path| from in-memory snapshot of
510 // the file system and the corresponding file from cache if it exists. 494 // the file system and the corresponding file from cache if it exists.
511 // Return PLATFORM_FILE_OK if successful. 495 // Return PLATFORM_FILE_OK if successful.
512 GDataFileError RemoveEntryFromFileSystem(const FilePath& file_path); 496 GDataFileError RemoveEntryFromFileSystem(const FilePath& file_path);
513 497
498 // Callback for GDataDirectoryService::MoveEntryToDirectory with
499 // FileMoveCallback.
500 void OnMoveEntryToDirectoryWithFileMoveCallback(
501 const FileMoveCallback& callback,
502 GDataFileError error,
503 const FilePath& moved_file_path);
504
505 // Callback for GDataDirectoryService::MoveEntryToDirectory with
506 // FileOperationCallback.
507 void OnMoveEntryToDirectoryWithFileOperationCallback(
508 const FileOperationCallback& callback,
509 GDataFileError error,
510 const FilePath& moved_file_path);
511
514 // Callback for GetEntryByResourceIdAsync. 512 // Callback for GetEntryByResourceIdAsync.
515 // Removes stale entry upon upload of file. 513 // Removes stale entry upon upload of file.
516 static void RemoveStaleEntryOnUpload(const std::string& resource_id, 514 static void RemoveStaleEntryOnUpload(const std::string& resource_id,
517 GDataDirectory* parent_dir, 515 GDataDirectory* parent_dir,
518 GDataEntry* existing_entry); 516 GDataEntry* existing_entry);
519 517
520 // Converts |entry_value| into GFileDocument instance and adds it 518 // Converts |entry_value| into GFileDocument instance and adds it
521 // to virtual file system at |directory_path|. 519 // to virtual file system at |directory_path|.
522 GDataFileError AddNewDirectory(const FilePath& directory_path, 520 GDataFileError AddNewDirectory(const FilePath& directory_path,
523 base::Value* entry_value); 521 base::Value* entry_value);
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 // invalidate the weak pointers before any other members are destroyed. 815 // invalidate the weak pointers before any other members are destroyed.
818 base::WeakPtrFactory<GDataFileSystem> ui_weak_ptr_factory_; 816 base::WeakPtrFactory<GDataFileSystem> ui_weak_ptr_factory_;
819 // Unlike other classes, we need this as we need this to redirect a task 817 // Unlike other classes, we need this as we need this to redirect a task
820 // from IO thread to UI thread. 818 // from IO thread to UI thread.
821 base::WeakPtr<GDataFileSystem> ui_weak_ptr_; 819 base::WeakPtr<GDataFileSystem> ui_weak_ptr_;
822 }; 820 };
823 821
824 } // namespace gdata 822 } // namespace gdata
825 823
826 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ 824 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/gdata/gdata_file_system.cc » ('j') | chrome/browser/chromeos/gdata/gdata_file_system.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698