OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/internal_api/public/sessions/sync_session_snapshot.h" | 5 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 |
| 9 #include <memory> |
8 #include <utility> | 10 #include <utility> |
9 | 11 |
10 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "base/values.h" | 13 #include "base/values.h" |
13 #include "sync/protocol/proto_enum_conversions.h" | 14 #include "sync/protocol/proto_enum_conversions.h" |
14 | 15 |
15 namespace syncer { | 16 namespace syncer { |
16 namespace sessions { | 17 namespace sessions { |
17 | 18 |
18 SyncSessionSnapshot::SyncSessionSnapshot() | 19 SyncSessionSnapshot::SyncSessionSnapshot() |
19 : is_silenced_(false), | 20 : is_silenced_(false), |
20 num_encryption_conflicts_(0), | 21 num_encryption_conflicts_(0), |
21 num_hierarchy_conflicts_(0), | 22 num_hierarchy_conflicts_(0), |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 num_to_delete_entries_by_type_(num_to_delete_entries_by_type), | 56 num_to_delete_entries_by_type_(num_to_delete_entries_by_type), |
56 legacy_updates_source_(legacy_updates_source), | 57 legacy_updates_source_(legacy_updates_source), |
57 is_initialized_(true) { | 58 is_initialized_(true) { |
58 } | 59 } |
59 | 60 |
60 SyncSessionSnapshot::SyncSessionSnapshot(const SyncSessionSnapshot& other) = | 61 SyncSessionSnapshot::SyncSessionSnapshot(const SyncSessionSnapshot& other) = |
61 default; | 62 default; |
62 | 63 |
63 SyncSessionSnapshot::~SyncSessionSnapshot() {} | 64 SyncSessionSnapshot::~SyncSessionSnapshot() {} |
64 | 65 |
65 scoped_ptr<base::DictionaryValue> SyncSessionSnapshot::ToValue() const { | 66 std::unique_ptr<base::DictionaryValue> SyncSessionSnapshot::ToValue() const { |
66 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 67 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
67 value->SetInteger("numSuccessfulCommits", | 68 value->SetInteger("numSuccessfulCommits", |
68 model_neutral_state_.num_successful_commits); | 69 model_neutral_state_.num_successful_commits); |
69 value->SetInteger("numSuccessfulBookmarkCommits", | 70 value->SetInteger("numSuccessfulBookmarkCommits", |
70 model_neutral_state_.num_successful_bookmark_commits); | 71 model_neutral_state_.num_successful_bookmark_commits); |
71 value->SetInteger("numUpdatesDownloadedTotal", | 72 value->SetInteger("numUpdatesDownloadedTotal", |
72 model_neutral_state_.num_updates_downloaded_total); | 73 model_neutral_state_.num_updates_downloaded_total); |
73 value->SetInteger("numTombstoneUpdatesDownloadedTotal", | 74 value->SetInteger("numTombstoneUpdatesDownloadedTotal", |
74 model_neutral_state_.num_tombstone_updates_downloaded_total); | 75 model_neutral_state_.num_tombstone_updates_downloaded_total); |
75 value->SetInteger("numReflectedUpdatesDownloadedTotal", | 76 value->SetInteger("numReflectedUpdatesDownloadedTotal", |
76 model_neutral_state_.num_reflected_updates_downloaded_total); | 77 model_neutral_state_.num_reflected_updates_downloaded_total); |
77 value->SetInteger("numLocalOverwrites", | 78 value->SetInteger("numLocalOverwrites", |
78 model_neutral_state_.num_local_overwrites); | 79 model_neutral_state_.num_local_overwrites); |
79 value->SetInteger("numServerOverwrites", | 80 value->SetInteger("numServerOverwrites", |
80 model_neutral_state_.num_server_overwrites); | 81 model_neutral_state_.num_server_overwrites); |
81 value->Set("downloadProgressMarkers", | 82 value->Set("downloadProgressMarkers", |
82 ProgressMarkerMapToValue(download_progress_markers_)); | 83 ProgressMarkerMapToValue(download_progress_markers_)); |
83 value->SetBoolean("isSilenced", is_silenced_); | 84 value->SetBoolean("isSilenced", is_silenced_); |
84 // We don't care too much if we lose precision here, also. | 85 // We don't care too much if we lose precision here, also. |
85 value->SetInteger("numEncryptionConflicts", | 86 value->SetInteger("numEncryptionConflicts", |
86 num_encryption_conflicts_); | 87 num_encryption_conflicts_); |
87 value->SetInteger("numHierarchyConflicts", | 88 value->SetInteger("numHierarchyConflicts", |
88 num_hierarchy_conflicts_); | 89 num_hierarchy_conflicts_); |
89 value->SetInteger("numServerConflicts", | 90 value->SetInteger("numServerConflicts", |
90 num_server_conflicts_); | 91 num_server_conflicts_); |
91 value->SetInteger("numEntries", num_entries_); | 92 value->SetInteger("numEntries", num_entries_); |
92 value->SetString("legacySource", | 93 value->SetString("legacySource", |
93 GetUpdatesSourceString(legacy_updates_source_)); | 94 GetUpdatesSourceString(legacy_updates_source_)); |
94 value->SetBoolean("notificationsEnabled", notifications_enabled_); | 95 value->SetBoolean("notificationsEnabled", notifications_enabled_); |
95 | 96 |
96 scoped_ptr<base::DictionaryValue> counter_entries( | 97 std::unique_ptr<base::DictionaryValue> counter_entries( |
97 new base::DictionaryValue()); | 98 new base::DictionaryValue()); |
98 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; i++) { | 99 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; i++) { |
99 scoped_ptr<base::DictionaryValue> type_entries(new base::DictionaryValue()); | 100 std::unique_ptr<base::DictionaryValue> type_entries( |
| 101 new base::DictionaryValue()); |
100 type_entries->SetInteger("numEntries", num_entries_by_type_[i]); | 102 type_entries->SetInteger("numEntries", num_entries_by_type_[i]); |
101 type_entries->SetInteger("numToDeleteEntries", | 103 type_entries->SetInteger("numToDeleteEntries", |
102 num_to_delete_entries_by_type_[i]); | 104 num_to_delete_entries_by_type_[i]); |
103 | 105 |
104 const std::string model_type = ModelTypeToString(static_cast<ModelType>(i)); | 106 const std::string model_type = ModelTypeToString(static_cast<ModelType>(i)); |
105 counter_entries->Set(model_type, type_entries.release()); | 107 counter_entries->Set(model_type, type_entries.release()); |
106 } | 108 } |
107 value->Set("counter_entries", std::move(counter_entries)); | 109 value->Set("counter_entries", std::move(counter_entries)); |
108 return value; | 110 return value; |
109 } | 111 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 return num_to_delete_entries_by_type_; | 167 return num_to_delete_entries_by_type_; |
166 } | 168 } |
167 | 169 |
168 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource | 170 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource |
169 SyncSessionSnapshot::legacy_updates_source() const { | 171 SyncSessionSnapshot::legacy_updates_source() const { |
170 return legacy_updates_source_; | 172 return legacy_updates_source_; |
171 } | 173 } |
172 | 174 |
173 } // namespace sessions | 175 } // namespace sessions |
174 } // namespace syncer | 176 } // namespace syncer |
OLD | NEW |