| 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 SYNC_SYNCABLE_DIRECTORY_H_ | 5 #ifndef SYNC_SYNCABLE_DIRECTORY_H_ |
| 6 #define SYNC_SYNCABLE_DIRECTORY_H_ | 6 #define SYNC_SYNCABLE_DIRECTORY_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/containers/hash_tables.h" | 14 #include "base/containers/hash_tables.h" |
| 15 #include "base/file_util.h" | 15 #include "base/file_util.h" |
| 16 #include "base/gtest_prod_util.h" | 16 #include "base/gtest_prod_util.h" |
| 17 #include "base/values.h" |
| 17 #include "sync/base/sync_export.h" | 18 #include "sync/base/sync_export.h" |
| 18 #include "sync/internal_api/public/util/report_unrecoverable_error_function.h" | 19 #include "sync/internal_api/public/util/report_unrecoverable_error_function.h" |
| 19 #include "sync/internal_api/public/util/weak_handle.h" | 20 #include "sync/internal_api/public/util/weak_handle.h" |
| 20 #include "sync/syncable/dir_open_result.h" | 21 #include "sync/syncable/dir_open_result.h" |
| 21 #include "sync/syncable/entry_kernel.h" | 22 #include "sync/syncable/entry_kernel.h" |
| 22 #include "sync/syncable/metahandle_set.h" | 23 #include "sync/syncable/metahandle_set.h" |
| 23 #include "sync/syncable/parent_child_index.h" | 24 #include "sync/syncable/parent_child_index.h" |
| 24 #include "sync/syncable/syncable_delete_journal.h" | 25 #include "sync/syncable/syncable_delete_journal.h" |
| 25 | 26 |
| 26 namespace syncer { | 27 namespace syncer { |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 const std::string & message); | 244 const std::string & message); |
| 244 | 245 |
| 245 DeleteJournal* delete_journal(); | 246 DeleteJournal* delete_journal(); |
| 246 | 247 |
| 247 // Returns the child meta handles (even those for deleted/unlinked | 248 // Returns the child meta handles (even those for deleted/unlinked |
| 248 // nodes) for given parent id. Clears |result| if there are no | 249 // nodes) for given parent id. Clears |result| if there are no |
| 249 // children. | 250 // children. |
| 250 bool GetChildHandlesById(BaseTransaction*, const Id& parent_id, | 251 bool GetChildHandlesById(BaseTransaction*, const Id& parent_id, |
| 251 Metahandles* result); | 252 Metahandles* result); |
| 252 | 253 |
| 253 // Returns the child meta handles (even those for deleted/unlinked | |
| 254 // nodes) for given meta handle. Clears |result| if there are no | |
| 255 // children. | |
| 256 bool GetChildHandlesByHandle(BaseTransaction*, int64 handle, | |
| 257 Metahandles* result); | |
| 258 | |
| 259 // Counts all items under the given node, including the node itself. | 254 // Counts all items under the given node, including the node itself. |
| 260 int GetTotalNodeCount(BaseTransaction*, EntryKernel* kernel_) const; | 255 int GetTotalNodeCount(BaseTransaction*, EntryKernel* kernel_) const; |
| 261 | 256 |
| 262 // Returns this item's position within its parent folder. | 257 // Returns this item's position within its parent folder. |
| 263 // The left-most item is 0, second left-most is 1, etc. | 258 // The left-most item is 0, second left-most is 1, etc. |
| 264 int GetPositionIndex(BaseTransaction*, EntryKernel* kernel_) const; | 259 int GetPositionIndex(BaseTransaction*, EntryKernel* kernel_) const; |
| 265 | 260 |
| 266 // Returns true iff |id| has children. | 261 // Returns true iff |id| has children. |
| 267 bool HasChildren(BaseTransaction* trans, const Id& id); | 262 bool HasChildren(BaseTransaction* trans, const Id& id); |
| 268 | 263 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 295 // SaveChanges works by taking a consistent snapshot of the current Directory | 290 // SaveChanges works by taking a consistent snapshot of the current Directory |
| 296 // state and indices (by deep copy) under a ReadTransaction, passing this | 291 // state and indices (by deep copy) under a ReadTransaction, passing this |
| 297 // snapshot to the backing store under no transaction, and finally cleaning | 292 // snapshot to the backing store under no transaction, and finally cleaning |
| 298 // up by either purging entries no longer needed (this part done under a | 293 // up by either purging entries no longer needed (this part done under a |
| 299 // WriteTransaction) or rolling back the dirty bits. It also uses | 294 // WriteTransaction) or rolling back the dirty bits. It also uses |
| 300 // internal locking to enforce SaveChanges operations are mutually exclusive. | 295 // internal locking to enforce SaveChanges operations are mutually exclusive. |
| 301 // | 296 // |
| 302 // WARNING: THIS METHOD PERFORMS SYNCHRONOUS I/O VIA SQLITE. | 297 // WARNING: THIS METHOD PERFORMS SYNCHRONOUS I/O VIA SQLITE. |
| 303 bool SaveChanges(); | 298 bool SaveChanges(); |
| 304 | 299 |
| 305 // Fill in |result| with all entry kernels. | |
| 306 void GetAllEntryKernels(BaseTransaction* trans, | |
| 307 std::vector<const EntryKernel*>* result); | |
| 308 | |
| 309 // Returns the number of entities with the unsynced bit set. | 300 // Returns the number of entities with the unsynced bit set. |
| 310 int64 unsynced_entity_count() const; | 301 int64 unsynced_entity_count() const; |
| 311 | 302 |
| 312 // Get GetUnsyncedMetaHandles should only be called after SaveChanges and | 303 // Get GetUnsyncedMetaHandles should only be called after SaveChanges and |
| 313 // before any new entries have been created. The intention is that the | 304 // before any new entries have been created. The intention is that the |
| 314 // syncer should call it from its PerformSyncQueries member. | 305 // syncer should call it from its PerformSyncQueries member. |
| 315 void GetUnsyncedMetaHandles(BaseTransaction* trans, | 306 void GetUnsyncedMetaHandles(BaseTransaction* trans, |
| 316 Metahandles* result); | 307 Metahandles* result); |
| 317 | 308 |
| 318 // Returns whether or not this |type| has unapplied updates. | 309 // Returns whether or not this |type| has unapplied updates. |
| 319 bool TypeHasUnappliedUpdates(ModelType type); | 310 bool TypeHasUnappliedUpdates(ModelType type); |
| 320 | 311 |
| 321 // Get all the metahandles for unapplied updates for a given set of | 312 // Get all the metahandles for unapplied updates for a given set of |
| 322 // server types. | 313 // server types. |
| 323 void GetUnappliedUpdateMetaHandles(BaseTransaction* trans, | 314 void GetUnappliedUpdateMetaHandles(BaseTransaction* trans, |
| 324 FullModelTypeSet server_types, | 315 FullModelTypeSet server_types, |
| 325 std::vector<int64>* result); | 316 std::vector<int64>* result); |
| 326 | 317 |
| 327 // Get metahandle counts for various criteria to show on the | 318 // Get metahandle counts for various criteria to show on the |
| 328 // about:sync page. The information is computed on the fly | 319 // about:sync page. The information is computed on the fly |
| 329 // each time. If this results in a significant performance hit, | 320 // each time. If this results in a significant performance hit, |
| 330 // additional data structures can be added to cache results. | 321 // additional data structures can be added to cache results. |
| 331 void CollectMetaHandleCounts(std::vector<int>* num_entries_by_type, | 322 void CollectMetaHandleCounts(std::vector<int>* num_entries_by_type, |
| 332 std::vector<int>* num_to_delete_entries_by_type); | 323 std::vector<int>* num_to_delete_entries_by_type); |
| 333 | 324 |
| 325 scoped_ptr<base::ListValue> GetAllNodeDetails(BaseTransaction* trans); |
| 326 |
| 334 // Sets the level of invariant checking performed after transactions. | 327 // Sets the level of invariant checking performed after transactions. |
| 335 void SetInvariantCheckLevel(InvariantCheckLevel check_level); | 328 void SetInvariantCheckLevel(InvariantCheckLevel check_level); |
| 336 | 329 |
| 337 // Checks tree metadata consistency following a transaction. It is intended | 330 // Checks tree metadata consistency following a transaction. It is intended |
| 338 // to provide a reasonable tradeoff between performance and comprehensiveness | 331 // to provide a reasonable tradeoff between performance and comprehensiveness |
| 339 // and may be used in release code. | 332 // and may be used in release code. |
| 340 bool CheckInvariantsOnTransactionClose( | 333 bool CheckInvariantsOnTransactionClose( |
| 341 syncable::BaseTransaction* trans, | 334 syncable::BaseTransaction* trans, |
| 342 const MetahandleSet& modified_handles); | 335 const MetahandleSet& modified_handles); |
| 343 | 336 |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 // are deleted in native models as well. | 541 // are deleted in native models as well. |
| 549 scoped_ptr<DeleteJournal> delete_journal_; | 542 scoped_ptr<DeleteJournal> delete_journal_; |
| 550 | 543 |
| 551 DISALLOW_COPY_AND_ASSIGN(Directory); | 544 DISALLOW_COPY_AND_ASSIGN(Directory); |
| 552 }; | 545 }; |
| 553 | 546 |
| 554 } // namespace syncable | 547 } // namespace syncable |
| 555 } // namespace syncer | 548 } // namespace syncer |
| 556 | 549 |
| 557 #endif // SYNC_SYNCABLE_DIRECTORY_H_ | 550 #endif // SYNC_SYNCABLE_DIRECTORY_H_ |
| OLD | NEW |