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

Unified Diff: base/prefs/pref_service.cc

Issue 254473002: Add support for int64 and uint64 in values.h's API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test compile Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/prefs/pref_service.h ('k') | base/values.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/prefs/pref_service.cc
diff --git a/base/prefs/pref_service.cc b/base/prefs/pref_service.cc
index a8e56d0b370680f9400e8432014d08b357fc4179..eaeb28b6b8c237f471d5229d7ee3715524ea7882 100644
--- a/base/prefs/pref_service.cc
+++ b/base/prefs/pref_service.cc
@@ -16,7 +16,6 @@
#include "base/prefs/pref_registry.h"
#include "base/prefs/pref_value_store.h"
#include "base/stl_util.h"
-#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/value_conversions.h"
#include "build/build_config.h"
@@ -146,6 +145,36 @@ std::string PrefService::GetString(const char* path) const {
return result;
}
+int64 PrefService::GetInt64(const char* path) const {
+ DCHECK(CalledOnValidThread());
+
+ int64 result = 0;
+
+ const base::Value* value = GetPreferenceValue(path);
+ if (!value) {
+ NOTREACHED() << "Trying to read an unregistered pref: " << path;
+ return result;
+ }
+ bool rv = value->GetAsInt64(&result);
+ DCHECK(rv);
+ return result;
+}
+
+uint64 PrefService::GetUint64(const char* path) const {
+ DCHECK(CalledOnValidThread());
+
+ uint64 result = 0;
+
+ const base::Value* value = GetPreferenceValue(path);
+ if (!value) {
+ NOTREACHED() << "Trying to read an unregistered pref: " << path;
+ return result;
+ }
+ bool rv = value->GetAsUint64(&result);
+ DCHECK(rv);
+ return result;
+}
+
base::FilePath PrefService::GetFilePath(const char* path) const {
DCHECK(CalledOnValidThread());
@@ -353,50 +382,16 @@ void PrefService::SetString(const char* path, const std::string& value) {
SetUserPrefValue(path, new base::StringValue(value));
}
-void PrefService::SetFilePath(const char* path, const base::FilePath& value) {
- SetUserPrefValue(path, base::CreateFilePathValue(value));
-}
-
void PrefService::SetInt64(const char* path, int64 value) {
- SetUserPrefValue(path, new base::StringValue(base::Int64ToString(value)));
-}
-
-int64 PrefService::GetInt64(const char* path) const {
- DCHECK(CalledOnValidThread());
-
- const base::Value* value = GetPreferenceValue(path);
- if (!value) {
- NOTREACHED() << "Trying to read an unregistered pref: " << path;
- return 0;
- }
- std::string result("0");
- bool rv = value->GetAsString(&result);
- DCHECK(rv);
-
- int64 val;
- base::StringToInt64(result, &val);
- return val;
+ SetUserPrefValue(path, new base::StringValue(value));
}
void PrefService::SetUint64(const char* path, uint64 value) {
- SetUserPrefValue(path, new base::StringValue(base::Uint64ToString(value)));
+ SetUserPrefValue(path, new base::StringValue(value));
}
-uint64 PrefService::GetUint64(const char* path) const {
- DCHECK(CalledOnValidThread());
-
- const base::Value* value = GetPreferenceValue(path);
- if (!value) {
- NOTREACHED() << "Trying to read an unregistered pref: " << path;
- return 0;
- }
- std::string result("0");
- bool rv = value->GetAsString(&result);
- DCHECK(rv);
-
- uint64 val;
- base::StringToUint64(result, &val);
- return val;
+void PrefService::SetFilePath(const char* path, const base::FilePath& value) {
+ SetUserPrefValue(path, base::CreateFilePathValue(value));
}
base::Value* PrefService::GetMutableUserPref(const char* path,
« no previous file with comments | « base/prefs/pref_service.h ('k') | base/values.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698