diff options
Diffstat (limited to 'chrome')
12 files changed, 111 insertions, 92 deletions
diff --git a/chrome/browser/sync_file_system/drive_backend/api_util.cc b/chrome/browser/sync_file_system/drive_backend/api_util.cc index 84cb34a..e1ddfb7 100644 --- a/chrome/browser/sync_file_system/drive_backend/api_util.cc +++ b/chrome/browser/sync_file_system/drive_backend/api_util.cc @@ -9,6 +9,7 @@ #include <sstream> #include <string> +#include "base/file_util.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "base/threading/sequenced_worker_pool.h" @@ -137,9 +138,24 @@ std::string GetMimeTypeFromTitle(const std::string& title) { return mime_type; } +bool CreateTemporaryFile(const base::FilePath& dir_path, + webkit_blob::ScopedFile* temp_file) { + base::FilePath temp_file_path; + const bool success = file_util::CreateDirectory(dir_path) && + file_util::CreateTemporaryFileInDir(dir_path, &temp_file_path); + if (!success) + return success; + *temp_file = + webkit_blob::ScopedFile(temp_file_path, + webkit_blob::ScopedFile::DELETE_ON_SCOPE_OUT, + base::MessageLoopProxy::current().get()); + return success; +} + } // namespace -APIUtil::APIUtil(Profile* profile) +APIUtil::APIUtil(Profile* profile, + const base::FilePath& temp_dir_path) : wapi_url_generator_( GURL(google_apis::GDataWapiUrlGenerator::kBaseUrlForProduction), GURL(google_apis::GDataWapiUrlGenerator:: @@ -148,7 +164,8 @@ APIUtil::APIUtil(Profile* profile) GURL(google_apis::DriveApiUrlGenerator::kBaseUrlForProduction), GURL(google_apis::DriveApiUrlGenerator:: kBaseDownloadUrlForProduction)), - upload_next_key_(0) { + upload_next_key_(0), + temp_dir_path_(temp_dir_path) { if (IsDriveAPIDisabled()) { drive_service_.reset(new drive::GDataWapiService( profile->GetRequestContext(), @@ -175,10 +192,12 @@ APIUtil::APIUtil(Profile* profile) scoped_ptr<APIUtil> APIUtil::CreateForTesting( Profile* profile, + const base::FilePath& temp_dir_path, scoped_ptr<drive::DriveServiceInterface> drive_service, scoped_ptr<drive::DriveUploaderInterface> drive_uploader) { return make_scoped_ptr(new APIUtil( profile, + temp_dir_path, GURL(kFakeServerBaseUrl), GURL(kFakeDownloadServerBaseUrl), drive_service.Pass(), @@ -186,13 +205,15 @@ scoped_ptr<APIUtil> APIUtil::CreateForTesting( } APIUtil::APIUtil(Profile* profile, + const base::FilePath& temp_dir_path, const GURL& base_url, const GURL& base_download_url, scoped_ptr<drive::DriveServiceInterface> drive_service, scoped_ptr<drive::DriveUploaderInterface> drive_uploader) : wapi_url_generator_(base_url, base_download_url), drive_api_url_generator_(base_url, base_download_url), - upload_next_key_(0) { + upload_next_key_(0), + temp_dir_path_(temp_dir_path) { drive_service_ = drive_service.Pass(); drive_service_->Initialize(profile); drive_service_->AddObserver(this); @@ -484,20 +505,19 @@ void APIUtil::ContinueListing(const GURL& feed_url, void APIUtil::DownloadFile(const std::string& resource_id, const std::string& local_file_md5, - const base::FilePath& local_file_path, const DownloadFileCallback& callback) { DCHECK(CalledOnValidThread()); + DCHECK(!temp_dir_path_.empty()); DVLOG(2) << "Downloading file [" << resource_id << "]"; - drive_service_->GetResourceEntry( - resource_id, - base::Bind(&APIUtil::DidGetResourceEntry, - AsWeakPtr(), - base::Bind(&APIUtil::DownloadFileInternal, - AsWeakPtr(), - local_file_md5, - local_file_path, - callback))); + scoped_ptr<webkit_blob::ScopedFile> temp_file(new webkit_blob::ScopedFile); + webkit_blob::ScopedFile* temp_file_ptr = temp_file.get(); + content::BrowserThread::PostTaskAndReplyWithResult( + content::BrowserThread::FILE, FROM_HERE, + base::Bind(&CreateTemporaryFile, temp_dir_path_, temp_file_ptr), + base::Bind(&APIUtil::DidGetTemporaryFileForDownload, + AsWeakPtr(), resource_id, local_file_md5, + base::Passed(&temp_file), callback)); } void APIUtil::UploadNewFile(const std::string& directory_resource_id, @@ -699,9 +719,33 @@ void APIUtil::DidGetResourceEntry( callback.Run(error, entry.Pass()); } +void APIUtil::DidGetTemporaryFileForDownload( + const std::string& resource_id, + const std::string& local_file_md5, + scoped_ptr<webkit_blob::ScopedFile> local_file, + const DownloadFileCallback& callback, + bool success) { + if (!success) { + DVLOG(2) << "Error in creating a temp file under " + << temp_dir_path_.value(); + callback.Run(google_apis::GDATA_FILE_ERROR, std::string(), 0, base::Time(), + local_file.Pass()); + return; + } + drive_service_->GetResourceEntry( + resource_id, + base::Bind(&APIUtil::DidGetResourceEntry, + AsWeakPtr(), + base::Bind(&APIUtil::DownloadFileInternal, + AsWeakPtr(), + local_file_md5, + base::Passed(&local_file), + callback))); +} + void APIUtil::DownloadFileInternal( const std::string& local_file_md5, - const base::FilePath& local_file_path, + scoped_ptr<webkit_blob::ScopedFile> local_file, const DownloadFileCallback& callback, google_apis::GDataErrorCode error, scoped_ptr<google_apis::ResourceEntry> entry) { @@ -709,7 +753,8 @@ void APIUtil::DownloadFileInternal( if (error != google_apis::HTTP_SUCCESS) { DVLOG(2) << "Error on getting resource entry for download"; - callback.Run(error, std::string(), 0, base::Time()); + callback.Run(error, std::string(), 0, base::Time(), + local_file.Pass()); return; } DCHECK(entry); @@ -720,23 +765,27 @@ void APIUtil::DownloadFileInternal( callback.Run(google_apis::HTTP_NOT_MODIFIED, local_file_md5, entry->file_size(), - entry->updated_time()); + entry->updated_time(), + local_file.Pass()); return; } DVLOG(2) << "Downloading file: " << entry->resource_id(); const std::string& resource_id = entry->resource_id(); + const base::FilePath& local_file_path = local_file->path(); drive_service_->DownloadFile(local_file_path, resource_id, base::Bind(&APIUtil::DidDownloadFile, AsWeakPtr(), base::Passed(&entry), + base::Passed(&local_file), callback), google_apis::GetContentCallback(), google_apis::ProgressCallback()); } void APIUtil::DidDownloadFile(scoped_ptr<google_apis::ResourceEntry> entry, + scoped_ptr<webkit_blob::ScopedFile> local_file, const DownloadFileCallback& callback, google_apis::GDataErrorCode error, const base::FilePath& downloaded_file_path) { @@ -747,7 +796,8 @@ void APIUtil::DidDownloadFile(scoped_ptr<google_apis::ResourceEntry> entry, DVLOG(2) << "Error on downloading file: " << error; callback.Run( - error, entry->file_md5(), entry->file_size(), entry->updated_time()); + error, entry->file_md5(), entry->file_size(), entry->updated_time(), + local_file.Pass()); } void APIUtil::DidUploadNewFile(const std::string& parent_resource_id, diff --git a/chrome/browser/sync_file_system/drive_backend/api_util.h b/chrome/browser/sync_file_system/drive_backend/api_util.h index 8c17628..e976a15 100644 --- a/chrome/browser/sync_file_system/drive_backend/api_util.h +++ b/chrome/browser/sync_file_system/drive_backend/api_util.h @@ -15,6 +15,7 @@ #include "chrome/browser/google_apis/gdata_wapi_url_generator.h" #include "chrome/browser/sync_file_system/drive_backend/api_util_interface.h" #include "net/base/network_change_notifier.h" +#include "webkit/common/blob/scoped_file.h" class GURL; class Profile; @@ -44,7 +45,7 @@ class APIUtil : public APIUtilInterface, scoped_ptr<google_apis::ResourceEntry> entry)> EnsureUniquenessCallback; - explicit APIUtil(Profile* profile); + APIUtil(Profile* profile, const base::FilePath& temp_dir_path); virtual ~APIUtil(); virtual void AddObserver(APIUtilObserver* observer) OVERRIDE; @@ -52,6 +53,7 @@ class APIUtil : public APIUtilInterface, static scoped_ptr<APIUtil> CreateForTesting( Profile* profile, + const base::FilePath& temp_dir_path, scoped_ptr<drive::DriveServiceInterface> drive_service, scoped_ptr<drive::DriveUploaderInterface> drive_uploader); @@ -74,7 +76,6 @@ class APIUtil : public APIUtilInterface, const ResourceListCallback& callback) OVERRIDE; virtual void DownloadFile(const std::string& resource_id, const std::string& local_file_md5, - const base::FilePath& local_file_path, const DownloadFileCallback& callback) OVERRIDE; virtual void UploadNewFile(const std::string& directory_resource_id, const base::FilePath& local_file_path, @@ -115,6 +116,7 @@ class APIUtil : public APIUtilInterface, // Constructor for test use. APIUtil(Profile* profile, + const base::FilePath& temp_dir_path, const GURL& base_url, const GURL& base_download_url, scoped_ptr<drive::DriveServiceInterface> drive_service, @@ -169,13 +171,21 @@ class APIUtil : public APIUtilInterface, google_apis::GDataErrorCode error, scoped_ptr<google_apis::ResourceEntry> entry); + void DidGetTemporaryFileForDownload( + const std::string& resource_id, + const std::string& local_file_md5, + scoped_ptr<webkit_blob::ScopedFile> local_file, + const DownloadFileCallback& callback, + bool success); + void DownloadFileInternal(const std::string& local_file_md5, - const base::FilePath& local_file_path, + scoped_ptr<webkit_blob::ScopedFile> local_file, const DownloadFileCallback& callback, google_apis::GDataErrorCode error, scoped_ptr<google_apis::ResourceEntry> entry); void DidDownloadFile(scoped_ptr<google_apis::ResourceEntry> entry, + scoped_ptr<webkit_blob::ScopedFile> local_file, const DownloadFileCallback& callback, google_apis::GDataErrorCode error, const base::FilePath& downloaded_file_path); @@ -243,6 +253,8 @@ class APIUtil : public APIUtilInterface, UploadCallbackMap upload_callback_map_; UploadKey upload_next_key_; + base::FilePath temp_dir_path_; + std::string root_resource_id_; ObserverList<APIUtilObserver> observers_; diff --git a/chrome/browser/sync_file_system/drive_backend/api_util_interface.h b/chrome/browser/sync_file_system/drive_backend/api_util_interface.h index 46867f2..e4a2ca7 100644 --- a/chrome/browser/sync_file_system/drive_backend/api_util_interface.h +++ b/chrome/browser/sync_file_system/drive_backend/api_util_interface.h @@ -22,6 +22,10 @@ namespace google_apis { class DriveUploaderInterface; } +namespace webkit_blob { +class ScopedFile; +} + namespace sync_file_system { namespace drive_backend { @@ -46,7 +50,8 @@ class APIUtilInterface { typedef base::Callback<void(google_apis::GDataErrorCode error, const std::string& file_md5, int64 file_size, - const base::Time& last_updated)> + const base::Time& last_updated, + scoped_ptr<webkit_blob::ScopedFile> downloaded)> DownloadFileCallback; typedef base::Callback<void(google_apis::GDataErrorCode error, const std::string& resource_id, @@ -130,7 +135,6 @@ class APIUtilInterface { // empty. virtual void DownloadFile(const std::string& resource_id, const std::string& local_file_md5, - const base::FilePath& local_file_path, const DownloadFileCallback& callback) = 0; // Uploads the new file |local_file_path| with specified |title| into the diff --git a/chrome/browser/sync_file_system/drive_backend/api_util_unittest.cc b/chrome/browser/sync_file_system/drive_backend/api_util_unittest.cc index 1407ab9..3f03963 100644 --- a/chrome/browser/sync_file_system/drive_backend/api_util_unittest.cc +++ b/chrome/browser/sync_file_system/drive_backend/api_util_unittest.cc @@ -4,6 +4,7 @@ #include "chrome/browser/sync_file_system/drive_backend/api_util.h" +#include "base/file_util.h" #include "base/location.h" #include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop_proxy.h" @@ -214,8 +215,10 @@ class APIUtilTest : public testing::Test { fake_drive_helper_.reset(new FakeDriveServiceHelper( fake_drive_service_, fake_drive_uploader_)); + ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); api_util_ = APIUtil::CreateForTesting( &profile_, + temp_dir_.path(), scoped_ptr<DriveServiceInterface>(fake_drive_service_), scoped_ptr<DriveUploaderInterface>(fake_drive_uploader_)); @@ -324,6 +327,7 @@ class APIUtilTest : public testing::Test { private: content::TestBrowserThreadBundle thread_bundle_; + base::ScopedTempDir temp_dir_; TestingProfile profile_; scoped_ptr<APIUtil> api_util_; FakeDriveServiceWrapper* fake_drive_service_; @@ -363,8 +367,10 @@ void DidDownloadFile(Output* output, GDataErrorCode error, const std::string& file_md5, int64 file_size, - const base::Time& updated_time) { + const base::Time& updated_time, + scoped_ptr<webkit_blob::ScopedFile> file) { ASSERT_TRUE(output); + ASSERT_TRUE(base::PathExists(file->path())); output->error = error; output->file_md5 = file_md5; } @@ -585,15 +591,10 @@ void APIUtilTest::TestDownloadFile() { scoped_ptr<ResourceEntry> file; SetUpFile(origin_root_id, kFileContent, kFileTitle, &file); - base::ScopedTempDir temp_dir; - ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); - base::FilePath output_file_path = temp_dir.path().AppendASCII(file->title()); - Output output; api_util()->DownloadFile( file->resource_id(), "", // local_file_md5 - output_file_path, base::Bind(&DidDownloadFile, &output)); base::MessageLoop::current()->RunUntilIdle(); @@ -610,17 +611,12 @@ void APIUtilTest::TestDownloadFileInNotModified() { scoped_ptr<ResourceEntry> file; SetUpFile(origin_root_id, kFileContent, kFileTitle, &file); - base::ScopedTempDir temp_dir; - ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); - base::FilePath output_file_path = temp_dir.path().AppendASCII(file->title()); - // Since local file's hash value is equal to remote file's one, it is expected // to cancel download the file and to return NOT_MODIFIED status code. Output output; api_util()->DownloadFile( file->resource_id(), file->file_md5(), - output_file_path, base::Bind(&DidDownloadFile, &output)); base::MessageLoop::current()->RunUntilIdle(); diff --git a/chrome/browser/sync_file_system/drive_backend/drive_file_sync_service.cc b/chrome/browser/sync_file_system/drive_backend/drive_file_sync_service.cc index 4ff04d8..9e07bdd 100644 --- a/chrome/browser/sync_file_system/drive_backend/drive_file_sync_service.cc +++ b/chrome/browser/sync_file_system/drive_backend/drive_file_sync_service.cc @@ -58,20 +58,6 @@ const base::FilePath::CharType* GetSyncFileSystemDir() { ? kSyncFileSystemDirDev : kSyncFileSystemDir; } -bool CreateTemporaryFile(const base::FilePath& dir_path, - webkit_blob::ScopedFile* temp_file) { - base::FilePath temp_file_path; - const bool success = file_util::CreateDirectory(dir_path) && - file_util::CreateTemporaryFileInDir(dir_path, &temp_file_path); - if (!success) - return success; - *temp_file = - webkit_blob::ScopedFile(temp_file_path, - webkit_blob::ScopedFile::DELETE_ON_SCOPE_OUT, - base::MessageLoopProxy::current().get()); - return success; -} - void EmptyStatusCallback(SyncStatusCode status) {} } // namespace @@ -325,7 +311,7 @@ void DriveFileSyncService::Initialize( temporary_file_dir_ = profile_->GetPath().Append(GetSyncFileSystemDir()).Append(kTempDirName); - api_util_.reset(new drive_backend::APIUtil(profile_)); + api_util_.reset(new drive_backend::APIUtil(profile_, temporary_file_dir_)); api_util_->AddObserver(this); metadata_store_.reset(new DriveMetadataStore( diff --git a/chrome/browser/sync_file_system/drive_backend/drive_file_sync_service_fake_unittest.cc b/chrome/browser/sync_file_system/drive_backend/drive_file_sync_service_fake_unittest.cc index 2d1e8a2..6f8431a 100644 --- a/chrome/browser/sync_file_system/drive_backend/drive_file_sync_service_fake_unittest.cc +++ b/chrome/browser/sync_file_system/drive_backend/drive_file_sync_service_fake_unittest.cc @@ -207,6 +207,7 @@ class DriveFileSyncServiceFakeTest : public testing::Test { api_util_ = APIUtil::CreateForTesting( profile_.get(), + fake_drive_helper_->base_dir_path().AppendASCII("tmp"), scoped_ptr<DriveServiceInterface>(fake_drive_service_), scoped_ptr<DriveUploaderInterface>(drive_uploader)).Pass(); metadata_store_.reset(new DriveMetadataStore( diff --git a/chrome/browser/sync_file_system/drive_backend/drive_file_sync_service_sync_unittest.cc b/chrome/browser/sync_file_system/drive_backend/drive_file_sync_service_sync_unittest.cc index 8d273d1..41e9037 100644 --- a/chrome/browser/sync_file_system/drive_backend/drive_file_sync_service_sync_unittest.cc +++ b/chrome/browser/sync_file_system/drive_backend/drive_file_sync_service_sync_unittest.cc @@ -118,6 +118,7 @@ class DriveFileSyncServiceSyncTest : public testing::Test { scoped_ptr<APIUtil> api_util(APIUtil::CreateForTesting( &profile_, + fake_drive_helper_->base_dir_path().AppendASCII("tmp"), scoped_ptr<drive::DriveServiceInterface>(fake_drive_service_), scoped_ptr<drive::DriveUploaderInterface>(drive_uploader_))); diff --git a/chrome/browser/sync_file_system/drive_backend/fake_api_util.cc b/chrome/browser/sync_file_system/drive_backend/fake_api_util.cc index c8e01a1..88ce414 100644 --- a/chrome/browser/sync_file_system/drive_backend/fake_api_util.cc +++ b/chrome/browser/sync_file_system/drive_backend/fake_api_util.cc @@ -10,6 +10,7 @@ #include "base/location.h" #include "base/message_loop/message_loop_proxy.h" #include "chrome/browser/google_apis/drive_entry_kinds.h" +#include "webkit/common/blob/scoped_file.h" namespace sync_file_system { namespace drive_backend { @@ -145,7 +146,6 @@ void FakeAPIUtil::ContinueListing(const GURL& feed_url, void FakeAPIUtil::DownloadFile(const std::string& resource_id, const std::string& local_file_md5, - const base::FilePath& local_file_path, const DownloadFileCallback& callback) { RemoteResourceByResourceId::iterator found = remote_resources_.find(resource_id); @@ -163,9 +163,12 @@ void FakeAPIUtil::DownloadFile(const std::string& resource_id, error = google_apis::HTTP_SUCCESS; } + scoped_ptr<webkit_blob::ScopedFile> dummy_local_file( + new webkit_blob::ScopedFile); base::MessageLoopProxy::current()->PostTask( FROM_HERE, - base::Bind(callback, error, file_md5, file_size, updated_time)); + base::Bind(callback, error, file_md5, file_size, updated_time, + base::Passed(&dummy_local_file))); } void FakeAPIUtil::UploadNewFile(const std::string& directory_resource_id, diff --git a/chrome/browser/sync_file_system/drive_backend/fake_api_util.h b/chrome/browser/sync_file_system/drive_backend/fake_api_util.h index 52c201e..3c5a552 100644 --- a/chrome/browser/sync_file_system/drive_backend/fake_api_util.h +++ b/chrome/browser/sync_file_system/drive_backend/fake_api_util.h @@ -79,7 +79,6 @@ class FakeAPIUtil : public APIUtilInterface { const ResourceListCallback& callback) OVERRIDE; virtual void DownloadFile(const std::string& resource_id, const std::string& local_file_md5, - const base::FilePath& local_file_path, const DownloadFileCallback& callback) OVERRIDE; virtual void UploadNewFile(const std::string& directory_resource_id, const base::FilePath& local_file_path, diff --git a/chrome/browser/sync_file_system/drive_backend/fake_api_util_unittest.cc b/chrome/browser/sync_file_system/drive_backend/fake_api_util_unittest.cc index 88a7ede..a0239cd 100644 --- a/chrome/browser/sync_file_system/drive_backend/fake_api_util_unittest.cc +++ b/chrome/browser/sync_file_system/drive_backend/fake_api_util_unittest.cc @@ -11,6 +11,7 @@ #include "base/message_loop/message_loop.h" #include "chrome/browser/google_apis/gdata_errorcode.h" #include "testing/gtest/include/gtest/gtest.h" +#include "webkit/common/blob/scoped_file.h" namespace sync_file_system { namespace drive_backend { @@ -22,7 +23,8 @@ void DidDownloadFile(google_apis::GDataErrorCode* error_out, google_apis::GDataErrorCode error, const std::string& file_md5, int64 file_size, - const base::Time& updated_time) { + const base::Time& updated_time, + scoped_ptr<webkit_blob::ScopedFile> downloaded_file) { *error_out = error; *file_md5_out = file_md5; } @@ -55,7 +57,6 @@ TEST(FakeAPIUtilTest, ChangeSquashTest) { std::string kMD5_1("md5 1"); std::string kMD5_2("md5 2"); std::string kMD5_3("md5 3"); - base::FilePath kTempFilePath(FILE_PATH_LITERAL("tmp_file")); api_util.PushRemoteChange(kParentResourceId, kParentTitle, @@ -97,7 +98,6 @@ TEST(FakeAPIUtilTest, ChangeSquashTest) { std::string md5; api_util.DownloadFile(kResourceId1, kMD5_1, - kTempFilePath, base::Bind(DidDownloadFile, &error, &md5)); message_loop.RunUntilIdle(); EXPECT_EQ(google_apis::HTTP_NOT_FOUND, error); diff --git a/chrome/browser/sync_file_system/drive_backend/remote_sync_delegate.cc b/chrome/browser/sync_file_system/drive_backend/remote_sync_delegate.cc index fa1cbc9..2377974 100644 --- a/chrome/browser/sync_file_system/drive_backend/remote_sync_delegate.cc +++ b/chrome/browser/sync_file_system/drive_backend/remote_sync_delegate.cc @@ -15,20 +15,6 @@ using fileapi::FileSystemURL; namespace { -bool CreateTemporaryFile(const base::FilePath& dir_path, - webkit_blob::ScopedFile* temp_file) { - base::FilePath temp_file_path; - const bool success = file_util::CreateDirectory(dir_path) && - file_util::CreateTemporaryFileInDir(dir_path, &temp_file_path); - if (!success) - return success; - *temp_file = - webkit_blob::ScopedFile(temp_file_path, - webkit_blob::ScopedFile::DELETE_ON_SCOPE_OUT, - base::MessageLoopProxy::current().get()); - return success; -} - void EmptyStatusCallback(sync_file_system::SyncStatusCode status) {} } // namespace @@ -201,25 +187,6 @@ void RemoteSyncDelegate::DeleteMetadata(const SyncStatusCallback& callback) { } void RemoteSyncDelegate::DownloadFile(const SyncStatusCallback& callback) { - content::BrowserThread::PostTaskAndReplyWithResult( - content::BrowserThread::FILE, FROM_HERE, - base::Bind(&CreateTemporaryFile, - sync_service_->temporary_file_dir_, - &temporary_file_), - base::Bind(&RemoteSyncDelegate::DidGetTemporaryFileForDownload, - AsWeakPtr(), callback)); -} - -void RemoteSyncDelegate::DidGetTemporaryFileForDownload( - const SyncStatusCallback& callback, - bool success) { - if (!success) { - AbortSync(callback, SYNC_FILE_ERROR_FAILED); - return; - } - - DCHECK(!temporary_file_.path().empty()); - // We should not use the md5 in metadata for FETCH type to avoid the download // finishes due to NOT_MODIFIED. std::string md5_checksum; @@ -229,7 +196,6 @@ void RemoteSyncDelegate::DidGetTemporaryFileForDownload( api_util()->DownloadFile( remote_change_.resource_id, md5_checksum, - temporary_file_.path(), base::Bind(&RemoteSyncDelegate::DidDownloadFile, AsWeakPtr(), callback)); @@ -240,7 +206,8 @@ void RemoteSyncDelegate::DidDownloadFile( google_apis::GDataErrorCode error, const std::string& md5_checksum, int64 file_size, - const base::Time& updated_time) { + const base::Time& updated_time, + scoped_ptr<webkit_blob::ScopedFile> downloaded_file) { if (error == google_apis::HTTP_NOT_MODIFIED) { sync_action_ = SYNC_ACTION_NONE; DidApplyRemoteChange(callback, SYNC_STATUS_OK); @@ -253,6 +220,7 @@ void RemoteSyncDelegate::DidDownloadFile( return; } + temporary_file_ = downloaded_file->Pass(); drive_metadata_.set_md5_checksum(md5_checksum); remote_change_processor()->ApplyRemoteChange( remote_file_change(), temporary_file_.path(), url(), diff --git a/chrome/browser/sync_file_system/drive_backend/remote_sync_delegate.h b/chrome/browser/sync_file_system/drive_backend/remote_sync_delegate.h index 5d8ccda..ff48cea 100644 --- a/chrome/browser/sync_file_system/drive_backend/remote_sync_delegate.h +++ b/chrome/browser/sync_file_system/drive_backend/remote_sync_delegate.h @@ -56,13 +56,12 @@ class RemoteSyncDelegate : public base::SupportsWeakPtr<RemoteSyncDelegate> { SyncStatusCode status); void DeleteMetadata(const SyncStatusCallback& callback); void DownloadFile(const SyncStatusCallback& callback); - void DidGetTemporaryFileForDownload(const SyncStatusCallback& callback, - bool success); void DidDownloadFile(const SyncStatusCallback& callback, google_apis::GDataErrorCode error, const std::string& md5_checksum, int64 file_size, - const base::Time& updated_time); + const base::Time& updated_time, + scoped_ptr<webkit_blob::ScopedFile> downloaded_file); void HandleConflict(const SyncStatusCallback& callback, SyncFileType remote_file_type); void HandleLocalWin(const SyncStatusCallback& callback); |