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 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
927 for (MetahandlesMap::iterator it = kernel_->metahandles_map.begin(); | 927 for (MetahandlesMap::iterator it = kernel_->metahandles_map.begin(); |
928 it != kernel_->metahandles_map.end(); ++it) { | 928 it != kernel_->metahandles_map.end(); ++it) { |
929 EntryKernel* entry = it->second; | 929 EntryKernel* entry = it->second; |
930 const ModelType type = GetModelTypeFromSpecifics(entry->ref(SPECIFICS)); | 930 const ModelType type = GetModelTypeFromSpecifics(entry->ref(SPECIFICS)); |
931 (*num_entries_by_type)[type]++; | 931 (*num_entries_by_type)[type]++; |
932 if (entry->ref(IS_DEL)) | 932 if (entry->ref(IS_DEL)) |
933 (*num_to_delete_entries_by_type)[type]++; | 933 (*num_to_delete_entries_by_type)[type]++; |
934 } | 934 } |
935 } | 935 } |
936 | 936 |
937 scoped_ptr<base::ListValue> Directory::GetAllNodeDetails( | 937 scoped_ptr<base::ListValue> Directory::GetNodeDetailsForType( |
938 BaseTransaction* trans) { | 938 BaseTransaction* trans, |
| 939 ModelType type) { |
939 scoped_ptr<base::ListValue> nodes(new base::ListValue()); | 940 scoped_ptr<base::ListValue> nodes(new base::ListValue()); |
940 | 941 |
941 ScopedKernelLock lock(this); | 942 ScopedKernelLock lock(this); |
942 for (MetahandlesMap::iterator it = kernel_->metahandles_map.begin(); | 943 for (MetahandlesMap::iterator it = kernel_->metahandles_map.begin(); |
943 it != kernel_->metahandles_map.end(); ++it) { | 944 it != kernel_->metahandles_map.end(); ++it) { |
| 945 if (GetModelTypeFromSpecifics(it->second->ref(SPECIFICS)) != type) { |
| 946 continue; |
| 947 } |
| 948 |
944 EntryKernel* kernel = it->second; | 949 EntryKernel* kernel = it->second; |
945 scoped_ptr<base::DictionaryValue> node( | 950 scoped_ptr<base::DictionaryValue> node( |
946 kernel->ToValue(GetCryptographer(trans))); | 951 kernel->ToValue(GetCryptographer(trans))); |
947 | 952 |
948 // Add the position index if appropriate. This must be done here (and not | 953 // Add the position index if appropriate. This must be done here (and not |
949 // in EntryKernel) because the EntryKernel does not have access to its | 954 // in EntryKernel) because the EntryKernel does not have access to its |
950 // siblings. | 955 // siblings. |
951 if (kernel->ShouldMaintainPosition() && !kernel->ref(IS_DEL)) { | 956 if (kernel->ShouldMaintainPosition() && !kernel->ref(IS_DEL)) { |
952 node->SetInteger("positionIndex", GetPositionIndex(trans, kernel)); | 957 node->SetInteger("positionIndex", GetPositionIndex(trans, kernel)); |
953 } | 958 } |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1298 | 1303 |
1299 for (OrderedChildSet::const_iterator i = children->begin(); | 1304 for (OrderedChildSet::const_iterator i = children->begin(); |
1300 i != children->end(); ++i) { | 1305 i != children->end(); ++i) { |
1301 DCHECK_EQ(parent_id, (*i)->ref(PARENT_ID)); | 1306 DCHECK_EQ(parent_id, (*i)->ref(PARENT_ID)); |
1302 result->push_back((*i)->ref(META_HANDLE)); | 1307 result->push_back((*i)->ref(META_HANDLE)); |
1303 } | 1308 } |
1304 } | 1309 } |
1305 | 1310 |
1306 } // namespace syncable | 1311 } // namespace syncable |
1307 } // namespace syncer | 1312 } // namespace syncer |
OLD | NEW |