| 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/remote_to_local_syncer.h
" | 5 #include "chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer.h
" |
| 6 | 6 |
| 7 #include <stdint.h> |
| 8 |
| 9 #include <limits> |
| 10 |
| 7 #include "base/bind.h" | 11 #include "base/bind.h" |
| 8 #include "base/callback.h" | 12 #include "base/callback.h" |
| 9 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
| 10 #include "base/format_macros.h" | 14 #include "base/format_macros.h" |
| 11 #include "base/location.h" | 15 #include "base/location.h" |
| 12 #include "base/logging.h" | 16 #include "base/logging.h" |
| 13 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
| 14 #include "base/task_runner_util.h" | 18 #include "base/task_runner_util.h" |
| 15 #include "chrome/browser/sync_file_system/drive_backend/callback_helper.h" | 19 #include "chrome/browser/sync_file_system/drive_backend/callback_helper.h" |
| 16 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_util.h" | 20 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_util.h" |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 | 350 |
| 347 FileTracker latest_dirty_tracker; | 351 FileTracker latest_dirty_tracker; |
| 348 if (!metadata_database()->FindTrackerByTrackerID( | 352 if (!metadata_database()->FindTrackerByTrackerID( |
| 349 dirty_tracker_->tracker_id(), &latest_dirty_tracker) || | 353 dirty_tracker_->tracker_id(), &latest_dirty_tracker) || |
| 350 dirty_tracker_->active() != latest_dirty_tracker.active() || | 354 dirty_tracker_->active() != latest_dirty_tracker.active() || |
| 351 !latest_dirty_tracker.dirty()) { | 355 !latest_dirty_tracker.dirty()) { |
| 352 SyncCompleted(token.Pass(), SYNC_STATUS_RETRY); | 356 SyncCompleted(token.Pass(), SYNC_STATUS_RETRY); |
| 353 return; | 357 return; |
| 354 } | 358 } |
| 355 | 359 |
| 356 int64 current_change_id = kint64min; | 360 int64_t current_change_id = std::numeric_limits<int64_t>::min(); |
| 357 int64 latest_change_id = kint64min; | 361 int64_t latest_change_id = std::numeric_limits<int64_t>::min(); |
| 358 if (dirty_tracker_->has_synced_details()) | 362 if (dirty_tracker_->has_synced_details()) |
| 359 current_change_id = dirty_tracker_->synced_details().change_id(); | 363 current_change_id = dirty_tracker_->synced_details().change_id(); |
| 360 if (latest_dirty_tracker.has_synced_details()) | 364 if (latest_dirty_tracker.has_synced_details()) |
| 361 latest_change_id = latest_dirty_tracker.synced_details().change_id(); | 365 latest_change_id = latest_dirty_tracker.synced_details().change_id(); |
| 362 if (current_change_id != latest_change_id) { | 366 if (current_change_id != latest_change_id) { |
| 363 SyncCompleted(token.Pass(), SYNC_STATUS_RETRY); | 367 SyncCompleted(token.Pass(), SYNC_STATUS_RETRY); |
| 364 return; | 368 return; |
| 365 } | 369 } |
| 366 | 370 |
| 367 FileMetadata latest_file_metadata; | 371 FileMetadata latest_file_metadata; |
| 368 if (metadata_database()->FindFileByFileID(dirty_tracker_->file_id(), | 372 if (metadata_database()->FindFileByFileID(dirty_tracker_->file_id(), |
| 369 &latest_file_metadata)) { | 373 &latest_file_metadata)) { |
| 370 if (!remote_metadata_) { | 374 if (!remote_metadata_) { |
| 371 SyncCompleted(token.Pass(), SYNC_STATUS_RETRY); | 375 SyncCompleted(token.Pass(), SYNC_STATUS_RETRY); |
| 372 return; | 376 return; |
| 373 } | 377 } |
| 374 | 378 |
| 375 int64 change_id = remote_metadata_->details().change_id(); | 379 int64_t change_id = remote_metadata_->details().change_id(); |
| 376 int64 latest_change_id = latest_file_metadata.details().change_id(); | 380 int64_t latest_change_id = latest_file_metadata.details().change_id(); |
| 377 if (change_id != latest_change_id) { | 381 if (change_id != latest_change_id) { |
| 378 SyncCompleted(token.Pass(), SYNC_STATUS_RETRY); | 382 SyncCompleted(token.Pass(), SYNC_STATUS_RETRY); |
| 379 return; | 383 return; |
| 380 } | 384 } |
| 381 } else { | 385 } else { |
| 382 if (remote_metadata_) { | 386 if (remote_metadata_) { |
| 383 SyncCompleted(token.Pass(), SYNC_STATUS_RETRY); | 387 SyncCompleted(token.Pass(), SYNC_STATUS_RETRY); |
| 384 return; | 388 return; |
| 385 } | 389 } |
| 386 } | 390 } |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 860 | 864 |
| 861 SyncStatusCallback RemoteToLocalSyncer::SyncCompletedCallback( | 865 SyncStatusCallback RemoteToLocalSyncer::SyncCompletedCallback( |
| 862 scoped_ptr<SyncTaskToken> token) { | 866 scoped_ptr<SyncTaskToken> token) { |
| 863 return base::Bind(&RemoteToLocalSyncer::SyncCompleted, | 867 return base::Bind(&RemoteToLocalSyncer::SyncCompleted, |
| 864 weak_ptr_factory_.GetWeakPtr(), | 868 weak_ptr_factory_.GetWeakPtr(), |
| 865 base::Passed(&token)); | 869 base::Passed(&token)); |
| 866 } | 870 } |
| 867 | 871 |
| 868 } // namespace drive_backend | 872 } // namespace drive_backend |
| 869 } // namespace sync_file_system | 873 } // namespace sync_file_system |
| OLD | NEW |