| 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 <utility> |
| 8 |
| 7 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 8 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/values.h" | 11 #include "base/values.h" |
| 10 #include "sync/protocol/proto_enum_conversions.h" | 12 #include "sync/protocol/proto_enum_conversions.h" |
| 11 | 13 |
| 12 namespace syncer { | 14 namespace syncer { |
| 13 namespace sessions { | 15 namespace sessions { |
| 14 | 16 |
| 15 SyncSessionSnapshot::SyncSessionSnapshot() | 17 SyncSessionSnapshot::SyncSessionSnapshot() |
| 16 : is_silenced_(false), | 18 : is_silenced_(false), |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 new base::DictionaryValue()); | 93 new base::DictionaryValue()); |
| 92 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; i++) { | 94 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; i++) { |
| 93 scoped_ptr<base::DictionaryValue> type_entries(new base::DictionaryValue()); | 95 scoped_ptr<base::DictionaryValue> type_entries(new base::DictionaryValue()); |
| 94 type_entries->SetInteger("numEntries", num_entries_by_type_[i]); | 96 type_entries->SetInteger("numEntries", num_entries_by_type_[i]); |
| 95 type_entries->SetInteger("numToDeleteEntries", | 97 type_entries->SetInteger("numToDeleteEntries", |
| 96 num_to_delete_entries_by_type_[i]); | 98 num_to_delete_entries_by_type_[i]); |
| 97 | 99 |
| 98 const std::string model_type = ModelTypeToString(static_cast<ModelType>(i)); | 100 const std::string model_type = ModelTypeToString(static_cast<ModelType>(i)); |
| 99 counter_entries->Set(model_type, type_entries.release()); | 101 counter_entries->Set(model_type, type_entries.release()); |
| 100 } | 102 } |
| 101 value->Set("counter_entries", counter_entries.Pass()); | 103 value->Set("counter_entries", std::move(counter_entries)); |
| 102 return value; | 104 return value; |
| 103 } | 105 } |
| 104 | 106 |
| 105 std::string SyncSessionSnapshot::ToString() const { | 107 std::string SyncSessionSnapshot::ToString() const { |
| 106 std::string json; | 108 std::string json; |
| 107 base::JSONWriter::WriteWithOptions( | 109 base::JSONWriter::WriteWithOptions( |
| 108 *ToValue(), base::JSONWriter::OPTIONS_PRETTY_PRINT, &json); | 110 *ToValue(), base::JSONWriter::OPTIONS_PRETTY_PRINT, &json); |
| 109 return json; | 111 return json; |
| 110 } | 112 } |
| 111 | 113 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 return num_to_delete_entries_by_type_; | 161 return num_to_delete_entries_by_type_; |
| 160 } | 162 } |
| 161 | 163 |
| 162 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource | 164 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource |
| 163 SyncSessionSnapshot::legacy_updates_source() const { | 165 SyncSessionSnapshot::legacy_updates_source() const { |
| 164 return legacy_updates_source_; | 166 return legacy_updates_source_; |
| 165 } | 167 } |
| 166 | 168 |
| 167 } // namespace sessions | 169 } // namespace sessions |
| 168 } // namespace syncer | 170 } // namespace syncer |
| OLD | NEW |