Chromium Code Reviews| Index: chrome/browser/chromeos/gdata/gdata_file_system.cc |
| =================================================================== |
| --- chrome/browser/chromeos/gdata/gdata_file_system.cc (revision 128786) |
| +++ chrome/browser/chromeos/gdata/gdata_file_system.cc (working copy) |
| @@ -53,6 +53,10 @@ |
| const FilePath::CharType kGDataCacheTmpDir[] = FILE_PATH_LITERAL("tmp"); |
| const FilePath::CharType kGDataCacheTmpDownloadsDir[] = |
| FILE_PATH_LITERAL("tmp/downloads"); |
| +// Sub-directory, under the system temporary directory, for hosting temporary |
| +// document JSON file. |
| +const FilePath::CharType kGDataTempDocumentDir[] = |
| + FILE_PATH_LITERAL("gdata_documents"); |
| const FilePath::CharType kLastFeedFile[] = FILE_PATH_LITERAL("last_feed.json"); |
| const char kGDataFileSystemToken[] = "GDataFileSystemToken"; |
| const FilePath::CharType kAccountMetadataFile[] = |
| @@ -427,6 +431,10 @@ |
| cache_paths_.push_back(gdata_cache_path_.Append(kGDataCacheTmpDir)); |
| cache_paths_.push_back(gdata_cache_path_.Append(kGDataCacheTmpDownloadsDir)); |
| + // GetTempDir should not really fail here. |
| + CHECK(file_util::GetTempDir(&temp_document_dir_)); |
| + temp_document_dir_ = temp_document_dir_.Append(kGDataTempDocumentDir); |
| + |
| documents_service_->Initialize(profile_); |
| root_.reset(new GDataRootDirectory(this)); |
| @@ -437,6 +445,11 @@ |
| // Should be deleted on IO thread by GDataSystemService. |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| + // Delete the sub-directory, under system temporary directory, for |
| + // hosting temporary hosting document JSON files. |
| + if (!temp_document_dir_.empty()) |
| + file_util::Delete(temp_document_dir_, true); |
|
satorux1
2012/03/24 23:42:51
Oh you cannot do this here.
BrowserThread::IO is
zel
2012/03/24 23:46:29
we can just leave this directory in place, no harm
|
| + |
| // io_weak_ptr_factory_ must be deleted on IO thread. |
| io_weak_ptr_factory_.reset(); |
| // documents_service_ must be deleted on IO thread, as it also owns |
| @@ -979,6 +992,7 @@ |
| // static |
| void GDataFileSystem::CreateDocumentJsonFileOnIOThreadPool( |
| + const FilePath& document_dir, |
| const GURL& edit_url, |
| const std::string& resource_id, |
| const GetFileCallback& callback, |
| @@ -986,7 +1000,8 @@ |
| base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED; |
| FilePath temp_file; |
| - if (file_util::CreateTemporaryFile(&temp_file)) { |
| + if (file_util::CreateDirectory(document_dir) && |
| + 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()); |
| @@ -1028,6 +1043,7 @@ |
| if (file_properties.is_hosted_document) { |
| BrowserThread::PostBlockingPoolTask(FROM_HERE, |
| base::Bind(&GDataFileSystem::CreateDocumentJsonFileOnIOThreadPool, |
| + temp_document_dir_, |
| file_properties.edit_url, |
| file_properties.resource_id, |
| callback, |
| @@ -1239,6 +1255,10 @@ |
| return cache_paths_[GDataRootDirectory::CACHE_TYPE_PERSISTENT]; |
| } |
| +FilePath GDataFileSystem::GetGDataTempDocumentDirectory() const { |
| + return temp_document_dir_; |
| +} |
| + |
| base::WeakPtr<GDataFileSystem> GDataFileSystem::GetWeakPtrForCurrentThread() { |
| if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| return ui_weak_ptr_factory_->GetWeakPtr(); |