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

Unified Diff: chrome/browser/chromeos/gdata/file_write_helper.h

Issue 10827068: gdata: Fix "save as pdf" to work on Google Drive. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase + add bug id + drive-by comment typo fix. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/chromeos/gdata/file_write_helper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/gdata/file_write_helper.h
diff --git a/chrome/browser/chromeos/gdata/file_write_helper.h b/chrome/browser/chromeos/gdata/file_write_helper.h
new file mode 100644
index 0000000000000000000000000000000000000000..c405bf1093401a97cad41fd6ffd63c45cf506a50
--- /dev/null
+++ b/chrome/browser/chromeos/gdata/file_write_helper.h
@@ -0,0 +1,60 @@
+// 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_FILE_WRITE_HELPER_H_
+#define CHROME_BROWSER_CHROMEOS_GDATA_FILE_WRITE_HELPER_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 FileWriteHelper {
+ public:
+ explicit FileWriteHelper(GDataFileSystemInterface* file_system);
+ ~FileWriteHelper();
+
+ // 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.
+ //
+ // Must be called from UI thread.
+ void PrepareWritableFileAndRun(const FilePath& path,
+ const OpenFileCallback& callback);
+
+ private:
+ // Part of PrepareWritableFilePathAndRun(). It 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 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 bound to the UI thread.
+ // Note: This should remain the last member so it'll be destroyed and
+ // invalidate its weak pointers before any other members are destroyed.
+ base::WeakPtrFactory<FileWriteHelper> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(FileWriteHelper);
+};
+
+} // namespace gdata
+
+#endif // CHROME_BROWSER_CHROMEOS_GDATA_FILE_WRITE_HELPER_H_
« no previous file with comments | « no previous file | chrome/browser/chromeos/gdata/file_write_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698