Chromium Code Reviews| Index: chrome/browser/chromeos/drive/file_system/get_file_for_saving_operation.h |
| diff --git a/chrome/browser/chromeos/drive/file_system/get_file_for_saving_operation.h b/chrome/browser/chromeos/drive/file_system/get_file_for_saving_operation.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..92b26b45a5a7b34f4dbc745a16b04f2c6ed4cb85 |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/drive/file_system/get_file_for_saving_operation.h |
| @@ -0,0 +1,90 @@ |
| +// Copyright 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_GET_FILE_FOR_SAVING_OPERATION_H_ |
| +#define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_GET_FILE_FOR_SAVING_OPERATION_H_ |
| + |
| +#include "base/basictypes.h" |
| +#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.
|
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "chrome/browser/chromeos/drive/file_errors.h" |
| +#include "chrome/browser/chromeos/drive/file_system_interface.h" |
| + |
| +namespace base { |
| +class FilePath; |
| +class SequencedTaskRunner; |
| +} // namespace base |
| + |
| +namespace drive { |
| +namespace internal { |
| +class FileCache; |
| +class FileWriteWatcher; |
| +class ResourceMetadata; |
| +} // namespace internal |
| + |
| +class JobScheduler; |
| +class ResourceEntry; |
| + |
| +namespace file_system { |
| + |
| +class CreateFileOperation; |
| +class DownloadOperation; |
| +class OperationObserver; |
| + |
| +// Implements GetFileForSaving() operation that prepares a local cache for |
| +// a Drive file whose next modification is monitored and uploaded to the server. |
| +class GetFileForSavingOperation { |
| + public: |
| + GetFileForSavingOperation(base::SequencedTaskRunner* blocking_task_runner, |
| + OperationObserver* observer, |
| + JobScheduler* scheduler, |
| + internal::ResourceMetadata* metadata, |
| + internal::FileCache* cache, |
| + const base::FilePath& temporary_file_directory); |
| + ~GetFileForSavingOperation(); |
| + |
| + // Makes sure that |file_path| in the file system is available in the local |
| + // cache, and mark it as dirty. The next modification to the cache file is |
| + // 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.
|
| + // present in the file system, it is created. |
| + void GetFileForSaving(const base::FilePath& file_path, |
| + const GetFileCallback& callback); |
| + |
| + internal::FileWriteWatcher* file_write_watcher_for_testing() { |
| + return file_write_watcher_.get(); |
| + } |
| + |
| + private: |
| + void GetFileForSavingAfterCreate(const base::FilePath& file_path, |
| + const GetFileCallback& callback, |
| + FileError error); |
| + void GetFileForSavingAfterDownload(const GetFileCallback& callback, |
| + FileError error, |
| + const base::FilePath& cache_path, |
| + scoped_ptr<ResourceEntry> entry); |
| + void GetFileForSavingAfterMarkDirty(const GetFileCallback& callback, |
| + const base::FilePath& cache_path, |
| + scoped_ptr<ResourceEntry> entry, |
| + FileError error); |
| + void GetFileForSavingAfterWatch(const GetFileCallback& callback, |
| + const base::FilePath& cache_path, |
| + scoped_ptr<ResourceEntry> entry, |
| + bool success); |
| + |
| + scoped_ptr<CreateFileOperation> create_file_operation_; |
| + scoped_ptr<DownloadOperation> download_operation_; |
| + scoped_ptr<internal::FileWriteWatcher> file_write_watcher_; |
| + internal::FileCache* cache_; |
| + |
| + // Note: This should remain the last member so it'll be destroyed and |
| + // invalidate the weak pointers before any other members are destroyed. |
| + base::WeakPtrFactory<GetFileForSavingOperation> weak_ptr_factory_; |
| + DISALLOW_COPY_AND_ASSIGN(GetFileForSavingOperation); |
| +}; |
| + |
| +} // namespace file_system |
| +} // namespace drive |
| + |
| +#endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_GET_FILE_FOR_SAVING_OPERATION_H_ |