summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos
diff options
context:
space:
mode:
authorbenchan@chromium.org <benchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-25 08:03:12 +0000
committerbenchan@chromium.org <benchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-25 08:03:12 +0000
commit29290a53c9a6377cc93f486326109f6efce3ddc0 (patch)
tree68eff73a80c0f1e05ccc601011b5988d5266cd0a /chrome/browser/chromeos
parent4280f4be4e602f51c34add5286d119dfa764a00c (diff)
downloadchromium_src-29290a53c9a6377cc93f486326109f6efce3ddc0.zip
chromium_src-29290a53c9a6377cc93f486326109f6efce3ddc0.tar.gz
chromium_src-29290a53c9a6377cc93f486326109f6efce3ddc0.tar.bz2
gdata: Fix issue with copying hosted documents out from Docs folder.
This CL changes GDataFileSystem to generate temporary document JSON files in a sub-directory under the cache tmp directory, which can be accessed by the file browser extension. BUG=chromium-os:28384 TEST=Tested the following: 1. Run "unit_tests --gtest_filter='*GData*'" 2. Manually test copying and moving hosted documents from Docs folder to Downloads folder in file manager. Review URL: http://codereview.chromium.org/9834091 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128808 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos')
-rw-r--r--chrome/browser/chromeos/gdata/gdata_file_system.cc17
-rw-r--r--chrome/browser/chromeos/gdata/gdata_file_system.h12
-rw-r--r--chrome/browser/chromeos/gdata/gdata_files.cc2
-rw-r--r--chrome/browser/chromeos/gdata/gdata_files.h1
-rw-r--r--chrome/browser/chromeos/gdata/mock_gdata_file_system.h1
5 files changed, 28 insertions, 5 deletions
diff --git a/chrome/browser/chromeos/gdata/gdata_file_system.cc b/chrome/browser/chromeos/gdata/gdata_file_system.cc
index 0d5045a..4878d20 100644
--- a/chrome/browser/chromeos/gdata/gdata_file_system.cc
+++ b/chrome/browser/chromeos/gdata/gdata_file_system.cc
@@ -53,6 +53,8 @@ const FilePath::CharType kGDataCachePersistentDir[] =
const FilePath::CharType kGDataCacheTmpDir[] = FILE_PATH_LITERAL("tmp");
const FilePath::CharType kGDataCacheTmpDownloadsDir[] =
FILE_PATH_LITERAL("tmp/downloads");
+const FilePath::CharType kGDataCacheTmpDocumentsDir[] =
+ FILE_PATH_LITERAL("tmp/documents");
const FilePath::CharType kLastFeedFile[] = FILE_PATH_LITERAL("last_feed.json");
const char kGDataFileSystemToken[] = "GDataFileSystemToken";
const FilePath::CharType kAccountMetadataFile[] =
@@ -426,6 +428,7 @@ void GDataFileSystem::Initialize() {
cache_paths_.push_back(gdata_cache_path_.Append(kGDataCachePersistentDir));
cache_paths_.push_back(gdata_cache_path_.Append(kGDataCacheTmpDir));
cache_paths_.push_back(gdata_cache_path_.Append(kGDataCacheTmpDownloadsDir));
+ cache_paths_.push_back(gdata_cache_path_.Append(kGDataCacheTmpDocumentsDir));
documents_service_->Initialize(profile_);
@@ -979,6 +982,7 @@ void GDataFileSystem::CreateDirectory(
// static
void GDataFileSystem::CreateDocumentJsonFileOnIOThreadPool(
+ const FilePath& document_dir,
const GURL& edit_url,
const std::string& resource_id,
const GetFileCallback& callback,
@@ -986,7 +990,7 @@ void GDataFileSystem::CreateDocumentJsonFileOnIOThreadPool(
base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED;
FilePath temp_file;
- if (file_util::CreateTemporaryFile(&temp_file)) {
+ if (file_util::CreateTemporaryFileInDir(document_dir, &temp_file)) {
std::string document_content = base::StringPrintf(
"{\"url\": \"%s\", \"resource_id\": \"%s\"}",
edit_url.spec().c_str(), resource_id.c_str());
@@ -1026,8 +1030,13 @@ void GDataFileSystem::GetFile(const FilePath& file_path,
// formats. The JSON file contains the edit URL and resource ID of the
// document.
if (file_properties.is_hosted_document) {
- BrowserThread::PostBlockingPoolTask(FROM_HERE,
+ InitializeCacheIfNecessary();
+
+ PostBlockingPoolSequencedTask(
+ kGDataFileSystemToken,
+ FROM_HERE,
base::Bind(&GDataFileSystem::CreateDocumentJsonFileOnIOThreadPool,
+ GetGDataTempDocumentFolderPath(),
file_properties.edit_url,
file_properties.resource_id,
callback,
@@ -1276,6 +1285,10 @@ FilePath GDataFileSystem::GetGDataTempDownloadFolderPath() const {
return cache_paths_[GDataRootDirectory::CACHE_TYPE_TMP_DOWNLOADS];
}
+FilePath GDataFileSystem::GetGDataTempDocumentFolderPath() const {
+ return cache_paths_[GDataRootDirectory::CACHE_TYPE_TMP_DOCUMENTS];
+}
+
FilePath GDataFileSystem::GetGDataCachePinnedDirectory() const {
return cache_paths_[GDataRootDirectory::CACHE_TYPE_PINNED];
}
diff --git a/chrome/browser/chromeos/gdata/gdata_file_system.h b/chrome/browser/chromeos/gdata/gdata_file_system.h
index d34e498..564e517 100644
--- a/chrome/browser/chromeos/gdata/gdata_file_system.h
+++ b/chrome/browser/chromeos/gdata/gdata_file_system.h
@@ -349,6 +349,10 @@ class GDataFileSystemInterface {
// <user_profile_dir>/GCache/v1/tmp/downloads/
virtual FilePath GetGDataTempDownloadFolderPath() const = 0;
+ // Returns the tmp documents sub-directory under gdata cache directory, i.e.
+ // <user_profile_dir>/GCache/v1/tmp/documents/
+ virtual FilePath GetGDataTempDocumentFolderPath() const = 0;
+
// Returns the pinned sub-directory under gdata cache directory, i.e.
// <user_profile_dir>/GCache/v1/pinned
virtual FilePath GetGDataCachePinnedDirectory() const = 0;
@@ -435,6 +439,7 @@ class GDataFileSystem : public GDataFileSystemInterface {
GDataFileProperties* properties) OVERRIDE;
virtual FilePath GetGDataCacheTmpDirectory() const OVERRIDE;
virtual FilePath GetGDataTempDownloadFolderPath() const OVERRIDE;
+ virtual FilePath GetGDataTempDocumentFolderPath() const OVERRIDE;
virtual FilePath GetGDataCachePinnedDirectory() const OVERRIDE;
virtual FilePath GetGDataCachePersistentDirectory() const OVERRIDE;
virtual FilePath GetCacheFilePath(
@@ -598,10 +603,11 @@ class GDataFileSystem : public GDataFileSystemInterface {
base::PlatformFileError *error);
// Creates a temporary JSON file representing a document with |edit_url|
- // and |resource_id| on IO thread pool. Upon completion it will invoke
- // |callback| with the path of the created temporary file on thread
- // represented by |relay_proxy|.
+ // and |resource_id| under |document_dir| on IO thread pool. Upon completion
+ // it will invoke |callback| with the path of the created temporary file on
+ // thread represented by |relay_proxy|.
static void CreateDocumentJsonFileOnIOThreadPool(
+ const FilePath& document_dir,
const GURL& edit_url,
const std::string& resource_id,
const GetFileCallback& callback,
diff --git a/chrome/browser/chromeos/gdata/gdata_files.cc b/chrome/browser/chromeos/gdata/gdata_files.cc
index e5ed359..0796b55 100644
--- a/chrome/browser/chromeos/gdata/gdata_files.cc
+++ b/chrome/browser/chromeos/gdata/gdata_files.cc
@@ -31,6 +31,8 @@ std::string CacheSubDirectoryTypeToString(
case gdata::GDataRootDirectory::CACHE_TYPE_TMP: return "tmp";
case gdata::GDataRootDirectory::CACHE_TYPE_TMP_DOWNLOADS:
return "tmp_downloads";
+ case gdata::GDataRootDirectory::CACHE_TYPE_TMP_DOCUMENTS:
+ return "tmp_documents";
}
NOTREACHED();
return "unknown subdir";
diff --git a/chrome/browser/chromeos/gdata/gdata_files.h b/chrome/browser/chromeos/gdata/gdata_files.h
index 1828951..fee0be6 100644
--- a/chrome/browser/chromeos/gdata/gdata_files.h
+++ b/chrome/browser/chromeos/gdata/gdata_files.h
@@ -274,6 +274,7 @@ class GDataRootDirectory : public GDataDirectory {
CACHE_TYPE_TMP, // Files that don't meet criteria to be in
// persistent dir, and hence evictable.
CACHE_TYPE_TMP_DOWNLOADS, // Downloaded files.
+ CACHE_TYPE_TMP_DOCUMENTS, // Temporary JSON files for hosted documents.
};
// Structure to store information of an existing cache file.
diff --git a/chrome/browser/chromeos/gdata/mock_gdata_file_system.h b/chrome/browser/chromeos/gdata/mock_gdata_file_system.h
index dcf480e..6f52f88 100644
--- a/chrome/browser/chromeos/gdata/mock_gdata_file_system.h
+++ b/chrome/browser/chromeos/gdata/mock_gdata_file_system.h
@@ -66,6 +66,7 @@ class MockGDataFileSystem : public GDataFileSystemInterface {
GDataFileProperties* properties));
MOCK_CONST_METHOD0(GetGDataCacheTmpDirectory, FilePath());
MOCK_CONST_METHOD0(GetGDataTempDownloadFolderPath, FilePath());
+ MOCK_CONST_METHOD0(GetGDataTempDocumentFolderPath, FilePath());
MOCK_CONST_METHOD0(GetGDataCachePinnedDirectory, FilePath());
MOCK_CONST_METHOD0(GetGDataCachePersistentDirectory, FilePath());
MOCK_CONST_METHOD4(GetCacheFilePath, FilePath(