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 <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "google_apis/drive/drive_api_parser.h" | 30 #include "google_apis/drive/drive_api_parser.h" |
31 #include "net/base/mime_util.h" | 31 #include "net/base/mime_util.h" |
32 #include "storage/common/fileapi/file_system_util.h" | 32 #include "storage/common/fileapi/file_system_util.h" |
33 | 33 |
34 namespace sync_file_system { | 34 namespace sync_file_system { |
35 namespace drive_backend { | 35 namespace drive_backend { |
36 | 36 |
37 namespace { | 37 namespace { |
38 | 38 |
39 scoped_ptr<FileTracker> FindTrackerByID(MetadataDatabase* metadata_database, | 39 scoped_ptr<FileTracker> FindTrackerByID(MetadataDatabase* metadata_database, |
40 int64 tracker_id) { | 40 int64_t tracker_id) { |
41 scoped_ptr<FileTracker> tracker(new FileTracker); | 41 scoped_ptr<FileTracker> tracker(new FileTracker); |
42 if (metadata_database->FindTrackerByTrackerID(tracker_id, tracker.get())) | 42 if (metadata_database->FindTrackerByTrackerID(tracker_id, tracker.get())) |
43 return tracker.Pass(); | 43 return tracker.Pass(); |
44 return scoped_ptr<FileTracker>(); | 44 return scoped_ptr<FileTracker>(); |
45 } | 45 } |
46 | 46 |
47 bool GetKnownChangeID(MetadataDatabase* metadata_database, | 47 bool GetKnownChangeID(MetadataDatabase* metadata_database, |
48 const std::string& file_id, | 48 const std::string& file_id, |
49 int64* change_id) { | 49 int64_t* change_id) { |
50 FileMetadata remote_file_metadata; | 50 FileMetadata remote_file_metadata; |
51 if (!metadata_database->FindFileByFileID(file_id, &remote_file_metadata)) | 51 if (!metadata_database->FindFileByFileID(file_id, &remote_file_metadata)) |
52 return false; | 52 return false; |
53 *change_id = remote_file_metadata.details().change_id(); | 53 *change_id = remote_file_metadata.details().change_id(); |
54 return true; | 54 return true; |
55 } | 55 } |
56 | 56 |
57 bool IsLocalFileMissing(const SyncFileMetadata& local_metadata, | 57 bool IsLocalFileMissing(const SyncFileMetadata& local_metadata, |
58 const FileChange& local_change) { | 58 const FileChange& local_change) { |
59 return local_metadata.file_type == SYNC_FILE_TYPE_UNKNOWN || | 59 return local_metadata.file_type == SYNC_FILE_TYPE_UNKNOWN || |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 // PrepareForProcessRemoteChange() since it should be blocked in | 288 // PrepareForProcessRemoteChange() since it should be blocked in |
289 // LocalFileSyncService. | 289 // LocalFileSyncService. |
290 // - For ListChangesTask, it may update FileMetatada together with |change_id| | 290 // - For ListChangesTask, it may update FileMetatada together with |change_id| |
291 // and may delete FileTracker. So, ensure |change_id| is not changed and | 291 // and may delete FileTracker. So, ensure |change_id| is not changed and |
292 // check if FileTracker still exists. | 292 // check if FileTracker still exists. |
293 // - For UninstallAppTask, it may also delete FileMetadata and FileTracker. | 293 // - For UninstallAppTask, it may also delete FileMetadata and FileTracker. |
294 // Check if FileTracker still exists. | 294 // Check if FileTracker still exists. |
295 // - Others, SyncEngineInitializer and RegisterAppTask doesn't affect to | 295 // - Others, SyncEngineInitializer and RegisterAppTask doesn't affect to |
296 // LocalToRemoteSyncer. | 296 // LocalToRemoteSyncer. |
297 if (remote_file_tracker_) { | 297 if (remote_file_tracker_) { |
298 int64 latest_change_id = 0; | 298 int64_t latest_change_id = 0; |
299 if (!GetKnownChangeID(metadata_database(), | 299 if (!GetKnownChangeID(metadata_database(), |
300 remote_file_tracker_->file_id(), | 300 remote_file_tracker_->file_id(), |
301 &latest_change_id) || | 301 &latest_change_id) || |
302 latest_change_id > remote_file_change_id_) { | 302 latest_change_id > remote_file_change_id_) { |
303 SyncCompleted(token.Pass(), SYNC_STATUS_RETRY); | 303 SyncCompleted(token.Pass(), SYNC_STATUS_RETRY); |
304 return; | 304 return; |
305 } | 305 } |
306 | 306 |
307 if (!metadata_database()->FindTrackerByTrackerID( | 307 if (!metadata_database()->FindTrackerByTrackerID( |
308 remote_file_tracker_->tracker_id(), nullptr)) { | 308 remote_file_tracker_->tracker_id(), nullptr)) { |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 set_used_network(true); | 759 set_used_network(true); |
760 return sync_context_->GetDriveUploader(); | 760 return sync_context_->GetDriveUploader(); |
761 } | 761 } |
762 | 762 |
763 MetadataDatabase* LocalToRemoteSyncer::metadata_database() { | 763 MetadataDatabase* LocalToRemoteSyncer::metadata_database() { |
764 return sync_context_->GetMetadataDatabase(); | 764 return sync_context_->GetMetadataDatabase(); |
765 } | 765 } |
766 | 766 |
767 } // namespace drive_backend | 767 } // namespace drive_backend |
768 } // namespace sync_file_system | 768 } // namespace sync_file_system |
OLD | NEW |