Skip to content

Commit

Permalink
[SyncFS] Expand simple functions to their caller in drive_backend/
Browse files Browse the repository at this point in the history
These functions used to be called asynchronously, and recently switched to be synchronous.
Then it's more readable to expand them to their caller.

BUG=412367

Review URL: https://codereview.chromium.org/560703002

Cr-Commit-Position: refs/heads/master@{#294140}
  • Loading branch information
tzik authored and Commit bot committed Sep 10, 2014
1 parent 90a0908 commit 34bdc6d
Show file tree
Hide file tree
Showing 10 changed files with 6 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,6 @@ void FolderCreator::DidListFolders(
std::string file_id = oldest->file_id();

status = metadata_database_->UpdateByFileResourceList(candidates.Pass());

// TODO(tzik): Expand this function.
DidUpdateDatabase(file_id, callback, status);
}

void FolderCreator::DidUpdateDatabase(const std::string& file_id,
const FileIDCallback& callback,
SyncStatusCode status) {
if (status != SYNC_STATUS_OK) {
callback.Run(std::string(), status);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ class FolderCreator {
ScopedVector<google_apis::FileResource> candidates,
google_apis::GDataErrorCode error,
scoped_ptr<google_apis::FileList> file_list);
void DidUpdateDatabase(const std::string& file_id,
const FileIDCallback& callback,
SyncStatusCode status);

drive::DriveServiceInterface* drive_service_;
MetadataDatabase* metadata_database_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,6 @@ void ListChangesTask::CheckInChangeList(int64 largest_change_id,
SyncStatusCode status =
metadata_database()->UpdateByChangeList(
largest_change_id, change_list_.Pass());

// TODO(tzik): Expand this function.
DidCheckInChangeList(token.Pass(), status);
}

void ListChangesTask::DidCheckInChangeList(scoped_ptr<SyncTaskToken> token,
SyncStatusCode status) {
if (status != SYNC_STATUS_OK) {
SyncTaskManager::NotifyTaskDone(token.Pass(), status);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ class ListChangesTask : public SyncTask {
scoped_ptr<google_apis::ChangeList> change_list);
void CheckInChangeList(int64 largest_change_id,
scoped_ptr<SyncTaskToken> token);
void DidCheckInChangeList(scoped_ptr<SyncTaskToken> token,
SyncStatusCode status);

bool IsContextReady();
MetadataDatabase* metadata_database();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -548,14 +548,6 @@ void LocalToRemoteSyncer::DidUploadExistingFile(

DCHECK(entry);
status = metadata_database()->UpdateByFileResource(*entry);

// TODO(tzik): Expand this function.
DidUpdateDatabaseForUploadExistingFile(token.Pass(), status);
}

void LocalToRemoteSyncer::DidUpdateDatabaseForUploadExistingFile(
scoped_ptr<SyncTaskToken> token,
SyncStatusCode status) {
if (status != SYNC_STATUS_OK) {
SyncCompleted(token.Pass(), status);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@ class LocalToRemoteSyncer : public SyncTask {
google_apis::GDataErrorCode error,
const GURL&,
scoped_ptr<google_apis::FileResource>);
void DidUpdateDatabaseForUploadExistingFile(
scoped_ptr<SyncTaskToken> token,
SyncStatusCode status);
void UpdateRemoteMetadata(const std::string& file_id,
scoped_ptr<SyncTaskToken> token);
void DidGetRemoteMetadata(const std::string& file_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,13 +328,6 @@ void RemoteToLocalSyncer::DidGetRemoteMetadata(
}

status = metadata_database()->UpdateByFileResource(*entry);
// TODO(tzik): Expand this function.
DidUpdateDatabaseForRemoteMetadata(token.Pass(), status);
}

void RemoteToLocalSyncer::DidUpdateDatabaseForRemoteMetadata(
scoped_ptr<SyncTaskToken> token,
SyncStatusCode status) {
if (status != SYNC_STATUS_OK) {
SyncCompleted(token.Pass(), status);
return;
Expand Down Expand Up @@ -629,7 +622,6 @@ void RemoteToLocalSyncer::SyncCompleted(scoped_ptr<SyncTaskToken> token,

status = metadata_database()->UpdateTracker(
dirty_tracker_->tracker_id(), updated_details);
// TODO(tzik): Expand this function.
FinalizeSync(token.Pass(), status);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ class RemoteToLocalSyncer : public SyncTask {
void DidGetRemoteMetadata(scoped_ptr<SyncTaskToken> token,
google_apis::GDataErrorCode error,
scoped_ptr<google_apis::FileResource> entry);
void DidUpdateDatabaseForRemoteMetadata(scoped_ptr<SyncTaskToken> token,
SyncStatusCode status);

// This implements the body of the HandleNewFile and HandleContentUpdate.
// If the file doesn't have corresponding local file:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,27 +88,16 @@ void SyncEngineInitializer::RunPreflight(scoped_ptr<SyncTaskToken> token) {
SyncStatusCode status = SYNC_STATUS_FAILED;
scoped_ptr<MetadataDatabase> metadata_database =
MetadataDatabase::Create(database_path_, env_override_, &status);
// TODO(tzik): Expand this function.
DidCreateMetadataDatabase(token.Pass(), status, metadata_database.Pass());
}

scoped_ptr<MetadataDatabase> SyncEngineInitializer::PassMetadataDatabase() {
return metadata_database_.Pass();
}

void SyncEngineInitializer::DidCreateMetadataDatabase(
scoped_ptr<SyncTaskToken> token,
SyncStatusCode status,
scoped_ptr<MetadataDatabase> instance) {
if (status != SYNC_STATUS_OK) {
util::Log(logging::LOG_VERBOSE, FROM_HERE,
"[Initialize] Failed to initialize MetadataDatabase.");
SyncTaskManager::NotifyTaskDone(token.Pass(), status);
return;
}

DCHECK(instance);
metadata_database_ = instance.Pass();
DCHECK(metadata_database);
metadata_database_ = metadata_database.Pass();
if (metadata_database_->HasSyncRoot()) {
util::Log(logging::LOG_VERBOSE, FROM_HERE,
"[Initialize] Found local cache of sync-root.");
Expand All @@ -119,6 +108,10 @@ void SyncEngineInitializer::DidCreateMetadataDatabase(
GetAboutResource(token.Pass());
}

scoped_ptr<MetadataDatabase> SyncEngineInitializer::PassMetadataDatabase() {
return metadata_database_.Pass();
}

void SyncEngineInitializer::GetAboutResource(
scoped_ptr<SyncTaskToken> token) {
set_used_network(true);
Expand Down Expand Up @@ -348,13 +341,6 @@ void SyncEngineInitializer::PopulateDatabase(
DCHECK(sync_root_folder_);
SyncStatusCode status = metadata_database_->PopulateInitialData(
largest_change_id_, *sync_root_folder_, app_root_folders_);
// TODO(tzik): Expand this function.
DidPopulateDatabase(token.Pass(), status);
}

void SyncEngineInitializer::DidPopulateDatabase(
scoped_ptr<SyncTaskToken> token,
SyncStatusCode status) {
if (status != SYNC_STATUS_OK) {
util::Log(logging::LOG_VERBOSE, FROM_HERE,
"[Initialize] Failed to populate initial data"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@ class SyncEngineInitializer : public SyncTask {
private:
typedef base::Callback<void(const SyncStatusCallback& callback)> Task;

void DidCreateMetadataDatabase(scoped_ptr<SyncTaskToken> token,
SyncStatusCode status,
scoped_ptr<MetadataDatabase> instance);

void GetAboutResource(scoped_ptr<SyncTaskToken> token);
void DidGetAboutResource(
scoped_ptr<SyncTaskToken> token,
Expand All @@ -103,8 +99,6 @@ class SyncEngineInitializer : public SyncTask {
google_apis::GDataErrorCode error,
scoped_ptr<google_apis::FileList> file_list);
void PopulateDatabase(scoped_ptr<SyncTaskToken> token);
void DidPopulateDatabase(scoped_ptr<SyncTaskToken> token,
SyncStatusCode status);

SyncEngineContext* sync_context_; // Not owned.
leveldb::Env* env_override_;
Expand Down

0 comments on commit 34bdc6d

Please sign in to comment.