OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/entry.h" | 5 #include "components/sync/syncable/entry.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <iomanip> | 9 #include <iomanip> |
10 | 10 |
11 #include "sync/syncable/directory.h" | 11 #include "components/sync/syncable/directory.h" |
12 #include "sync/syncable/syncable_base_transaction.h" | 12 #include "components/sync/syncable/syncable_base_transaction.h" |
13 | 13 |
14 namespace syncer { | 14 namespace syncer { |
15 namespace syncable { | 15 namespace syncable { |
16 | 16 |
17 Entry::Entry(BaseTransaction* trans, GetById, const Id& id) | 17 Entry::Entry(BaseTransaction* trans, GetById, const Id& id) |
18 : basetrans_(trans) { | 18 : basetrans_(trans) { |
19 kernel_ = trans->directory()->GetEntryById(id); | 19 kernel_ = trans->directory()->GetEntryById(id); |
20 } | 20 } |
21 | 21 |
22 Entry::Entry(BaseTransaction* trans, GetByClientTag, const std::string& tag) | 22 Entry::Entry(BaseTransaction* trans, GetByClientTag, const std::string& tag) |
(...skipping 19 matching lines...) Expand all Loading... |
42 | 42 |
43 Directory* Entry::dir() const { | 43 Directory* Entry::dir() const { |
44 return basetrans_->directory(); | 44 return basetrans_->directory(); |
45 } | 45 } |
46 | 46 |
47 base::DictionaryValue* Entry::ToValue(Cryptographer* cryptographer) const { | 47 base::DictionaryValue* Entry::ToValue(Cryptographer* cryptographer) const { |
48 base::DictionaryValue* entry_info = new base::DictionaryValue(); | 48 base::DictionaryValue* entry_info = new base::DictionaryValue(); |
49 entry_info->SetBoolean("good", good()); | 49 entry_info->SetBoolean("good", good()); |
50 if (good()) { | 50 if (good()) { |
51 entry_info->Set("kernel", kernel_->ToValue(cryptographer)); | 51 entry_info->Set("kernel", kernel_->ToValue(cryptographer)); |
52 entry_info->Set("modelType", | 52 entry_info->Set("modelType", ModelTypeToValue(GetModelType())); |
53 ModelTypeToValue(GetModelType())); | |
54 entry_info->SetBoolean("existsOnClientBecauseNameIsNonEmpty", | 53 entry_info->SetBoolean("existsOnClientBecauseNameIsNonEmpty", |
55 ExistsOnClientBecauseNameIsNonEmpty()); | 54 ExistsOnClientBecauseNameIsNonEmpty()); |
56 entry_info->SetBoolean("isRoot", IsRoot()); | 55 entry_info->SetBoolean("isRoot", IsRoot()); |
57 } | 56 } |
58 return entry_info; | 57 return entry_info; |
59 } | 58 } |
60 | 59 |
61 bool Entry::GetSyncing() const { | 60 bool Entry::GetSyncing() const { |
62 DCHECK(kernel_); | 61 DCHECK(kernel_); |
63 return kernel_->ref(SYNCING); | 62 return kernel_->ref(SYNCING); |
64 } | 63 } |
65 | 64 |
66 bool Entry::GetDirtySync() const { | 65 bool Entry::GetDirtySync() const { |
67 DCHECK(kernel_); | 66 DCHECK(kernel_); |
68 return kernel_->ref(DIRTY_SYNC); | 67 return kernel_->ref(DIRTY_SYNC); |
69 } | 68 } |
70 | 69 |
71 ModelType Entry::GetServerModelType() const { | 70 ModelType Entry::GetServerModelType() const { |
72 ModelType specifics_type = kernel_->GetServerModelType(); | 71 ModelType specifics_type = kernel_->GetServerModelType(); |
73 if (specifics_type != UNSPECIFIED) | 72 if (specifics_type != UNSPECIFIED) |
74 return specifics_type; | 73 return specifics_type; |
75 | 74 |
76 // Otherwise, we don't have a server type yet. That should only happen | 75 // Otherwise, we don't have a server type yet. That should only happen |
77 // if the item is an uncommitted locally created item. | 76 // if the item is an uncommitted locally created item. |
78 // It's possible we'll need to relax these checks in the future; they're | 77 // It's possible we'll need to relax these checks in the future; they're |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 return kernel_->ShouldMaintainHierarchy(); | 130 return kernel_->ShouldMaintainHierarchy(); |
132 } | 131 } |
133 | 132 |
134 std::ostream& operator<<(std::ostream& os, const Entry& entry) { | 133 std::ostream& operator<<(std::ostream& os, const Entry& entry) { |
135 os << *(entry.kernel_); | 134 os << *(entry.kernel_); |
136 return os; | 135 return os; |
137 } | 136 } |
138 | 137 |
139 } // namespace syncable | 138 } // namespace syncable |
140 } // namespace syncer | 139 } // namespace syncer |
OLD | NEW |