| 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/json/json_parser.h" | 5 #include "base/json/json_parser.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 144 |
| 145 // Overridden from Value: | 145 // Overridden from Value: |
| 146 bool GetAsString(std::string* out_value) const override { | 146 bool GetAsString(std::string* out_value) const override { |
| 147 string_piece_.CopyToString(out_value); | 147 string_piece_.CopyToString(out_value); |
| 148 return true; | 148 return true; |
| 149 } | 149 } |
| 150 bool GetAsString(string16* out_value) const override { | 150 bool GetAsString(string16* out_value) const override { |
| 151 *out_value = UTF8ToUTF16(string_piece_); | 151 *out_value = UTF8ToUTF16(string_piece_); |
| 152 return true; | 152 return true; |
| 153 } | 153 } |
| 154 Value* DeepCopy() const override { | 154 Value* DeepCopy() const override { return new StringValue(string_piece_); } |
| 155 return new StringValue(string_piece_.as_string()); | |
| 156 } | |
| 157 bool Equals(const Value* other) const override { | 155 bool Equals(const Value* other) const override { |
| 158 std::string other_string; | 156 std::string other_string; |
| 159 return other->IsType(TYPE_STRING) && other->GetAsString(&other_string) && | 157 return other->IsType(TYPE_STRING) && other->GetAsString(&other_string) && |
| 160 StringPiece(other_string) == string_piece_; | 158 StringPiece(other_string) == string_piece_; |
| 161 } | 159 } |
| 162 | 160 |
| 163 private: | 161 private: |
| 164 // The location in the original input stream. | 162 // The location in the original input stream. |
| 165 StringPiece string_piece_; | 163 StringPiece string_piece_; |
| 166 | 164 |
| (...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 981 const std::string& description) { | 979 const std::string& description) { |
| 982 if (line || column) { | 980 if (line || column) { |
| 983 return StringPrintf("Line: %i, column: %i, %s", | 981 return StringPrintf("Line: %i, column: %i, %s", |
| 984 line, column, description.c_str()); | 982 line, column, description.c_str()); |
| 985 } | 983 } |
| 986 return description; | 984 return description; |
| 987 } | 985 } |
| 988 | 986 |
| 989 } // namespace internal | 987 } // namespace internal |
| 990 } // namespace base | 988 } // namespace base |
| OLD | NEW |