OLD | NEW |
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/value_conversions.h" | 5 #include "base/value_conversions.h" |
6 | 6 |
| 7 #include <stdint.h> |
| 8 |
7 #include <string> | 9 #include <string> |
8 | 10 |
9 #include "base/basictypes.h" | |
10 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
11 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
12 #include "base/time/time.h" | 13 #include "base/time/time.h" |
13 #include "base/values.h" | 14 #include "base/values.h" |
14 | 15 |
15 namespace base { | 16 namespace base { |
16 | 17 |
17 // |Value| internally stores strings in UTF-8, so we have to convert from the | 18 // |Value| internally stores strings in UTF-8, so we have to convert from the |
18 // system native code to UTF-8 and back. | 19 // system native code to UTF-8 and back. |
19 StringValue* CreateFilePathValue(const FilePath& in_value) { | 20 StringValue* CreateFilePathValue(const FilePath& in_value) { |
(...skipping 11 matching lines...) Expand all Loading... |
31 | 32 |
32 // |Value| does not support 64-bit integers, and doubles do not have enough | 33 // |Value| does not support 64-bit integers, and doubles do not have enough |
33 // precision, so we store the 64-bit time value as a string instead. | 34 // precision, so we store the 64-bit time value as a string instead. |
34 StringValue* CreateTimeDeltaValue(const TimeDelta& time) { | 35 StringValue* CreateTimeDeltaValue(const TimeDelta& time) { |
35 std::string string_value = base::Int64ToString(time.ToInternalValue()); | 36 std::string string_value = base::Int64ToString(time.ToInternalValue()); |
36 return new StringValue(string_value); | 37 return new StringValue(string_value); |
37 } | 38 } |
38 | 39 |
39 bool GetValueAsTimeDelta(const Value& value, TimeDelta* time) { | 40 bool GetValueAsTimeDelta(const Value& value, TimeDelta* time) { |
40 std::string str; | 41 std::string str; |
41 int64 int_value; | 42 int64_t int_value; |
42 if (!value.GetAsString(&str) || !base::StringToInt64(str, &int_value)) | 43 if (!value.GetAsString(&str) || !base::StringToInt64(str, &int_value)) |
43 return false; | 44 return false; |
44 if (time) | 45 if (time) |
45 *time = TimeDelta::FromInternalValue(int_value); | 46 *time = TimeDelta::FromInternalValue(int_value); |
46 return true; | 47 return true; |
47 } | 48 } |
48 | 49 |
49 } // namespace base | 50 } // namespace base |
OLD | NEW |