Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: components/sync/driver/about_sync_util.cc

Issue 2287733002: Switch //components away from base::ListValue::Append(Value*) overload. (Closed)
Patch Set: rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "components/sync/driver/about_sync_util.h" 5 #include "components/sync/driver/about_sync_util.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/memory/ptr_util.h"
11 #include "base/strings/string16.h" 12 #include "base/strings/string16.h"
12 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
13 #include "base/values.h" 14 #include "base/values.h"
14 #include "components/signin/core/browser/signin_manager_base.h" 15 #include "components/signin/core/browser/signin_manager_base.h"
15 #include "components/sync/api/time.h" 16 #include "components/sync/api/time.h"
16 #include "components/sync/driver/sync_service.h" 17 #include "components/sync/driver/sync_service.h"
17 #include "components/sync/engine/cycle/sync_cycle_snapshot.h" 18 #include "components/sync/engine/cycle/sync_cycle_snapshot.h"
18 #include "components/sync/engine/sync_status.h" 19 #include "components/sync/engine/sync_status.h"
19 #include "components/sync/engine/sync_string_conversions.h" 20 #include "components/sync/engine/sync_string_conversions.h"
20 #include "components/sync/protocol/proto_enum_conversions.h" 21 #include "components/sync/protocol/proto_enum_conversions.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 // Owned by the |section| passed in during construction. 111 // Owned by the |section| passed in during construction.
111 base::DictionaryValue* stat_; 112 base::DictionaryValue* stat_;
112 }; 113 };
113 114
114 StringSyncStat::StringSyncStat(base::ListValue* section, 115 StringSyncStat::StringSyncStat(base::ListValue* section,
115 const std::string& key) { 116 const std::string& key) {
116 stat_ = new base::DictionaryValue(); 117 stat_ = new base::DictionaryValue();
117 stat_->SetString("stat_name", key); 118 stat_->SetString("stat_name", key);
118 stat_->SetString("stat_value", "Uninitialized"); 119 stat_->SetString("stat_value", "Uninitialized");
119 stat_->SetBoolean("is_valid", false); 120 stat_->SetBoolean("is_valid", false);
120 section->Append(stat_); 121 section->Append(base::WrapUnique(stat_));
121 } 122 }
122 123
123 void StringSyncStat::SetValue(const std::string& value) { 124 void StringSyncStat::SetValue(const std::string& value) {
124 stat_->SetString("stat_value", value); 125 stat_->SetString("stat_value", value);
125 stat_->SetBoolean("is_valid", true); 126 stat_->SetBoolean("is_valid", true);
126 } 127 }
127 128
128 void StringSyncStat::SetValue(const base::string16& value) { 129 void StringSyncStat::SetValue(const base::string16& value) {
129 stat_->SetString("stat_value", value); 130 stat_->SetString("stat_value", value);
130 stat_->SetBoolean("is_valid", true); 131 stat_->SetBoolean("is_valid", true);
131 } 132 }
132 133
133 class BoolSyncStat { 134 class BoolSyncStat {
134 public: 135 public:
135 BoolSyncStat(base::ListValue* section, const std::string& key); 136 BoolSyncStat(base::ListValue* section, const std::string& key);
136 void SetValue(bool value); 137 void SetValue(bool value);
137 138
138 private: 139 private:
139 // Owned by the |section| passed in during construction. 140 // Owned by the |section| passed in during construction.
140 base::DictionaryValue* stat_; 141 base::DictionaryValue* stat_;
141 }; 142 };
142 143
143 BoolSyncStat::BoolSyncStat(base::ListValue* section, const std::string& key) { 144 BoolSyncStat::BoolSyncStat(base::ListValue* section, const std::string& key) {
144 stat_ = new base::DictionaryValue(); 145 stat_ = new base::DictionaryValue();
145 stat_->SetString("stat_name", key); 146 stat_->SetString("stat_name", key);
146 stat_->SetBoolean("stat_value", false); 147 stat_->SetBoolean("stat_value", false);
147 stat_->SetBoolean("is_valid", false); 148 stat_->SetBoolean("is_valid", false);
148 section->Append(stat_); 149 section->Append(base::WrapUnique(stat_));
149 } 150 }
150 151
151 void BoolSyncStat::SetValue(bool value) { 152 void BoolSyncStat::SetValue(bool value) {
152 stat_->SetBoolean("stat_value", value); 153 stat_->SetBoolean("stat_value", value);
153 stat_->SetBoolean("is_valid", true); 154 stat_->SetBoolean("is_valid", true);
154 } 155 }
155 156
156 class IntSyncStat { 157 class IntSyncStat {
157 public: 158 public:
158 IntSyncStat(base::ListValue* section, const std::string& key); 159 IntSyncStat(base::ListValue* section, const std::string& key);
159 void SetValue(int value); 160 void SetValue(int value);
160 161
161 private: 162 private:
162 // Owned by the |section| passed in during construction. 163 // Owned by the |section| passed in during construction.
163 base::DictionaryValue* stat_; 164 base::DictionaryValue* stat_;
164 }; 165 };
165 166
166 IntSyncStat::IntSyncStat(base::ListValue* section, const std::string& key) { 167 IntSyncStat::IntSyncStat(base::ListValue* section, const std::string& key) {
167 stat_ = new base::DictionaryValue(); 168 stat_ = new base::DictionaryValue();
168 stat_->SetString("stat_name", key); 169 stat_->SetString("stat_name", key);
169 stat_->SetInteger("stat_value", 0); 170 stat_->SetInteger("stat_value", 0);
170 stat_->SetBoolean("is_valid", false); 171 stat_->SetBoolean("is_valid", false);
171 section->Append(stat_); 172 section->Append(base::WrapUnique(stat_));
172 } 173 }
173 174
174 void IntSyncStat::SetValue(int value) { 175 void IntSyncStat::SetValue(int value) {
175 stat_->SetInteger("stat_value", value); 176 stat_->SetInteger("stat_value", value);
176 stat_->SetBoolean("is_valid", true); 177 stat_->SetBoolean("is_valid", true);
177 } 178 }
178 179
179 // Returns a string describing the chrome version environment. Version format: 180 // Returns a string describing the chrome version environment. Version format:
180 // <Build Info> <OS> <Version number> (<Last change>)<channel or "-devel"> 181 // <Build Info> <OS> <Version number> (<Last change>)<channel or "-devel">
181 // If version information is unavailable, returns "invalid." 182 // If version information is unavailable, returns "invalid."
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 } 517 }
517 518
518 about_info->Set("type_status", service->GetTypeStatusMap()); 519 about_info->Set("type_status", service->GetTypeStatusMap());
519 520
520 return about_info; 521 return about_info;
521 } 522 }
522 523
523 } // namespace sync_ui_util 524 } // namespace sync_ui_util
524 525
525 } // namespace sync_driver 526 } // namespace sync_driver
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698