| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer.h
" | 5 #include "chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer.h
" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 remote_file_tracker_->synced_details().etag(), | 160 remote_file_tracker_->synced_details().etag(), |
| 161 base::Bind(&LocalToRemoteSyncer::DidDeleteRemoteFile, | 161 base::Bind(&LocalToRemoteSyncer::DidDeleteRemoteFile, |
| 162 weak_ptr_factory_.GetWeakPtr(), | 162 weak_ptr_factory_.GetWeakPtr(), |
| 163 callback)); | 163 callback)); |
| 164 return; | 164 return; |
| 165 } | 165 } |
| 166 | 166 |
| 167 DCHECK(local_change_.IsAddOrUpdate()); | 167 DCHECK(local_change_.IsAddOrUpdate()); |
| 168 DCHECK(local_change_.file_type() == SYNC_FILE_TYPE_FILE || | 168 DCHECK(local_change_.file_type() == SYNC_FILE_TYPE_FILE || |
| 169 local_change_.file_type() == SYNC_FILE_TYPE_DIRECTORY); | 169 local_change_.file_type() == SYNC_FILE_TYPE_DIRECTORY); |
| 170 |
| 171 const FileDetails& synced_details = remote_file_tracker_->synced_details(); |
| 172 DCHECK(synced_details.file_kind() == FILE_KIND_FILE || |
| 173 synced_details.file_kind() == FILE_KIND_FOLDER); |
| 170 if (local_change_.file_type() == SYNC_FILE_TYPE_FILE) { | 174 if (local_change_.file_type() == SYNC_FILE_TYPE_FILE) { |
| 171 UploadExistingFile(callback); | 175 if (synced_details.file_kind() == FILE_KIND_FILE) { |
| 176 // Non-conflicting local file update to existing remote regular file. |
| 177 UploadExistingFile(callback); |
| 178 return; |
| 179 } |
| 180 |
| 181 DCHECK_EQ(FILE_KIND_FOLDER, synced_details.file_kind()); |
| 182 // Non-conflicting local file update to existing remote *folder*. |
| 183 // Our policy prioritize the folder on this case. |
| 184 // Do nothing to remote folder and mark the tracker dirty to defer it to |
| 185 // next remote-to-local sync phase. |
| 186 metadata_database()->MarkTrackerDirty(remote_file_tracker_->tracker_id(), |
| 187 callback); |
| 172 return; | 188 return; |
| 173 } | 189 } |
| 174 | 190 |
| 175 NOTIMPLEMENTED(); | 191 DCHECK_EQ(SYNC_FILE_TYPE_DIRECTORY, local_change_.file_type()); |
| 176 callback.Run(SYNC_STATUS_FAILED); | 192 if (synced_details.file_kind() == FILE_KIND_FILE) { |
| 193 // Non-conflicting local folder creation to existing remote *file*. |
| 194 // Our policy prioritize the folder on this case. |
| 195 // TODO(tzik): Delete remote file and create a folder at the path. |
| 196 NOTIMPLEMENTED(); |
| 197 callback.Run(SYNC_STATUS_FAILED); |
| 198 return; |
| 199 } |
| 200 |
| 201 // Non-conflicting local folder creation to existing remote folder. |
| 202 DCHECK_EQ(FILE_KIND_FOLDER, synced_details.file_kind()); |
| 203 callback.Run(SYNC_STATUS_OK); |
| 177 } | 204 } |
| 178 | 205 |
| 179 void LocalToRemoteSyncer::DidDeleteRemoteFile( | 206 void LocalToRemoteSyncer::DidDeleteRemoteFile( |
| 180 const SyncStatusCallback& callback, | 207 const SyncStatusCallback& callback, |
| 181 google_apis::GDataErrorCode error) { | 208 google_apis::GDataErrorCode error) { |
| 182 if (error != google_apis::HTTP_SUCCESS && | 209 if (error != google_apis::HTTP_SUCCESS && |
| 183 error != google_apis::HTTP_NOT_FOUND && | 210 error != google_apis::HTTP_NOT_FOUND && |
| 184 error != google_apis::HTTP_PRECONDITION) { | 211 error != google_apis::HTTP_PRECONDITION) { |
| 185 callback.Run(GDataErrorCodeToSyncStatusCode(error)); | 212 callback.Run(GDataErrorCodeToSyncStatusCode(error)); |
| 186 return; | 213 return; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 drive::DriveUploaderInterface* LocalToRemoteSyncer::drive_uploader() { | 304 drive::DriveUploaderInterface* LocalToRemoteSyncer::drive_uploader() { |
| 278 return sync_context_->GetDriveUploader(); | 305 return sync_context_->GetDriveUploader(); |
| 279 } | 306 } |
| 280 | 307 |
| 281 MetadataDatabase* LocalToRemoteSyncer::metadata_database() { | 308 MetadataDatabase* LocalToRemoteSyncer::metadata_database() { |
| 282 return sync_context_->GetMetadataDatabase(); | 309 return sync_context_->GetMetadataDatabase(); |
| 283 } | 310 } |
| 284 | 311 |
| 285 } // namespace drive_backend | 312 } // namespace drive_backend |
| 286 } // namespace sync_file_system | 313 } // namespace sync_file_system |
| OLD | NEW |