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

Side by Side Diff: chrome/browser/chromeos/login/signed_settings_helper.cc

Issue 8091002: PART2: Make SignedSettings use proper Value types instead of string all around the place. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments and rebased on a the current PART1 version. Created 9 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/chromeos/login/signed_settings_helper.h" 5 #include "chrome/browser/chromeos/login/signed_settings_helper.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 Type type_; 161 Type type_;
162 std::string email_; 162 std::string email_;
163 163
164 DISALLOW_COPY_AND_ASSIGN(WhitelistOpContext); 164 DISALLOW_COPY_AND_ASSIGN(WhitelistOpContext);
165 }; 165 };
166 166
167 class StorePropertyOpContext : public SignedSettings::Delegate<bool>, 167 class StorePropertyOpContext : public SignedSettings::Delegate<bool>,
168 public OpContext { 168 public OpContext {
169 public: 169 public:
170 StorePropertyOpContext(const std::string& name, 170 StorePropertyOpContext(const std::string& name,
171 const std::string& value, 171 const base::Value& value,
172 SignedSettingsHelper::Callback* callback, 172 SignedSettingsHelper::Callback* callback,
173 OpContext::Delegate* delegate) 173 OpContext::Delegate* delegate)
174 : OpContext(callback, delegate), 174 : OpContext(callback, delegate),
175 name_(name), 175 name_(name),
176 value_(value) { 176 value_(value.DeepCopy()) {
177 } 177 }
178 178
179 // chromeos::SignedSettings::Delegate implementation 179 // chromeos::SignedSettings::Delegate implementation
180 virtual void OnSettingsOpCompleted(SignedSettings::ReturnCode code, 180 virtual void OnSettingsOpCompleted(SignedSettings::ReturnCode code,
181 bool unused) OVERRIDE { 181 bool unused) OVERRIDE {
182 VLOG(2) << "OnSettingsOpCompleted, code = " << code; 182 VLOG(2) << "OnSettingsOpCompleted, code = " << code;
183 if (callback_) 183 if (callback_)
184 callback_->OnStorePropertyCompleted(code, name_, value_); 184 callback_->OnStorePropertyCompleted(code, name_, *value_);
185 OnOpCompleted(); 185 OnOpCompleted();
186 } 186 }
187 187
188 protected: 188 protected:
189 // OpContext implemenetation 189 // OpContext implemenetation
190 virtual void CreateOp() OVERRIDE { 190 virtual void CreateOp() OVERRIDE {
191 op_ = SignedSettings::CreateStorePropertyOp(name_, value_, this); 191 op_ = SignedSettings::CreateStorePropertyOp(name_, *value_, this);
192 } 192 }
193 193
194 private: 194 private:
195 std::string name_; 195 std::string name_;
196 std::string value_; 196 scoped_ptr<base::Value> value_;
197 197
198 DISALLOW_COPY_AND_ASSIGN(StorePropertyOpContext); 198 DISALLOW_COPY_AND_ASSIGN(StorePropertyOpContext);
199 }; 199 };
200 200
201 class RetrievePropertyOpContext 201 class RetrievePropertyOpContext
202 : public SignedSettings::Delegate<std::string>, 202 : public SignedSettings::Delegate<const base::Value&>,
203 public OpContext { 203 public OpContext {
204 public: 204 public:
205 RetrievePropertyOpContext(const std::string& name, 205 RetrievePropertyOpContext(const std::string& name,
206 SignedSettingsHelper::Callback* callback, 206 SignedSettingsHelper::Callback* callback,
207 OpContext::Delegate* delegate) 207 OpContext::Delegate* delegate)
208 : OpContext(callback, delegate), 208 : OpContext(callback, delegate),
209 name_(name) { 209 name_(name) {
210 } 210 }
211 211
212 // chromeos::SignedSettings::Delegate implementation 212 // chromeos::SignedSettings::Delegate implementation
213 virtual void OnSettingsOpCompleted(SignedSettings::ReturnCode code, 213 virtual void OnSettingsOpCompleted(SignedSettings::ReturnCode code,
214 std::string value) OVERRIDE { 214 const base::Value& value) OVERRIDE {
215 if (callback_) 215 if (callback_)
216 callback_->OnRetrievePropertyCompleted(code, name_, value); 216 callback_->OnRetrievePropertyCompleted(code, name_, value);
217 217
218 OnOpCompleted(); 218 OnOpCompleted();
219 } 219 }
220 220
221 protected: 221 protected:
222 // OpContext implemenetation 222 // OpContext implemenetation
223 virtual void CreateOp() OVERRIDE { 223 virtual void CreateOp() OVERRIDE {
224 op_ = SignedSettings::CreateRetrievePropertyOp(name_, this); 224 op_ = SignedSettings::CreateRetrievePropertyOp(name_, this);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 class SignedSettingsHelperImpl : public SignedSettingsHelper, 294 class SignedSettingsHelperImpl : public SignedSettingsHelper,
295 public OpContext::Delegate { 295 public OpContext::Delegate {
296 public: 296 public:
297 // SignedSettingsHelper implementation 297 // SignedSettingsHelper implementation
298 virtual void StartCheckWhitelistOp(const std::string& email, 298 virtual void StartCheckWhitelistOp(const std::string& email,
299 Callback* callback) OVERRIDE; 299 Callback* callback) OVERRIDE;
300 virtual void StartWhitelistOp(const std::string& email, 300 virtual void StartWhitelistOp(const std::string& email,
301 bool add_to_whitelist, 301 bool add_to_whitelist,
302 Callback* callback) OVERRIDE; 302 Callback* callback) OVERRIDE;
303 virtual void StartStorePropertyOp(const std::string& name, 303 virtual void StartStorePropertyOp(const std::string& name,
304 const std::string& value, 304 const base::Value& value,
305 Callback* callback) OVERRIDE; 305 Callback* callback) OVERRIDE;
306 virtual void StartRetrieveProperty(const std::string& name, 306 virtual void StartRetrieveProperty(const std::string& name,
307 Callback* callback) OVERRIDE; 307 Callback* callback) OVERRIDE;
308 virtual void StartStorePolicyOp(const em::PolicyFetchResponse& policy, 308 virtual void StartStorePolicyOp(const em::PolicyFetchResponse& policy,
309 Callback* callback) OVERRIDE; 309 Callback* callback) OVERRIDE;
310 virtual void StartRetrievePolicyOp(Callback* callback) OVERRIDE; 310 virtual void StartRetrievePolicyOp(Callback* callback) OVERRIDE;
311 virtual void CancelCallback(Callback* callback) OVERRIDE; 311 virtual void CancelCallback(Callback* callback) OVERRIDE;
312 312
313 // OpContext::Delegate implementation 313 // OpContext::Delegate implementation
314 virtual void OnOpCreated(OpContext* context); 314 virtual void OnOpCreated(OpContext* context);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 SignedSettingsHelper::Callback* callback) { 358 SignedSettingsHelper::Callback* callback) {
359 AddOpContext(new WhitelistOpContext( 359 AddOpContext(new WhitelistOpContext(
360 add_to_whitelist ? WhitelistOpContext::ADD : WhitelistOpContext::REMOVE, 360 add_to_whitelist ? WhitelistOpContext::ADD : WhitelistOpContext::REMOVE,
361 email, 361 email,
362 callback, 362 callback,
363 this)); 363 this));
364 } 364 }
365 365
366 void SignedSettingsHelperImpl::StartStorePropertyOp( 366 void SignedSettingsHelperImpl::StartStorePropertyOp(
367 const std::string& name, 367 const std::string& name,
368 const std::string& value, 368 const base::Value& value,
369 SignedSettingsHelper::Callback* callback) { 369 SignedSettingsHelper::Callback* callback) {
370 AddOpContext(new StorePropertyOpContext( 370 AddOpContext(new StorePropertyOpContext(
371 name, 371 name,
372 value, 372 value,
373 callback, 373 callback,
374 this)); 374 this));
375 } 375 }
376 376
377 void SignedSettingsHelperImpl::StartRetrieveProperty( 377 void SignedSettingsHelperImpl::StartRetrieveProperty(
378 const std::string& name, 378 const std::string& name,
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 444
445 if (test_delegate_) 445 if (test_delegate_)
446 test_delegate_->OnOpCompleted(context->op()); 446 test_delegate_->OnOpCompleted(context->op());
447 } 447 }
448 448
449 SignedSettingsHelper* SignedSettingsHelper::Get() { 449 SignedSettingsHelper* SignedSettingsHelper::Get() {
450 return g_signed_settings_helper_impl.Pointer(); 450 return g_signed_settings_helper_impl.Pointer();
451 } 451 }
452 452
453 } // namespace chromeos 453 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698