Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer.h

Issue 58953003: [SyncFS] Refine RemoteToLocalSyncer resolver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: buildfix Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_REMOTE_TO_LOCAL_SYNCER_H_ 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_REMOTE_TO_LOCAL_SYNCER_H_
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_REMOTE_TO_LOCAL_SYNCER_H_ 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_REMOTE_TO_LOCAL_SYNCER_H_
7 7
8 #include "base/memory/weak_ptr.h" 8 #include "base/memory/weak_ptr.h"
9 #include "chrome/browser/google_apis/gdata_errorcode.h" 9 #include "chrome/browser/google_apis/gdata_errorcode.h"
10 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.pb.h" 10 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.pb.h"
(...skipping 23 matching lines...) Expand all
34 PRIORITY_NORMAL = 1 << 0, 34 PRIORITY_NORMAL = 1 << 0,
35 PRIORITY_LOW = 1 << 1, 35 PRIORITY_LOW = 1 << 1,
36 }; 36 };
37 37
38 // |priorities| must be a bitwise-or'd value of Priority. 38 // |priorities| must be a bitwise-or'd value of Priority.
39 // Conflicting trackers will have low priority for RemoteToLocalSyncer so that 39 // Conflicting trackers will have low priority for RemoteToLocalSyncer so that
40 // it should be resolved by LocatToRemoteSyncer. 40 // it should be resolved by LocatToRemoteSyncer.
41 RemoteToLocalSyncer(SyncEngineContext* sync_context, 41 RemoteToLocalSyncer(SyncEngineContext* sync_context,
42 int priorities); 42 int priorities);
43 virtual ~RemoteToLocalSyncer(); 43 virtual ~RemoteToLocalSyncer();
44
44 virtual void Run(const SyncStatusCallback& callback) OVERRIDE; 45 virtual void Run(const SyncStatusCallback& callback) OVERRIDE;
45 46
46 private: 47 private:
47 void AnalyzeCurrentDirtyTracker(); 48 // Dispatches remote change to handlers or to SyncCompleted() directly.
48 49 // This function uses information only in MetadataDatabase.
50 //
51 // If the tracker doesn't have remote metadata:
52 // # The file is listed in a folder right before this operation.
53 // - Dispatch to HandleMissingRemoteMetadata to fetch remote metadata.
54 // Else, if the tracker is not active or the dominating app-root is disabled:
55 // # Assume the file has remote metadata.
56 // - Dispatch to HandleInactiveTracker() to resolve offline solvable
57 // dirtiness.
58 // Else, if the tracker doesn't have synced metadata:
59 // # Assume the tracker has remote metadata and the tracker is active.
60 // # The tracker is not yet synced ever.
61 // - If the file is remotely deleted, do nothing to local file and dispatch
62 // directly to SyncCompleted().
63 // - Else, if the file is a regular file, dispatch to HandleNewFile().
64 // - Else, if the file is a folder, dispatch to HandleNewFolder().
65 // - Else, the file should be an unsupported active file. This should not
66 // happen.
67 // Else, if the remote metadata is marked as deleted:
68 // # Most of the remote metadata is missing including title, kind and md5.
69 // - Dispatch to HandleDeletion().
70 // Else, if the tracker has different titles between its synced metadata and
71 // remote metadata:
72 // # Assume the tracker is active and has remote metetadata and synced
73 // metadata.
74 // # The file is remotely renamed.
75 // # Maybe, this can be decomposed to delete and update.
76 // - Dispatch to HandleRemoteRename().
77 // Else, if the tracker's parent is not a parent of the remote metadata:
78 // # The file has reorganized.
79 // # Maybe, this can be decomposed to delete and update.
80 // - Dispatch to HandreReorganize().
81 // Else, if the folder is a regular file and the md5 in remote metadata does
82 // not match the md5 in synced metadata:
83 // # The file is modified remotely.
84 // - Dispatch to HandleContentUpdate().
85 // Else, if the tracker is a folder and it has needs_folder_listing flag:
86 // - Dispatch to HandleFolderContentListing()
87 // Else, there should be no change to sync.
88 // - Dispatch to HandleOfflineSolvable()
49 void ResolveRemoteChange(const SyncStatusCallback& callback); 89 void ResolveRemoteChange(const SyncStatusCallback& callback);
50 90
51 void GetRemoteResource(const SyncStatusCallback& callback); 91 // Handles missing remote metadata case.
52 void DidGetRemoteResource(const SyncStatusCallback& callback, 92 // Fetches remote metadata and updates MetadataDatabase by that. The sync
93 // operation itself will be deferred to the next sync round.
94 // Note: if the file is not found, it should be handled as if deleted.
95 void HandleMissingRemoteMetadata(const SyncStatusCallback& callback);
96 void DidGetRemoteMetadata(const SyncStatusCallback& callback,
53 int64 change_id, 97 int64 change_id,
54 google_apis::GDataErrorCode error, 98 google_apis::GDataErrorCode error,
55 scoped_ptr<google_apis::ResourceEntry> entry); 99 scoped_ptr<google_apis::ResourceEntry> entry);
100 void DidUpdateDatabaseForRemoteMetadata(const SyncStatusCallback& callback,
101 SyncStatusCode status);
56 102
103 // Handles modification to inactive or disabled-app tracker.
104 // TODO(tzik): Write details and implement this.
105 void HandleInactiveTracker(const SyncStatusCallback& callback);
106
107 // Handles remotely added file. Needs Prepare() call.
108 // TODO(tzik): Write details and implement this.
109 void HandleNewFile(const SyncStatusCallback& callback);
110 void DidPrepareForNewFile(const SyncStatusCallback& callback,
111 SyncStatusCode status);
112
113 // Handles remotely added folder. Needs Prepare() call.
114 // TODO(tzik): Write details and implement this.
115 void HandleNewFolder(const SyncStatusCallback& callback);
116
117 // Handles deleted remote file. Needs Prepare() call.
118 // If the deleted tracker is the sync-root:
119 // - TODO(tzik): Needs special handling.
120 // Else, if the deleted tracker is a app-root:
121 // - TODO(tzik): Needs special handling.
122 // Else, if the local file is already deleted:
123 // - Do nothing anymore to the local, call SyncCompleted().
124 // Else, if the local file is modified:
125 // - Do nothing to the local file, call SyncCompleted().
126 // Else, if the local file is not modified:
127 // - Delete local file.
128 // # Note: if the local file is a folder, delete recursively.
57 void HandleDeletion(const SyncStatusCallback& callback); 129 void HandleDeletion(const SyncStatusCallback& callback);
58 void DidPrepareForDeletion(const SyncStatusCallback& callback, 130 void DidPrepareForDeletion(const SyncStatusCallback& callback,
59 SyncStatusCode status); 131 SyncStatusCode status);
60 132
61 void HandleNewFile(const SyncStatusCallback& callback); 133 // TODO(tzik): Write details and implement this.
62 void DidPrepareForNewFile(const SyncStatusCallback& callback, 134 void HandleRename(const SyncStatusCallback& callback);
63 SyncStatusCode status);
64 135
136 // TODO(tzik): Write details and implement this.
137 void HandleReorganize(const SyncStatusCallback& callback);
138
139 // Handles new file. Needs Prepare() call.
65 void HandleContentUpdate(const SyncStatusCallback& callback); 140 void HandleContentUpdate(const SyncStatusCallback& callback);
66 void DidPrepareForContentUpdate(const SyncStatusCallback& callback, 141 void DidPrepareForContentUpdate(const SyncStatusCallback& callback,
67 SyncStatusCode status); 142 SyncStatusCode status);
68 143
69 void ListFolderContent(const SyncStatusCallback& callback); 144 void HandleFolderContentListing(const SyncStatusCallback& callback);
70 void DidPrepareForFolderListing(const SyncStatusCallback& callback, 145 void DidPrepareForFolderListing(const SyncStatusCallback& callback,
71 SyncStatusCode status); 146 SyncStatusCode status);
72 147
73 void HandleRename(const SyncStatusCallback& callback);
74 void HandleReorganize(const SyncStatusCallback& callback);
75 void HandleOfflineSolvable(const SyncStatusCallback& callback); 148 void HandleOfflineSolvable(const SyncStatusCallback& callback);
76 149
77 void SyncCompleted(const SyncStatusCallback& callback); 150 void SyncCompleted(const SyncStatusCallback& callback);
78 151
79 void Prepare(const SyncStatusCallback& callback); 152 void Prepare(const SyncStatusCallback& callback);
80 void DidPrepare(const SyncStatusCallback& callback, 153 void DidPrepare(const SyncStatusCallback& callback,
81 SyncStatusCode status, 154 SyncStatusCode status,
82 const SyncFileMetadata& metadata, 155 const SyncFileMetadata& metadata,
83 const FileChangeList& changes); 156 const FileChangeList& changes);
84 157
85 void DeleteLocalFile(const SyncStatusCallback& callback); 158 void DeleteLocalFile(const SyncStatusCallback& callback);
86 void DidDeleteLocalFile(const SyncStatusCallback& callback, 159 void DidDeleteLocalFile(const SyncStatusCallback& callback,
87 SyncStatusCode status); 160 SyncStatusCode status);
88 161
89 drive::DriveServiceInterface* drive_service(); 162 drive::DriveServiceInterface* drive_service();
90 MetadataDatabase* metadata_database(); 163 MetadataDatabase* metadata_database();
91 RemoteChangeProcessor* remote_change_processor(); 164 RemoteChangeProcessor* remote_change_processor();
92 165
93 SyncEngineContext* sync_context_; // Not owned. 166 SyncEngineContext* sync_context_; // Not owned.
94 167
95 int priorities_; 168 int priorities_;
96 FileTracker dirty_tracker_; 169 scoped_ptr<FileTracker> dirty_tracker_;
97 FileTracker parent_tracker_; 170 scoped_ptr<FileMetadata> remote_metadata_;
98 FileMetadata remote_metadata_;
99
100 bool missing_remote_details_;
101 bool missing_synced_details_;
102 bool deleted_remote_details_;
103 bool deleted_synced_details_;
104 bool title_changed_;
105 bool content_changed_;
106 bool needs_folder_listing_;
107 bool missing_parent_;
108
109 bool sync_root_modification_;
110 171
111 fileapi::FileSystemURL url_; 172 fileapi::FileSystemURL url_;
112 173
113 SyncFileMetadata local_metadata_; 174 SyncFileMetadata local_metadata_;
114 FileChangeList local_changes_; 175 FileChangeList local_changes_;
115 176
116 base::WeakPtrFactory<RemoteToLocalSyncer> weak_ptr_factory_; 177 base::WeakPtrFactory<RemoteToLocalSyncer> weak_ptr_factory_;
117 178
118 DISALLOW_COPY_AND_ASSIGN(RemoteToLocalSyncer); 179 DISALLOW_COPY_AND_ASSIGN(RemoteToLocalSyncer);
119 }; 180 };
120 181
121 } // namespace drive_backend 182 } // namespace drive_backend
122 } // namespace sync_file_system 183 } // namespace sync_file_system
123 184
124 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_REMOTE_TO_LOCAL_SYNCER_ H_ 185 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_REMOTE_TO_LOCAL_SYNCER_ H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698