Index: chrome/browser/chromeos/gdata/gdata_file_writing.h |
diff --git a/chrome/browser/chromeos/gdata/gdata_file_writing.h b/chrome/browser/chromeos/gdata/gdata_file_writing.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..904b0cc6bc7c0520c641bf2b62233643e3a04741 |
--- /dev/null |
+++ b/chrome/browser/chromeos/gdata/gdata_file_writing.h |
@@ -0,0 +1,61 @@ |
+// Copyright (c) 2012 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_GDATA_GDATA_FILE_WRITING_H_ |
+#define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_WRITING_H_ |
+ |
+#include "base/bind.h" |
+#include "base/file_path.h" |
+#include "base/memory/weak_ptr.h" |
+#include "chrome/browser/chromeos/gdata/gdata_errorcode.h" |
+#include "chrome/browser/chromeos/gdata/gdata_file_system_interface.h" |
+ |
+namespace gdata { |
+ |
+// This class provides higher level operations for writing to GData files over |
+// GDataFileSystemInterface. |
+class GDataFileWriting { |
satorux1
2012/08/02 01:08:09
The class name looks rather unusual. Maybe somethi
kinaba
2012/08/02 04:57:31
Done.
|
+ public: |
+ explicit GDataFileWriting(GDataFileSystemInterface* file_system); |
+ ~GDataFileWriting(); |
+ |
+ // Prepares a local temporary file path and passes it to |callback| on the |
+ // blocking thread pool that allows file operations. The modification to |
+ // the file is reflected to GData |path|. If |path| does not exist, a new |
+ // file is created. |
+ // |
+ // Can be called from UI/IO thread. |
+ void PrepareWritableFileAndRun(const FilePath& path, |
+ const OpenFileCallback& callback); |
+ |
+ private: |
+ // Part of PrepareWritableFilePathAndRun(). It forwards the task to the UI |
+ // thread, tries CreateFile for the case file does not exist yet, does |
+ // OpenFile to download and mark the file as dirty, runs |callback|, and |
+ // finally calls CloseFile. |
+ void PrepareWritableFileAndRunOnUIThread( |
+ const FilePath& file_path, |
+ const OpenFileCallback& callback); |
+ void PrepareWritableFileAndRunAfterCreateFile( |
+ const FilePath& file_path, |
+ const OpenFileCallback& callback, |
+ GDataFileError result); |
+ void PrepareWritableFileAndRunAfterOpenFile( |
+ const FilePath& file_path, |
+ const OpenFileCallback& callback, |
+ GDataFileError result, |
+ const FilePath& local_cache_path); |
+ void PrepareWritableFileAndRunAfterCallback(const FilePath& file_path); |
+ |
+ // File system owned by GDataSystemService. |
+ GDataFileSystemInterface* file_system_; |
+ |
+ // WeakPtrFactory and WeakPtr bound to the UI thread. |
+ base::WeakPtrFactory<GDataFileWriting> ui_weak_ptr_factory_; |
satorux1
2012/08/02 01:08:09
weak_ptr_factory_
kinaba
2012/08/02 04:57:31
Done.
|
+ base::WeakPtr<GDataFileWriting> ui_weak_ptr_; |
satorux1
2012/08/02 01:08:09
Please remove this. Please use GetWeakPtr()
kinaba
2012/08/02 04:57:31
Done.
|
+}; |
+ |
+} // namespace gdata |
+ |
+#endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_WRITING_H_ |