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 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_H_ | 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_H_ |
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_H_ | 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
184 | 184 |
185 // Updates database by |changes|. | 185 // Updates database by |changes|. |
186 // Marks each tracker for modified file as dirty and adds new trackers if | 186 // Marks each tracker for modified file as dirty and adds new trackers if |
187 // needed. | 187 // needed. |
188 void UpdateByChangeList(ScopedVector<google_apis::ChangeResource> changes, | 188 void UpdateByChangeList(ScopedVector<google_apis::ChangeResource> changes, |
189 const SyncStatusCallback& callback); | 189 const SyncStatusCallback& callback); |
190 | 190 |
191 // Adds |child_file_ids| to |folder_id| as its children. | 191 // Adds |child_file_ids| to |folder_id| as its children. |
192 // This method affects the active tracker only. | 192 // This method affects the active tracker only. |
193 // If the tracker has no further change to sync, unmarks its dirty flag. | 193 // If the tracker has no further change to sync, unmarks its dirty flag. |
194 void PopulateFolder(const std::string& folder_id, | 194 void PopulateFolderByChildList(const std::string& folder_id, |
195 const FileIDList& child_file_ids, | 195 const FileIDList& child_file_ids, |
196 const SyncStatusCallback& callback); | 196 const SyncStatusCallback& callback); |
197 | |
198 // Update |synced_details| of the tracker with |updated_details|. | |
nhiroki
2013/08/30 06:16:27
nit: s/Update/Updates/
tzik
2013/08/30 07:11:28
Done.
| |
199 void UpdateTracker(int64 tracker_id, | |
200 const FileDetails& updated_details, | |
201 const SyncStatusCallback& callback); | |
197 | 202 |
198 private: | 203 private: |
199 struct DirtyTrackerComparator { | 204 struct DirtyTrackerComparator { |
200 bool operator()(const FileTracker* left, | 205 bool operator()(const FileTracker* left, |
201 const FileTracker* right) const; | 206 const FileTracker* right) const; |
202 }; | 207 }; |
203 | 208 |
204 typedef std::set<FileTracker*, DirtyTrackerComparator> DirtyTrackers; | 209 typedef std::set<FileTracker*, DirtyTrackerComparator> DirtyTrackers; |
205 | 210 |
206 friend class MetadataDatabaseTest; | 211 friend class MetadataDatabaseTest; |
(...skipping 19 matching lines...) Expand all Loading... | |
226 void MakeAppRootEnabled(int64 tracker_id, leveldb::WriteBatch* batch); | 231 void MakeAppRootEnabled(int64 tracker_id, leveldb::WriteBatch* batch); |
227 | 232 |
228 void UnregisterTrackerAsAppRoot(const std::string& app_id, | 233 void UnregisterTrackerAsAppRoot(const std::string& app_id, |
229 leveldb::WriteBatch* batch); | 234 leveldb::WriteBatch* batch); |
230 void RemoveAllDescendantTrackers(int64 root_tracker_id, | 235 void RemoveAllDescendantTrackers(int64 root_tracker_id, |
231 leveldb::WriteBatch* batch); | 236 leveldb::WriteBatch* batch); |
232 | 237 |
233 void CreateTrackerForParentAndFileID(const FileTracker& parent_tracker, | 238 void CreateTrackerForParentAndFileID(const FileTracker& parent_tracker, |
234 const std::string& file_id, | 239 const std::string& file_id, |
235 leveldb::WriteBatch* batch); | 240 leveldb::WriteBatch* batch); |
241 | |
242 void RemoveTracker(int64 tracker_id, leveldb::WriteBatch* batch); | |
236 void RemoveTrackerIgnoringSiblings(int64 tracker_id, | 243 void RemoveTrackerIgnoringSiblings(int64 tracker_id, |
237 leveldb::WriteBatch* batch); | 244 leveldb::WriteBatch* batch); |
245 void RemoveTrackerInternal(int64 tracker_id, | |
246 leveldb::WriteBatch* batch, | |
247 bool remove_tracker_ignoring_siblings); | |
238 void MaybeAddTrackersForNewFile(const FileMetadata& file, | 248 void MaybeAddTrackersForNewFile(const FileMetadata& file, |
239 leveldb::WriteBatch* batch); | 249 leveldb::WriteBatch* batch); |
240 | 250 |
241 void MarkTrackerSetDirty(TrackerSet* trackers, | 251 void MarkTrackerSetDirty(TrackerSet* trackers, |
242 leveldb::WriteBatch* batch); | 252 leveldb::WriteBatch* batch); |
243 void MarkTrackersDirtyByFileID(const std::string& file_id, | 253 void MarkTrackersDirtyByFileID(const std::string& file_id, |
244 leveldb::WriteBatch* batch); | 254 leveldb::WriteBatch* batch); |
245 void MarkTrackersDirtyByPath(int64 parent_tracker_id, | 255 void MarkTrackersDirtyByPath(int64 parent_tracker_id, |
246 const std::string& title, | 256 const std::string& title, |
247 leveldb::WriteBatch* batch); | 257 leveldb::WriteBatch* batch); |
248 | 258 |
249 void EraseTrackerFromFileIDIndex(FileTracker* tracker, | 259 void EraseTrackerFromFileIDIndex(FileTracker* tracker, |
250 leveldb::WriteBatch* batch); | 260 leveldb::WriteBatch* batch); |
251 void EraseTrackerFromPathIndex(FileTracker* tracker); | 261 void EraseTrackerFromPathIndex(FileTracker* tracker); |
252 void EraseFileFromDatabase(const std::string& file_id, | 262 void EraseFileFromDatabase(const std::string& file_id, |
253 leveldb::WriteBatch* batch); | 263 leveldb::WriteBatch* batch); |
254 | 264 |
255 int64 GetNextTrackerID(leveldb::WriteBatch* batch); | 265 int64 GetNextTrackerID(leveldb::WriteBatch* batch); |
256 | 266 |
257 void RecursiveMarkTrackerAsDirty(int64 root_tracker_id, | 267 void RecursiveMarkTrackerAsDirty(int64 root_tracker_id, |
258 leveldb::WriteBatch* batch); | 268 leveldb::WriteBatch* batch); |
269 bool CanActivateTracker(const FileTracker& tracker); | |
259 bool ShouldKeepDirty(const FileTracker& tracker) const; | 270 bool ShouldKeepDirty(const FileTracker& tracker) const; |
260 | 271 |
272 bool HasDisabledAppRoot(const FileTracker& tracker) const; | |
273 bool HasActiveTrackerForFileID(const std::string& file_id) const; | |
274 bool HasActiveTrackerForPath(int64 parent_tracker, | |
275 const std::string& title) const; | |
276 | |
277 void UpdateTrackerTitle(FileTracker* tracker, | |
278 const std::string& new_title, | |
279 leveldb::WriteBatch* batch); | |
280 | |
261 void WriteToDatabase(scoped_ptr<leveldb::WriteBatch> batch, | 281 void WriteToDatabase(scoped_ptr<leveldb::WriteBatch> batch, |
262 const SyncStatusCallback& callback); | 282 const SyncStatusCallback& callback); |
263 | 283 |
264 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 284 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
265 scoped_ptr<leveldb::DB> db_; | 285 scoped_ptr<leveldb::DB> db_; |
266 | 286 |
267 scoped_ptr<ServiceMetadata> service_metadata_; | 287 scoped_ptr<ServiceMetadata> service_metadata_; |
268 | 288 |
269 FileByID file_by_id_; // Owned. | 289 FileByID file_by_id_; // Owned. |
270 TrackerByID tracker_by_id_; // Owned. | 290 TrackerByID tracker_by_id_; // Owned. |
(...skipping 21 matching lines...) Expand all Loading... | |
292 | 312 |
293 base::WeakPtrFactory<MetadataDatabase> weak_ptr_factory_; | 313 base::WeakPtrFactory<MetadataDatabase> weak_ptr_factory_; |
294 | 314 |
295 DISALLOW_COPY_AND_ASSIGN(MetadataDatabase); | 315 DISALLOW_COPY_AND_ASSIGN(MetadataDatabase); |
296 }; | 316 }; |
297 | 317 |
298 } // namespace drive_backend | 318 } // namespace drive_backend |
299 } // namespace sync_file_system | 319 } // namespace sync_file_system |
300 | 320 |
301 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_H_ | 321 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_H_ |
OLD | NEW |