Index: chrome/browser/chromeos/gdata/gdata_util.cc |
diff --git a/chrome/browser/chromeos/gdata/gdata_util.cc b/chrome/browser/chromeos/gdata/gdata_util.cc |
index fe764c9ea56c16d80185a3bde161038ae20ee606..52af3978bcece5f1aa8fd944b8ff7a523a156d70 100644 |
--- a/chrome/browser/chromeos/gdata/gdata_util.cc |
+++ b/chrome/browser/chromeos/gdata/gdata_util.cc |
@@ -23,6 +23,7 @@ |
#include "base/time.h" |
#include "chrome/browser/chromeos/gdata/gdata.pb.h" |
#include "chrome/browser/chromeos/gdata/gdata_file_system_interface.h" |
+#include "chrome/browser/chromeos/gdata/gdata_file_write_helper.h" |
#include "chrome/browser/chromeos/gdata/gdata_system_service.h" |
#include "chrome/browser/chromeos/login/user.h" |
#include "chrome/browser/chromeos/login/user_manager.h" |
@@ -71,6 +72,12 @@ GDataCache* GetGDataCache(Profile* profile) { |
return system_service ? system_service->cache() : NULL; |
} |
+GDataFileWriteHelper* GetGDataFileWriteHelper(Profile* profile) { |
+ GDataSystemService* system_service = |
+ GDataSystemServiceFactory::GetForProfile(profile); |
+ return system_service ? system_service->file_write_helper() : NULL; |
+} |
+ |
void GetHostedDocumentURLBlockingThread(const FilePath& gdata_cache_path, |
GURL* url) { |
std::string json; |
@@ -579,5 +586,22 @@ std::string FormatTimeAsString(const base::Time& time) { |
exploded.hour, exploded.minute, exploded.second, exploded.millisecond); |
} |
+void PrepareWritableFileAndRun(Profile* profile, |
+ const FilePath& path, |
+ const OpenFileCallback& callback) { |
+ if (IsUnderGDataMountPoint(path)) { |
+ GDataFileWriteHelper* file_write_helper = GetGDataFileWriteHelper(profile); |
+ if (!file_write_helper) |
+ return; |
+ FilePath remote_path(ExtractGDataPath(path)); |
+ file_write_helper->PrepareWritableFileAndRun(remote_path, callback); |
+ } else { |
+ if (!callback.is_null()) { |
+ content::BrowserThread::GetBlockingPool()->PostTask( |
+ FROM_HERE, base::Bind(callback, GDATA_FILE_OK, path)); |
+ } |
+ } |
+} |
+ |
} // namespace util |
} // namespace gdata |