Commit 63bc983e authored by kinuko@chromium.org's avatar kinuko@chromium.org

Return AUTHENTICATION_FAILED error if Drive operation has failed and user is not signed in

BUG=163548
TEST=manual


Review URL: https://chromiumcodereview.appspot.com/11416279

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170554 0039d316-1c4b-4281-b951-d872f2087c98
parent d7e4a02f
...@@ -662,7 +662,7 @@ void DriveFileSyncService::DidGetSyncRootDirectory( ...@@ -662,7 +662,7 @@ void DriveFileSyncService::DidGetSyncRootDirectory(
const fileapi::SyncStatusCallback& callback, const fileapi::SyncStatusCallback& callback,
google_apis::GDataErrorCode error, google_apis::GDataErrorCode error,
const std::string& resource_id) { const std::string& resource_id) {
fileapi::SyncStatusCode status = GDataErrorCodeToSyncStatusCode(error); fileapi::SyncStatusCode status = GDataErrorCodeToSyncStatusCodeWrapper(error);
if (error != google_apis::HTTP_SUCCESS && if (error != google_apis::HTTP_SUCCESS &&
error != google_apis::HTTP_CREATED) { error != google_apis::HTTP_CREATED) {
NotifyTaskDone(status, token.Pass()); NotifyTaskDone(status, token.Pass());
...@@ -711,7 +711,8 @@ void DriveFileSyncService::DidGetDirectoryForOrigin( ...@@ -711,7 +711,8 @@ void DriveFileSyncService::DidGetDirectoryForOrigin(
const std::string& resource_id) { const std::string& resource_id) {
if (error != google_apis::HTTP_SUCCESS && if (error != google_apis::HTTP_SUCCESS &&
error != google_apis::HTTP_CREATED) { error != google_apis::HTTP_CREATED) {
fileapi::SyncStatusCode status = GDataErrorCodeToSyncStatusCode(error); fileapi::SyncStatusCode status =
GDataErrorCodeToSyncStatusCodeWrapper(error);
NotifyTaskDone(status, token.Pass()); NotifyTaskDone(status, token.Pass());
callback.Run(status); callback.Run(status);
return; return;
...@@ -734,7 +735,7 @@ void DriveFileSyncService::DidGetLargestChangeStampForBatchSync( ...@@ -734,7 +735,7 @@ void DriveFileSyncService::DidGetLargestChangeStampForBatchSync(
if (error != google_apis::HTTP_SUCCESS) { if (error != google_apis::HTTP_SUCCESS) {
pending_batch_sync_origins_.insert(origin); pending_batch_sync_origins_.insert(origin);
// TODO(tzik): Refine this error code. // TODO(tzik): Refine this error code.
NotifyTaskDone(GDataErrorCodeToSyncStatusCode(error), token.Pass()); NotifyTaskDone(GDataErrorCodeToSyncStatusCodeWrapper(error), token.Pass());
return; return;
} }
...@@ -756,7 +757,7 @@ void DriveFileSyncService::DidGetDirectoryContentForBatchSync( ...@@ -756,7 +757,7 @@ void DriveFileSyncService::DidGetDirectoryContentForBatchSync(
if (error != google_apis::HTTP_SUCCESS) { if (error != google_apis::HTTP_SUCCESS) {
pending_batch_sync_origins_.insert(origin); pending_batch_sync_origins_.insert(origin);
// TODO(tzik): Refine this error code. // TODO(tzik): Refine this error code.
NotifyTaskDone(GDataErrorCodeToSyncStatusCode(error), token.Pass()); NotifyTaskDone(GDataErrorCodeToSyncStatusCodeWrapper(error), token.Pass());
return; return;
} }
...@@ -797,7 +798,7 @@ void DriveFileSyncService::DidGetRemoteFileMetadata( ...@@ -797,7 +798,7 @@ void DriveFileSyncService::DidGetRemoteFileMetadata(
file_type = fileapi::SYNC_FILE_TYPE_FILE; file_type = fileapi::SYNC_FILE_TYPE_FILE;
else if (entry->is_folder()) else if (entry->is_folder())
file_type = fileapi::SYNC_FILE_TYPE_DIRECTORY; file_type = fileapi::SYNC_FILE_TYPE_DIRECTORY;
callback.Run(GDataErrorCodeToSyncStatusCode(error), callback.Run(GDataErrorCodeToSyncStatusCodeWrapper(error),
fileapi::SyncFileMetadata(file_type, fileapi::SyncFileMetadata(file_type,
entry->file_size(), entry->file_size(),
entry->updated_time())); entry->updated_time()));
...@@ -869,8 +870,8 @@ void DriveFileSyncService::DidApplyLocalChange( ...@@ -869,8 +870,8 @@ void DriveFileSyncService::DidApplyLocalChange(
fileapi::SyncStatusCode status) { fileapi::SyncStatusCode status) {
if (status == fileapi::SYNC_STATUS_OK) { if (status == fileapi::SYNC_STATUS_OK) {
CancelRemoteChange(url); CancelRemoteChange(url);
NotifyTaskDone(GDataErrorCodeToSyncStatusCode(error), token.Pass()); NotifyTaskDone(GDataErrorCodeToSyncStatusCodeWrapper(error), token.Pass());
callback.Run(GDataErrorCodeToSyncStatusCode(error)); callback.Run(GDataErrorCodeToSyncStatusCodeWrapper(error));
return; return;
} }
NotifyTaskDone(status, token.Pass()); NotifyTaskDone(status, token.Pass());
...@@ -896,7 +897,8 @@ void DriveFileSyncService::DidUploadNewFile( ...@@ -896,7 +897,8 @@ void DriveFileSyncService::DidUploadNewFile(
AsWeakPtr(), base::Passed(&token), url, error, callback)); AsWeakPtr(), base::Passed(&token), url, error, callback));
return; return;
} }
const fileapi::SyncStatusCode status = GDataErrorCodeToSyncStatusCode(error); const fileapi::SyncStatusCode status =
GDataErrorCodeToSyncStatusCodeWrapper(error);
NotifyTaskDone(status, token.Pass()); NotifyTaskDone(status, token.Pass());
callback.Run(status); callback.Run(status);
} }
...@@ -939,7 +941,7 @@ void DriveFileSyncService::DidUploadExistingFile( ...@@ -939,7 +941,7 @@ void DriveFileSyncService::DidUploadExistingFile(
} }
default: { default: {
const fileapi::SyncStatusCode status = const fileapi::SyncStatusCode status =
GDataErrorCodeToSyncStatusCode(error); GDataErrorCodeToSyncStatusCodeWrapper(error);
DCHECK_NE(fileapi::SYNC_STATUS_OK, status); DCHECK_NE(fileapi::SYNC_STATUS_OK, status);
DidApplyLocalChange(token.Pass(), url, error, callback, status); DidApplyLocalChange(token.Pass(), url, error, callback, status);
return; return;
...@@ -973,7 +975,7 @@ void DriveFileSyncService::DidDeleteFile( ...@@ -973,7 +975,7 @@ void DriveFileSyncService::DidDeleteFile(
} }
default: { default: {
const fileapi::SyncStatusCode status = const fileapi::SyncStatusCode status =
GDataErrorCodeToSyncStatusCode(error); GDataErrorCodeToSyncStatusCodeWrapper(error);
DCHECK_NE(fileapi::SYNC_STATUS_OK, status); DCHECK_NE(fileapi::SYNC_STATUS_OK, status);
DidApplyLocalChange(token.Pass(), url, error, callback, status); DidApplyLocalChange(token.Pass(), url, error, callback, status);
return; return;
...@@ -1143,7 +1145,7 @@ void DriveFileSyncService::DidDownloadFile( ...@@ -1143,7 +1145,7 @@ void DriveFileSyncService::DidDownloadFile(
return; return;
} }
fileapi::SyncStatusCode status = GDataErrorCodeToSyncStatusCode(error); fileapi::SyncStatusCode status = GDataErrorCodeToSyncStatusCodeWrapper(error);
if (status != fileapi::SYNC_STATUS_OK) { if (status != fileapi::SYNC_STATUS_OK) {
AbortRemoteSync(param.Pass(), status); AbortRemoteSync(param.Pass(), status);
return; return;
...@@ -1324,4 +1326,13 @@ bool DriveFileSyncService::GetPendingChangeForFileSystemURL( ...@@ -1324,4 +1326,13 @@ bool DriveFileSyncService::GetPendingChangeForFileSystemURL(
return true; return true;
} }
fileapi::SyncStatusCode
DriveFileSyncService::GDataErrorCodeToSyncStatusCodeWrapper(
google_apis::GDataErrorCode error) const {
fileapi::SyncStatusCode status = GDataErrorCodeToSyncStatusCode(error);
if (status != fileapi::SYNC_STATUS_OK && !sync_client_->IsAuthenticated())
return fileapi::SYNC_STATUS_AUTHENTICATION_FAILED;
return status;
}
} // namespace sync_file_system } // namespace sync_file_system
...@@ -287,6 +287,11 @@ class DriveFileSyncService ...@@ -287,6 +287,11 @@ class DriveFileSyncService
bool GetPendingChangeForFileSystemURL(const fileapi::FileSystemURL& url, bool GetPendingChangeForFileSystemURL(const fileapi::FileSystemURL& url,
RemoteChange* change) const; RemoteChange* change) const;
// A wrapper implementation to GDataErrorCodeToSyncStatusCode which returns
// authentication error if the user is not signed in.
fileapi::SyncStatusCode GDataErrorCodeToSyncStatusCodeWrapper(
google_apis::GDataErrorCode error) const;
FilePath temporary_file_dir_; FilePath temporary_file_dir_;
scoped_ptr<DriveMetadataStore> metadata_store_; scoped_ptr<DriveMetadataStore> metadata_store_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment