Chromium Code Reviews| 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 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1026 continue; | 1026 continue; |
| 1027 | 1027 |
| 1028 if (candidate->has_synced_details() && | 1028 if (candidate->has_synced_details() && |
| 1029 candidate->synced_details().title() != title) | 1029 candidate->synced_details().title() != title) |
| 1030 continue; | 1030 continue; |
| 1031 tracker = candidate; | 1031 tracker = candidate; |
| 1032 } | 1032 } |
| 1033 | 1033 |
| 1034 DCHECK(tracker); | 1034 DCHECK(tracker); |
| 1035 | 1035 |
| 1036 if (!tracker->active() && same_file_id.has_active()) | |
| 1037 return ACTIVATION_FAILED_ANOTHER_ACTIVE_TRACKER; | |
| 1038 | |
| 1039 scoped_ptr<leveldb::WriteBatch> batch(new leveldb::WriteBatch); | |
| 1040 | |
| 1036 if (!tracker->active()) { | 1041 if (!tracker->active()) { |
| 1037 if (same_file_id.has_active()) | |
| 1038 return ACTIVATION_FAILED_ANOTHER_ACTIVE_TRACKER; | |
| 1039 | |
| 1040 TrackerSet same_title; | 1042 TrackerSet same_title; |
| 1041 FindTrackersByParentAndTitle(parent_tracker_id, title, &same_title); | 1043 FindTrackersByParentAndTitle(parent_tracker_id, title, &same_title); |
| 1042 if (same_title.has_active()) | 1044 if (same_title.has_active()) { |
|
kinuko
2014/02/06 09:48:01
Does it make sense to have some comment here? It's
tzik
2014/02/07 04:43:53
Added some comment around here.
| |
| 1043 return ACTIVATION_FAILED_SAME_PATH_TRACKER; | 1045 MakeTrackerInactive(same_title.active_tracker()->tracker_id(), |
| 1046 batch.get()); | |
| 1047 } | |
| 1044 } | 1048 } |
| 1045 | 1049 |
| 1046 scoped_ptr<leveldb::WriteBatch> batch(new leveldb::WriteBatch); | |
| 1047 if (!tracker->has_synced_details() || | 1050 if (!tracker->has_synced_details() || |
| 1048 tracker->synced_details().title() != title) { | 1051 tracker->synced_details().title() != title) { |
| 1049 trackers_by_parent_and_title_[parent_tracker_id] | 1052 trackers_by_parent_and_title_[parent_tracker_id] |
| 1050 [GetTrackerTitle(*tracker)].Erase(tracker); | 1053 [GetTrackerTitle(*tracker)].Erase(tracker); |
| 1051 trackers_by_parent_and_title_[parent_tracker_id][title].Insert( | 1054 trackers_by_parent_and_title_[parent_tracker_id][title].Insert( |
| 1052 tracker); | 1055 tracker); |
| 1053 } | 1056 } |
| 1054 *tracker->mutable_synced_details() = file.details(); | 1057 *tracker->mutable_synced_details() = file.details(); |
| 1055 | 1058 |
| 1056 MakeTrackerActive(tracker->tracker_id(), batch.get()); | 1059 MakeTrackerActive(tracker->tracker_id(), batch.get()); |
| (...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2047 MakeTrackerActive(tracker->tracker_id(), batch); | 2050 MakeTrackerActive(tracker->tracker_id(), batch); |
| 2048 ClearDirty(tracker, batch); | 2051 ClearDirty(tracker, batch); |
| 2049 return; | 2052 return; |
| 2050 } | 2053 } |
| 2051 | 2054 |
| 2052 NOTREACHED(); | 2055 NOTREACHED(); |
| 2053 } | 2056 } |
| 2054 | 2057 |
| 2055 } // namespace drive_backend | 2058 } // namespace drive_backend |
| 2056 } // namespace sync_file_system | 2059 } // namespace sync_file_system |
| OLD | NEW |