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 // Keep this file in sync with the .proto files in this directory. | 5 // Keep this file in sync with the .proto files in this directory. |
6 | 6 |
7 #include "sync/protocol/proto_value_conversions.h" | 7 #include "sync/protocol/proto_value_conversions.h" |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 // Basic Type -> Value functions. | 47 // Basic Type -> Value functions. |
48 | 48 |
49 base::StringValue* MakeInt64Value(int64 x) { | 49 base::StringValue* MakeInt64Value(int64 x) { |
50 return new base::StringValue(base::Int64ToString(x)); | 50 return new base::StringValue(base::Int64ToString(x)); |
51 } | 51 } |
52 | 52 |
53 // TODO(akalin): Perhaps make JSONWriter support BinaryValue and use | 53 // TODO(akalin): Perhaps make JSONWriter support BinaryValue and use |
54 // that instead of a StringValue. | 54 // that instead of a StringValue. |
55 base::StringValue* MakeBytesValue(const std::string& bytes) { | 55 base::StringValue* MakeBytesValue(const std::string& bytes) { |
56 std::string bytes_base64; | 56 std::string bytes_base64; |
57 if (!base::Base64Encode(bytes, &bytes_base64)) { | 57 base::Base64Encode(bytes, &bytes_base64); |
58 NOTREACHED(); | |
59 } | |
60 return new base::StringValue(bytes_base64); | 58 return new base::StringValue(bytes_base64); |
61 } | 59 } |
62 | 60 |
63 base::StringValue* MakeStringValue(const std::string& str) { | 61 base::StringValue* MakeStringValue(const std::string& str) { |
64 return new base::StringValue(str); | 62 return new base::StringValue(str); |
65 } | 63 } |
66 | 64 |
67 // T is the enum type. | 65 // T is the enum type. |
68 template <class T> | 66 template <class T> |
69 base::StringValue* MakeEnumValue(T t, const char* (*converter_fn)(T)) { | 67 base::StringValue* MakeEnumValue(T t, const char* (*converter_fn)(T)) { |
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1005 #undef SET_BYTES | 1003 #undef SET_BYTES |
1006 #undef SET_INT32 | 1004 #undef SET_INT32 |
1007 #undef SET_INT64 | 1005 #undef SET_INT64 |
1008 #undef SET_INT64_REP | 1006 #undef SET_INT64_REP |
1009 #undef SET_STR | 1007 #undef SET_STR |
1010 #undef SET_STR_REP | 1008 #undef SET_STR_REP |
1011 | 1009 |
1012 #undef SET_FIELD | 1010 #undef SET_FIELD |
1013 | 1011 |
1014 } // namespace syncer | 1012 } // namespace syncer |
OLD | NEW |