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

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

Issue 2664753002: Remove base::StringValue (Closed)
Patch Set: Rebase Created 3 years, 9 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
« no previous file with comments | « components/prefs/pref_registry_simple.cc ('k') | components/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 "components/prefs/pref_service.h" 5 #include "components/prefs/pref_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 394
395 void PrefService::SetInteger(const std::string& path, int value) { 395 void PrefService::SetInteger(const std::string& path, int value) {
396 SetUserPrefValue(path, new base::Value(value)); 396 SetUserPrefValue(path, new base::Value(value));
397 } 397 }
398 398
399 void PrefService::SetDouble(const std::string& path, double value) { 399 void PrefService::SetDouble(const std::string& path, double value) {
400 SetUserPrefValue(path, new base::Value(value)); 400 SetUserPrefValue(path, new base::Value(value));
401 } 401 }
402 402
403 void PrefService::SetString(const std::string& path, const std::string& value) { 403 void PrefService::SetString(const std::string& path, const std::string& value) {
404 SetUserPrefValue(path, new base::StringValue(value)); 404 SetUserPrefValue(path, new base::Value(value));
405 } 405 }
406 406
407 void PrefService::SetFilePath(const std::string& path, 407 void PrefService::SetFilePath(const std::string& path,
408 const base::FilePath& value) { 408 const base::FilePath& value) {
409 SetUserPrefValue(path, base::CreateFilePathValue(value)); 409 SetUserPrefValue(path, base::CreateFilePathValue(value));
410 } 410 }
411 411
412 void PrefService::SetInt64(const std::string& path, int64_t value) { 412 void PrefService::SetInt64(const std::string& path, int64_t value) {
413 SetUserPrefValue(path, new base::StringValue(base::Int64ToString(value))); 413 SetUserPrefValue(path, new base::Value(base::Int64ToString(value)));
414 } 414 }
415 415
416 int64_t PrefService::GetInt64(const std::string& path) const { 416 int64_t PrefService::GetInt64(const std::string& path) const {
417 DCHECK(CalledOnValidThread()); 417 DCHECK(CalledOnValidThread());
418 418
419 const base::Value* value = GetPreferenceValue(path); 419 const base::Value* value = GetPreferenceValue(path);
420 if (!value) { 420 if (!value) {
421 NOTREACHED() << "Trying to read an unregistered pref: " << path; 421 NOTREACHED() << "Trying to read an unregistered pref: " << path;
422 return 0; 422 return 0;
423 } 423 }
424 std::string result("0"); 424 std::string result("0");
425 bool rv = value->GetAsString(&result); 425 bool rv = value->GetAsString(&result);
426 DCHECK(rv); 426 DCHECK(rv);
427 427
428 int64_t val; 428 int64_t val;
429 base::StringToInt64(result, &val); 429 base::StringToInt64(result, &val);
430 return val; 430 return val;
431 } 431 }
432 432
433 void PrefService::SetUint64(const std::string& path, uint64_t value) { 433 void PrefService::SetUint64(const std::string& path, uint64_t value) {
434 SetUserPrefValue(path, new base::StringValue(base::Uint64ToString(value))); 434 SetUserPrefValue(path, new base::Value(base::Uint64ToString(value)));
435 } 435 }
436 436
437 uint64_t PrefService::GetUint64(const std::string& path) const { 437 uint64_t PrefService::GetUint64(const std::string& path) const {
438 DCHECK(CalledOnValidThread()); 438 DCHECK(CalledOnValidThread());
439 439
440 const base::Value* value = GetPreferenceValue(path); 440 const base::Value* value = GetPreferenceValue(path);
441 if (!value) { 441 if (!value) {
442 NOTREACHED() << "Trying to read an unregistered pref: " << path; 442 NOTREACHED() << "Trying to read an unregistered pref: " << path;
443 return 0; 443 return 0;
444 } 444 }
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 DCHECK(found_value->IsType(default_type)); 614 DCHECK(found_value->IsType(default_type));
615 return found_value; 615 return found_value;
616 } else { 616 } else {
617 // Every registered preference has at least a default value. 617 // Every registered preference has at least a default value.
618 NOTREACHED() << "no valid value found for registered pref " << path; 618 NOTREACHED() << "no valid value found for registered pref " << path;
619 } 619 }
620 } 620 }
621 621
622 return NULL; 622 return NULL;
623 } 623 }
OLDNEW
« no previous file with comments | « components/prefs/pref_registry_simple.cc ('k') | components/prefs/pref_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698