Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_GET_FILE_FOR_SAVING_OPERATION_ H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_GET_FILE_FOR_SAVING_OPERATION_ H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/memory/ref_counted.h" | |
|
hashimoto
2013/08/07 10:31:54
nit: no need to include this?
kinaba
2013/08/07 11:28:38
Done.
| |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "base/memory/weak_ptr.h" | |
| 12 #include "chrome/browser/chromeos/drive/file_errors.h" | |
| 13 #include "chrome/browser/chromeos/drive/file_system_interface.h" | |
| 14 | |
| 15 namespace base { | |
| 16 class FilePath; | |
| 17 class SequencedTaskRunner; | |
| 18 } // namespace base | |
| 19 | |
| 20 namespace drive { | |
| 21 namespace internal { | |
| 22 class FileCache; | |
| 23 class FileWriteWatcher; | |
| 24 class ResourceMetadata; | |
| 25 } // namespace internal | |
| 26 | |
| 27 class JobScheduler; | |
| 28 class ResourceEntry; | |
| 29 | |
| 30 namespace file_system { | |
| 31 | |
| 32 class CreateFileOperation; | |
| 33 class DownloadOperation; | |
| 34 class OperationObserver; | |
| 35 | |
| 36 // Implements GetFileForSaving() operation that prepares a local cache for | |
| 37 // a Drive file whose next modification is monitored and uploaded to the server. | |
| 38 class GetFileForSavingOperation { | |
| 39 public: | |
| 40 GetFileForSavingOperation(base::SequencedTaskRunner* blocking_task_runner, | |
| 41 OperationObserver* observer, | |
| 42 JobScheduler* scheduler, | |
| 43 internal::ResourceMetadata* metadata, | |
| 44 internal::FileCache* cache, | |
| 45 const base::FilePath& temporary_file_directory); | |
| 46 ~GetFileForSavingOperation(); | |
| 47 | |
| 48 // Makes sure that |file_path| in the file system is available in the local | |
| 49 // cache, and mark it as dirty. The next modification to the cache file is | |
| 50 // watched and is automatically uploaded to the server. If the entry is not | |
|
hashimoto
2013/08/07 10:31:54
nit: "uploaded to the server" Considering what thi
kinaba
2013/08/07 11:28:38
Done.
| |
| 51 // present in the file system, it is created. | |
| 52 void GetFileForSaving(const base::FilePath& file_path, | |
| 53 const GetFileCallback& callback); | |
| 54 | |
| 55 internal::FileWriteWatcher* file_write_watcher_for_testing() { | |
| 56 return file_write_watcher_.get(); | |
| 57 } | |
| 58 | |
| 59 private: | |
| 60 void GetFileForSavingAfterCreate(const base::FilePath& file_path, | |
| 61 const GetFileCallback& callback, | |
| 62 FileError error); | |
| 63 void GetFileForSavingAfterDownload(const GetFileCallback& callback, | |
| 64 FileError error, | |
| 65 const base::FilePath& cache_path, | |
| 66 scoped_ptr<ResourceEntry> entry); | |
| 67 void GetFileForSavingAfterMarkDirty(const GetFileCallback& callback, | |
| 68 const base::FilePath& cache_path, | |
| 69 scoped_ptr<ResourceEntry> entry, | |
| 70 FileError error); | |
| 71 void GetFileForSavingAfterWatch(const GetFileCallback& callback, | |
| 72 const base::FilePath& cache_path, | |
| 73 scoped_ptr<ResourceEntry> entry, | |
| 74 bool success); | |
| 75 | |
| 76 scoped_ptr<CreateFileOperation> create_file_operation_; | |
| 77 scoped_ptr<DownloadOperation> download_operation_; | |
| 78 scoped_ptr<internal::FileWriteWatcher> file_write_watcher_; | |
| 79 internal::FileCache* cache_; | |
| 80 | |
| 81 // Note: This should remain the last member so it'll be destroyed and | |
| 82 // invalidate the weak pointers before any other members are destroyed. | |
| 83 base::WeakPtrFactory<GetFileForSavingOperation> weak_ptr_factory_; | |
| 84 DISALLOW_COPY_AND_ASSIGN(GetFileForSavingOperation); | |
| 85 }; | |
| 86 | |
| 87 } // namespace file_system | |
| 88 } // namespace drive | |
| 89 | |
| 90 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_GET_FILE_FOR_SAVING_OPERATI ON_H_ | |
| OLD | NEW |