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/metadata_database.h" | 5 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <stack> | 8 #include <stack> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 if (tracker->dirty() && !ShouldKeepDirty(*tracker)) { | 1034 if (tracker->dirty() && !ShouldKeepDirty(*tracker)) { |
1035 tracker->set_dirty(false); | 1035 tracker->set_dirty(false); |
1036 dirty_trackers_.erase(tracker); | 1036 dirty_trackers_.erase(tracker); |
1037 low_priority_dirty_trackers_.erase(tracker); | 1037 low_priority_dirty_trackers_.erase(tracker); |
1038 } | 1038 } |
1039 PutTrackerToBatch(*tracker, batch.get()); | 1039 PutTrackerToBatch(*tracker, batch.get()); |
1040 | 1040 |
1041 WriteToDatabase(batch.Pass(), callback); | 1041 WriteToDatabase(batch.Pass(), callback); |
1042 } | 1042 } |
1043 | 1043 |
| 1044 bool MetadataDatabase::TryNoSideEffectActivation( |
| 1045 int64 tracker_id, |
| 1046 const SyncStatusCallback& callback) { |
| 1047 DCHECK(ContainsKey(tracker_by_id_, tracker_id)); |
| 1048 const FileTracker& tracker = *tracker_by_id_[tracker_id]; |
| 1049 if (tracker.active()) { |
| 1050 RunSoon(FROM_HERE, base::Bind(callback, SYNC_STATUS_OK)); |
| 1051 return true; |
| 1052 } |
| 1053 |
| 1054 if (!CanActivateTracker(tracker)) |
| 1055 return false; |
| 1056 |
| 1057 scoped_ptr<leveldb::WriteBatch> batch(new leveldb::WriteBatch); |
| 1058 MakeTrackerActive(tracker_id, batch.get()); |
| 1059 WriteToDatabase(batch.Pass(), callback); |
| 1060 return true; |
| 1061 } |
| 1062 |
1044 void MetadataDatabase::LowerTrackerPriority(int64 tracker_id) { | 1063 void MetadataDatabase::LowerTrackerPriority(int64 tracker_id) { |
1045 TrackerByID::const_iterator found = tracker_by_id_.find(tracker_id); | 1064 TrackerByID::const_iterator found = tracker_by_id_.find(tracker_id); |
1046 if (found == tracker_by_id_.end()) | 1065 if (found == tracker_by_id_.end()) |
1047 return; | 1066 return; |
1048 | 1067 |
1049 FileTracker* tracker = found->second; | 1068 FileTracker* tracker = found->second; |
1050 if (dirty_trackers_.erase(tracker)) | 1069 if (dirty_trackers_.erase(tracker)) |
1051 low_priority_dirty_trackers_.insert(tracker); | 1070 low_priority_dirty_trackers_.insert(tracker); |
1052 } | 1071 } |
1053 | 1072 |
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1759 int64 change_id) { | 1778 int64 change_id) { |
1760 FileByID::const_iterator found = file_by_id_.find(file_id); | 1779 FileByID::const_iterator found = file_by_id_.find(file_id); |
1761 if (found == file_by_id_.end()) | 1780 if (found == file_by_id_.end()) |
1762 return false; | 1781 return false; |
1763 DCHECK(found->second->has_details()); | 1782 DCHECK(found->second->has_details()); |
1764 return found->second->details().change_id() >= change_id; | 1783 return found->second->details().change_id() >= change_id; |
1765 } | 1784 } |
1766 | 1785 |
1767 } // namespace drive_backend | 1786 } // namespace drive_backend |
1768 } // namespace sync_file_system | 1787 } // namespace sync_file_system |
OLD | NEW |