| 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..3215cc27401b4575e99c97da83942b2412080b05
|
| --- /dev/null
|
| +++ b/chrome/browser/chromeos/drive/file_system/get_file_for_saving_operation.h
|
| @@ -0,0 +1,92 @@
|
| +// 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/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 notified to the
|
| +// OperationObserver.
|
| +// TODO(kinaba): crbug.com/269424: we might want to monitor all the changes
|
| +// to the cache directory, not just the one immediately after the save dialog.
|
| +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 marks it as dirty. The next modification to the cache file is
|
| + // watched and is automatically notified to the observer. If the entry is not
|
| + // 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_
|
|
|