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

Side by Side Diff: base/prefs/pref_service.cc

Issue 131503015: Get rid of some uses of base::Create*Value (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more Created 6 years, 10 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
« no previous file with comments | « base/prefs/pref_registry_simple.cc ('k') | base/prefs/pref_service_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/prefs/pref_service.h" 5 #include "base/prefs/pref_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 return; 329 return;
330 } 330 }
331 user_pref_store_->RemoveValue(path); 331 user_pref_store_->RemoveValue(path);
332 } 332 }
333 333
334 void PrefService::Set(const char* path, const base::Value& value) { 334 void PrefService::Set(const char* path, const base::Value& value) {
335 SetUserPrefValue(path, value.DeepCopy()); 335 SetUserPrefValue(path, value.DeepCopy());
336 } 336 }
337 337
338 void PrefService::SetBoolean(const char* path, bool value) { 338 void PrefService::SetBoolean(const char* path, bool value) {
339 SetUserPrefValue(path, base::Value::CreateBooleanValue(value)); 339 SetUserPrefValue(path, new base::FundamentalValue(value));
340 } 340 }
341 341
342 void PrefService::SetInteger(const char* path, int value) { 342 void PrefService::SetInteger(const char* path, int value) {
343 SetUserPrefValue(path, base::Value::CreateIntegerValue(value)); 343 SetUserPrefValue(path, new base::FundamentalValue(value));
344 } 344 }
345 345
346 void PrefService::SetDouble(const char* path, double value) { 346 void PrefService::SetDouble(const char* path, double value) {
347 SetUserPrefValue(path, base::Value::CreateDoubleValue(value)); 347 SetUserPrefValue(path, new base::FundamentalValue(value));
348 } 348 }
349 349
350 void PrefService::SetString(const char* path, const std::string& value) { 350 void PrefService::SetString(const char* path, const std::string& value) {
351 SetUserPrefValue(path, base::Value::CreateStringValue(value)); 351 SetUserPrefValue(path, new base::StringValue(value));
352 } 352 }
353 353
354 void PrefService::SetFilePath(const char* path, const base::FilePath& value) { 354 void PrefService::SetFilePath(const char* path, const base::FilePath& value) {
355 SetUserPrefValue(path, base::CreateFilePathValue(value)); 355 SetUserPrefValue(path, base::CreateFilePathValue(value));
356 } 356 }
357 357
358 void PrefService::SetInt64(const char* path, int64 value) { 358 void PrefService::SetInt64(const char* path, int64 value) {
359 SetUserPrefValue(path, 359 SetUserPrefValue(path, new base::StringValue(base::Int64ToString(value)));
360 base::Value::CreateStringValue(base::Int64ToString(value)));
361 } 360 }
362 361
363 int64 PrefService::GetInt64(const char* path) const { 362 int64 PrefService::GetInt64(const char* path) const {
364 DCHECK(CalledOnValidThread()); 363 DCHECK(CalledOnValidThread());
365 364
366 const base::Value* value = GetPreferenceValue(path); 365 const base::Value* value = GetPreferenceValue(path);
367 if (!value) { 366 if (!value) {
368 NOTREACHED() << "Trying to read an unregistered pref: " << path; 367 NOTREACHED() << "Trying to read an unregistered pref: " << path;
369 return 0; 368 return 0;
370 } 369 }
371 std::string result("0"); 370 std::string result("0");
372 bool rv = value->GetAsString(&result); 371 bool rv = value->GetAsString(&result);
373 DCHECK(rv); 372 DCHECK(rv);
374 373
375 int64 val; 374 int64 val;
376 base::StringToInt64(result, &val); 375 base::StringToInt64(result, &val);
377 return val; 376 return val;
378 } 377 }
379 378
380 void PrefService::SetUint64(const char* path, uint64 value) { 379 void PrefService::SetUint64(const char* path, uint64 value) {
381 SetUserPrefValue(path, 380 SetUserPrefValue(path, new base::StringValue(base::Uint64ToString(value)));
382 base::Value::CreateStringValue(base::Uint64ToString(value)));
383 } 381 }
384 382
385 uint64 PrefService::GetUint64(const char* path) const { 383 uint64 PrefService::GetUint64(const char* path) const {
386 DCHECK(CalledOnValidThread()); 384 DCHECK(CalledOnValidThread());
387 385
388 const base::Value* value = GetPreferenceValue(path); 386 const base::Value* value = GetPreferenceValue(path);
389 if (!value) { 387 if (!value) {
390 NOTREACHED() << "Trying to read an unregistered pref: " << path; 388 NOTREACHED() << "Trying to read an unregistered pref: " << path;
391 return 0; 389 return 0;
392 } 390 }
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 DCHECK(found_value->IsType(default_type)); 544 DCHECK(found_value->IsType(default_type));
547 return found_value; 545 return found_value;
548 } else { 546 } else {
549 // Every registered preference has at least a default value. 547 // Every registered preference has at least a default value.
550 NOTREACHED() << "no valid value found for registered pref " << path; 548 NOTREACHED() << "no valid value found for registered pref " << path;
551 } 549 }
552 } 550 }
553 551
554 return NULL; 552 return NULL;
555 } 553 }
OLDNEW
« no previous file with comments | « base/prefs/pref_registry_simple.cc ('k') | base/prefs/pref_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698