| 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 "sync/syncable/directory.h" | 5 #include "sync/syncable/directory.h" |
| 6 | 6 |
| 7 #include <iterator> | 7 #include <iterator> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 ModelType model_type) { | 51 ModelType model_type) { |
| 52 // Clear everything except the data type id field. | 52 // Clear everything except the data type id field. |
| 53 download_progress[model_type].Clear(); | 53 download_progress[model_type].Clear(); |
| 54 download_progress[model_type].set_data_type_id( | 54 download_progress[model_type].set_data_type_id( |
| 55 GetSpecificsFieldNumberFromModelType(model_type)); | 55 GetSpecificsFieldNumberFromModelType(model_type)); |
| 56 | 56 |
| 57 // Explicitly set an empty token field to denote no progress. | 57 // Explicitly set an empty token field to denote no progress. |
| 58 download_progress[model_type].set_token(""); | 58 download_progress[model_type].set_token(""); |
| 59 } | 59 } |
| 60 | 60 |
| 61 bool Directory::PersistedKernelInfo::HasEmptyDownloadProgress( |
| 62 ModelType model_type) { |
| 63 const sync_pb::DataTypeProgressMarker& progress_marker = |
| 64 download_progress[model_type]; |
| 65 return progress_marker.token().empty(); |
| 66 } |
| 67 |
| 61 Directory::SaveChangesSnapshot::SaveChangesSnapshot() | 68 Directory::SaveChangesSnapshot::SaveChangesSnapshot() |
| 62 : kernel_info_status(KERNEL_SHARE_INFO_INVALID) { | 69 : kernel_info_status(KERNEL_SHARE_INFO_INVALID) { |
| 63 } | 70 } |
| 64 | 71 |
| 65 Directory::SaveChangesSnapshot::~SaveChangesSnapshot() { | 72 Directory::SaveChangesSnapshot::~SaveChangesSnapshot() { |
| 66 STLDeleteElements(&dirty_metas); | 73 STLDeleteElements(&dirty_metas); |
| 67 STLDeleteElements(&delete_journals); | 74 STLDeleteElements(&delete_journals); |
| 68 } | 75 } |
| 69 | 76 |
| 70 Directory::Kernel::Kernel( | 77 Directory::Kernel::Kernel( |
| (...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 | 738 |
| 732 { | 739 { |
| 733 WriteTransaction trans(FROM_HERE, PURGE_ENTRIES, this); | 740 WriteTransaction trans(FROM_HERE, PURGE_ENTRIES, this); |
| 734 | 741 |
| 735 EntryKernelSet entries_to_journal; | 742 EntryKernelSet entries_to_journal; |
| 736 STLElementDeleter<EntryKernelSet> journal_deleter(&entries_to_journal); | 743 STLElementDeleter<EntryKernelSet> journal_deleter(&entries_to_journal); |
| 737 | 744 |
| 738 { | 745 { |
| 739 ScopedKernelLock lock(this); | 746 ScopedKernelLock lock(this); |
| 740 | 747 |
| 748 bool found_progress = false; |
| 749 for (ModelTypeSet::Iterator iter = disabled_types.First(); iter.Good(); |
| 750 iter.Inc()) { |
| 751 if (!kernel_->persisted_info.HasEmptyDownloadProgress(iter.Get())) |
| 752 found_progress = true; |
| 753 } |
| 754 |
| 755 // If none of the disabled types have progress markers, there's nothing to |
| 756 // purge. |
| 757 if (!found_progress) |
| 758 return true; |
| 759 |
| 741 // We iterate in two passes to avoid a bug in STLport (which is used in | 760 // We iterate in two passes to avoid a bug in STLport (which is used in |
| 742 // the Android build). There are some versions of that library where a | 761 // the Android build). There are some versions of that library where a |
| 743 // hash_map's iterators can be invalidated when an item is erased from the | 762 // hash_map's iterators can be invalidated when an item is erased from the |
| 744 // hash_map. | 763 // hash_map. |
| 745 // See http://sourceforge.net/p/stlport/bugs/239/. | 764 // See http://sourceforge.net/p/stlport/bugs/239/. |
| 746 | 765 |
| 747 std::set<EntryKernel*> to_purge; | 766 std::set<EntryKernel*> to_purge; |
| 748 for (MetahandlesMap::iterator it = kernel_->metahandles_map.begin(); | 767 for (MetahandlesMap::iterator it = kernel_->metahandles_map.begin(); |
| 749 it != kernel_->metahandles_map.end(); ++it) { | 768 it != kernel_->metahandles_map.end(); ++it) { |
| 750 const sync_pb::EntitySpecifics& local_specifics = | 769 const sync_pb::EntitySpecifics& local_specifics = |
| (...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1446 } | 1465 } |
| 1447 } | 1466 } |
| 1448 | 1467 |
| 1449 void Directory::UnmarkDirtyEntry(WriteTransaction* trans, Entry* entry) { | 1468 void Directory::UnmarkDirtyEntry(WriteTransaction* trans, Entry* entry) { |
| 1450 CHECK(trans); | 1469 CHECK(trans); |
| 1451 entry->kernel_->clear_dirty(&kernel_->dirty_metahandles); | 1470 entry->kernel_->clear_dirty(&kernel_->dirty_metahandles); |
| 1452 } | 1471 } |
| 1453 | 1472 |
| 1454 } // namespace syncable | 1473 } // namespace syncable |
| 1455 } // namespace syncer | 1474 } // namespace syncer |
| OLD | NEW |