summaryrefslogtreecommitdiffstats
path: root/base/values.cc
diff options
context:
space:
mode:
authorbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-21 16:35:04 +0000
committerbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-21 16:35:04 +0000
commit68d9d35f4cec33ccdd5931249e0c58fd7dca830a (patch)
tree1751feffa1fcbd851ff8779f8be6a1211ee45457 /base/values.cc
parent7f0a77b0b2a5492f34554fdff9e8467e9d8db930 (diff)
downloadchromium_src-68d9d35f4cec33ccdd5931249e0c58fd7dca830a.zip
chromium_src-68d9d35f4cec33ccdd5931249e0c58fd7dca830a.tar.gz
chromium_src-68d9d35f4cec33ccdd5931249e0c58fd7dca830a.tar.bz2
Add MoveToThread method to PrefMember to make it safe to read pref values from other threads.
BUG=73385 TEST=PrefMemberTest.MoveToThread Review URL: http://codereview.chromium.org/6524041 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75555 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/values.cc')
-rw-r--r--base/values.cc33
1 files changed, 33 insertions, 0 deletions
diff --git a/base/values.cc b/base/values.cc
index 9c96f26..3340f9b 100644
--- a/base/values.cc
+++ b/base/values.cc
@@ -4,8 +4,10 @@
#include "base/values.h"
+#include "base/file_path.h"
#include "base/logging.h"
#include "base/string_util.h"
+#include "base/sys_string_conversions.h"
#include "base/utf_string_conversions.h"
namespace {
@@ -95,6 +97,19 @@ StringValue* Value::CreateStringValue(const string16& in_value) {
}
// static
+StringValue* Value::CreateFilePathValue(const FilePath& in_value) {
+#if defined(OS_POSIX)
+ // Value::SetString only knows about UTF8 strings, so convert the path from
+ // the system native value to UTF8.
+ std::string path_utf8 = WideToUTF8(base::SysNativeMBToWide(in_value.value()));
+ return new StringValue(path_utf8);
+#else
+ return new StringValue(in_value.value());
+#endif
+
+}
+
+// static
BinaryValue* Value::CreateBinaryValue(char* buffer, size_t size) {
return BinaryValue::Create(buffer, size);
}
@@ -119,6 +134,10 @@ bool Value::GetAsString(string16* out_value) const {
return false;
}
+bool Value::GetAsFilePath(FilePath* out_value) const {
+ return false;
+}
+
bool Value::GetAsList(ListValue** out_value) {
return false;
}
@@ -250,6 +269,20 @@ bool StringValue::GetAsString(string16* out_value) const {
return true;
}
+bool StringValue::GetAsFilePath(FilePath* out_value) const {
+ if (out_value) {
+ FilePath::StringType result;
+#if defined(OS_POSIX)
+ // We store filepaths as UTF8, so convert it back to the system type.
+ result = base::SysWideToNativeMB(UTF8ToWide(value_));
+#elif defined(OS_WIN)
+ result = UTF8ToUTF16(value_);
+#endif
+ *out_value = FilePath(result);
+ }
+ return true;
+}
+
StringValue* StringValue::DeepCopy() const {
return CreateStringValue(value_);
}